$npx -y skills add nvidia/skills --skill jetson-build-sourceUse when you need to rebuild the BSP overlay — DT, OOT modules, or kernel — from changes under bsp_sources/. Triggers: build bsp, rebuild dtb, rebuild kernel.
| 1 | # Build BSP Source |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Rebuild the kernel-side artifacts (DTBs, OOT modules, in-tree |
| 6 | modules, kernel `Image`) implied by changes under |
| 7 | `<source.root_path>/bsp_sources/`, and write a manifest that |
| 8 | `/jetson-promote-image` reads to stage those outputs into the BSP |
| 9 | image. The skill never writes into `<bsp_image.root_path>` itself. |
| 10 | |
| 11 | ## Prerequisites |
| 12 | |
| 13 | - Active target-platform profile with `bsp_image:` and |
| 14 | `source.toolchain:` resolved (run `/jetson-init-image` and |
| 15 | `/jetson-init-source` first). |
| 16 | - `<source.root_path>/bsp_sources/` populated with the kernel-side |
| 17 | checkout layout `/jetson-init-source` materializes. |
| 18 | - `<bsp_image.root_path>/Linux_for_Tegra/source/kernel_src_build_env.sh` |
| 19 | present (extracted from `public_sources.tbz2`). |
| 20 | - Host packages: `flex`, `bison`, `libssl-dev` (hard); `git`, |
| 21 | `build-essential`, `bc`, `zstd` (warn-only). |
| 22 | - Cross-toolchain at `${source.toolchain}gcc` resolvable on disk. |
| 23 | |
| 24 | ## Overview |
| 25 | |
| 26 | This skill is the **Build** stage of the workflow — see |
| 27 | [`../../context/bsp-customization-workflow.md`](../../context/bsp-customization-workflow.md) |
| 28 | for where it sits in the Setup → Customize → Build → Deploy pipeline |
| 29 | and what triggers it. The skill takes source-side customization |
| 30 | commits, rebuilds the implied artifacts, and records which were |
| 31 | rebuilt in a manifest. Outputs stay in-tree under |
| 32 | `<source.root_path>/bsp_sources/`; |
| 33 | [`jetson-promote-image`](../jetson-promote-image/SKILL.md) reads the |
| 34 | manifest at Deploy to copy each rebuilt artifact into the matching |
| 35 | path under `<bsp_image.root_path>/Linux_for_Tegra/`. |
| 36 | |
| 37 | Overlay-only edits (`nvpmodel.conf`, `nvfancontrol.conf`, BPMP DTB) |
| 38 | skip Build — `customize-*` stages them directly to the overlay |
| 39 | tracker; BPMP DTB uses the `dtc` decompile → edit → recompile loop in |
| 40 | [`../../references/bsp-customization-bpmp-dtb.md`](../../references/bsp-customization-bpmp-dtb.md). |
| 41 | |
| 42 | **Custom-overlay slot ownership.** Kernel-DT customizations from |
| 43 | every customize-* skill collect into a single composite |
| 44 | `tegra<soc>-<carrier-id-sku>+<module-id>-xxxx-custom.dts` per |
| 45 | active target — see |
| 46 | [`../../references/bsp-customization-kernel-dtb.md`](../../references/bsp-customization-kernel-dtb.md) |
| 47 | for the filename / location / append protocol. This skill is the |
| 48 | **sole owner** of the composite's per-dir Makefile registration |
| 49 | (`dtbo-y += <name>.dtbo`) and the carrier flash conf's |
| 50 | `OVERLAY_DTB_FILE+=` line (the "Register composite custom overlay" step). |
| 51 | |
| 52 | **Four build modes** matched to the dirty-repo profile: |
| 53 | |
| 54 | | Mode | What's built | Auto-picks when | |
| 55 | |---|---|---| |
| 56 | | **dt** | NVIDIA DTBs only | only `hardware/nvidia/*` or `kernel-devicetree` dirty | |
| 57 | | **oot** | OOT modules (six repos) | only OOT repos dirty | |
| 58 | | **kernel** | Kernel `Image` + full in-tree `.ko` set + kernel-side dtbs | only `kernel/$KERNEL_SRC_DIR` dirty | |
| 59 | | **full** | Everything above + optional install consolidation | mixed dirty set | |
| 60 | |
| 61 | Mode selection: **auto** (default — invoke `/jetson-build-source` |
| 62 | with no argument) walks the dirty-repo set; force a specific mode |
| 63 | by passing it as the skill argument. |
| 64 | |
| 65 | **Design principle: delegate to upstream.** Every build primitive |
| 66 | already exists in `<bsp_image.root_path>/Linux_for_Tegra/source/` |
| 67 | — the env file, top-level Makefile (`nvidia-dtbs` / `modules` / |
| 68 | `modules_install`), kernel Makefile (`kernel` / `install`). The |
| 69 | skill drives those primitives against |
| 70 | `<source.root_path>/bsp_sources/` — never duplicates their |
| 71 | logic in shell. |
| 72 | |
| 73 | ## When to invoke |
| 74 | |
| 75 | - **Auto-chained** at the end of a Customize `customize-*` invocation |
| 76 | whenever Customize committed to a kernel-side source repo. |
| 77 | - **Manual re-run** via `/jetson-build-source [<mode>]` when: |
| 78 | - the auto-chained build was interrupted, |
| 79 | - source commits arrived via `git pull` from other users, |
| 80 | - the user wants to force a rebuild without a fresh edit, |
| 81 | - the user wants a specific mode (e.g. install consolidation for |
| 82 | a manual scp deploy to a DUT). |
| 83 | |
| 84 | ## Instructions |
| 85 | |
| 86 | ### Resolve active target + paths + upstream env |
| 87 | |
| 88 | Resolve the active profile per |
| 89 | [`../../context/target-platform-contract.md`](../../context/target-platform-contract.md). |
| 90 | Refuse and route in these cases: |
| 91 | |
| 92 | | Condition | Route to | |
| 93 | |---|---| |
| 94 | | No active profile, or `active: NA` | `/jetson-set-target` or `/jetson-init-target` | |
| 95 | | Profile lacks `bsp_image:` | `/jetson-init-image` | |
| 96 | | Profile lacks `source.toolchain:` | `/jetson-init-source` | |
| 97 | | `<source.root_path>/bsp_sources/` missing or empty | `/jetson-init-source` | |
| 98 | | `<bsp_image.root_path>/Linux_for_Tegra/source/kernel_src_build_env.sh` missing | `/jetson-init-image` (BSP not properly extracted) | |
| 99 | |
| 100 | Bi |