Build BSP Source
Purpose
Rebuild the kernel-side artifacts (DTBs, OOT modules, in-tree
modules, kernel
) implied by changes under
<source.root_path>/bsp_sources/
, and write a manifest that
reads to stage those outputs into the BSP
image. The skill never writes into
itself.
Prerequisites
- Active target-platform profile with and
resolved (run and
first).
<source.root_path>/bsp_sources/
populated with the kernel-side
checkout layout materializes.
<bsp_image.root_path>/Linux_for_Tegra/source/kernel_src_build_env.sh
present (extracted from ).
- Host packages: , , (hard); ,
, , (warn-only).
- Cross-toolchain at resolvable on disk.
Overview
This skill is the
Build stage of the workflow — see
../../context/bsp-customization-workflow.md
for where it sits in the Setup → Customize → Build → Deploy pipeline
and what triggers it. The skill takes source-side customization
commits, rebuilds the implied artifacts, and records which were
rebuilt in a manifest. Outputs stay in-tree under
<source.root_path>/bsp_sources/
;
reads the
manifest at Deploy to copy each rebuilt artifact into the matching
path under
<bsp_image.root_path>/Linux_for_Tegra/
.
Overlay-only edits (
,
, BPMP DTB)
skip Build —
stages them directly to the overlay
tracker; BPMP DTB uses the
decompile → edit → recompile loop in
../../references/bsp-customization-bpmp-dtb.md
.
Custom-overlay slot ownership. Kernel-DT customizations from
every customize-* skill collect into a single composite
tegra<soc>-<carrier-id-sku>+<module-id>-xxxx-custom.dts
per
active target — see
../../references/bsp-customization-kernel-dtb.md
for the filename / location / append protocol. This skill is the
sole owner of the composite's per-dir Makefile registration
(
) and the carrier flash conf's
line (the "Register composite custom overlay" step).
Four build modes matched to the dirty-repo profile:
| Mode | What's built | Auto-picks when |
|---|
| dt | NVIDIA DTBs only | only or dirty |
| oot | OOT modules (six repos) | only OOT repos dirty |
| kernel | Kernel + full in-tree set + kernel-side dtbs | only dirty |
| full | Everything above + optional install consolidation | mixed dirty set |
Mode selection:
auto (default — invoke
with no argument) walks the dirty-repo set; force a specific mode
by passing it as the skill argument.
Design principle: delegate to upstream. Every build primitive
already exists in
<bsp_image.root_path>/Linux_for_Tegra/source/
— the env file, top-level Makefile (
/
/
), kernel Makefile (
/
). The
skill drives those primitives against
<source.root_path>/bsp_sources/
— never duplicates their
logic in shell.
When to invoke
- Auto-chained at the end of a Customize invocation
whenever Customize committed to a kernel-side source repo.
- Manual re-run via
/jetson-build-source [<mode>]
when:
- the auto-chained build was interrupted,
- source commits arrived via from other users,
- the user wants to force a rebuild without a fresh edit,
- the user wants a specific mode (e.g. install consolidation for
a manual scp deploy to a DUT).
Instructions
Resolve active target + paths + upstream env
Resolve the active profile per
../../context/target-platform-contract.md
.
Refuse and route in these cases:
| Condition | Route to |
|---|
| No active profile, or | or |
| Profile lacks | |
| Profile lacks | |
<source.root_path>/bsp_sources/
missing or empty | |
<bsp_image.root_path>/Linux_for_Tegra/source/kernel_src_build_env.sh
missing | (BSP not properly extracted) |
Bind:
bash
WORKSPACE=<parent of target-platform/>
BSP_SRC=<bsp_image.root_path>/Linux_for_Tegra/source # NVIDIA's build primitives
KS=<source.root_path>/bsp_sources # our kernel-side checkout
KOUT=<source.root_path>/.build/kernel-out # DT-mode out-of-tree build dir
STAGE=<source.root_path>/.build/install-stage # install consolidation (full mode / opt-in)
STATE=<source.root_path>/.build-state.yaml # per-repo watermark
MANIFEST=<source.root_path>/.build-manifest.yaml # rebuilt-artifact list for jetson-promote-image
Source the NVIDIA build env to inherit canonical names — never
hardcode
, the OOT module list, or
:
bash
source "$BSP_SRC/kernel_src_build_env.sh"
# Now in scope: KERNEL_SRC_DIR (e.g. kernel-noble), KERNEL_DEF_CONFIG,
# OOT_SOURCE_LIST, kernel_name (e.g. noble), KERNEL_MODULAR_BUILD
Refuse if
$KS/kernel/$KERNEL_SRC_DIR/
is missing or if any name
in
is missing under
. Route to
.
Resolve toolchain (read-only)
Read
from the active profile (authored by
). Validate:
bash
export ARCH=arm64
export CROSS_COMPILE=<source.toolchain> # trailing dash mandatory
[ -f "${CROSS_COMPILE}gcc" ] || refuse \
"source.toolchain points at ${CROSS_COMPILE}gcc which does not exist. Re-run /jetson-init-source."
A trailing dash on
is mandatory — kbuild treats it
as a prefix (
); a missing dash breaks with
. The
check catches it before any
runs.
This skill
never prompts for the toolchain or attempts to
resolve a missing one — that's
's exclusive
responsibility. A missing field is a Setup gap; route there.
Verify build-host prerequisites once:
bash
for p in flex bison libssl-dev; do
dpkg -s "$p" >/dev/null 2>&1 || refuse "host package missing: $p"
done
for p in git build-essential bc zstd; do
dpkg -s "$p" >/dev/null 2>&1 || warn "host package missing: $p"
done
Detect dirty source repos
The watermark file
records the last successfully built
commit per kernel-side repo. The repo list is derived at runtime
from
+
. For each repo:
HEAD ≠ watermark → dirty; uncommitted edits (
non-zero) → also dirty.
Branch-A note: when
is one mono-repo with a
single
, every canonical sub-path shares the same HEAD —
the watermark schema still keys per-sub-path and the dirty set
still works (any change anywhere flips every sub-path's HEAD).
If
is absent (first build), treat all repos as clean
unless the auto-chain context says "Customize just committed". If
is empty and no mode argument was passed: report
"nothing to build" and return.
Pick build mode
Map the dirty set to a mode (auto), or honor the mode argument:
| Dirty repos (auto) | Mode |
|---|
| Only or | |
| Only OOT subset of | |
| Only | |
| Any mix spanning the above | |
Modes are union-able:
runs
→
→
in that
order (kernel produces headers OOT needs;
uses the
same generated headers). A manually passed mode argument skips
auto-detection.
Execute build
Common setup + per-mode build snippets
Common setup (validate orchestrator Makefiles,
) and the
exact
invocations for each mode (
,
,
,
) plus the optional install consolidation pass live in
references/build-modes.md
. Drive
the relevant mode's snippet against the bindings from the
"Resolve active target + paths + upstream env" step.
Register composite custom overlay (dt + full only)
Skip unless the selected mode is
or
. The composite
overlay slot is documented in
../../references/bsp-customization-kernel-dtb.md
;
this sub-step owns the build / Makefile / flash-conf side of it.
Resolve the composite path for the active target (
,
,
) using the active profile's
chip family, carrier ID/SKU, and module ID — full snippet in
references/composite-registration.md
.
Gate (symmetric). drives both directions:
present → apply the two idempotent patches below; absent → run the
cleanup pass
to strip any stale
/
line from a
prior run. Either path keeps
from referencing
an unbuilt
— the build-time enforcement of the
no-direct-in-tree-DT-edits rule.
- Per-dir Makefile — append after the
last literal-named entry. Inserting after the
merge-back line skips the
$(addprefix makefile-path/,…)
prefix pass and the build silently drops
the composite. Commit to the mono-repo. Full
snippet + rationale:
references/composite-registration.md
.
- Carrier flash conf — append
OVERLAY_DTB_FILE+=",<name>.dtbo"
with first-touch pristine import on the overlay tracker. On a
fresh workspace the tracker is empty git-init; import the
conf from and commit as before the
customization commit (workflow contract). Full snippet:
references/composite-registration.md
.
The composite's parent sub-repo flipping HEAD during a customize-*
append is what the "Detect dirty source repos" step's dirty detection consumes — no extra
bookkeeping needed here.
Self-check before invoking
:
bash
grep -qxF "dtbo-y += ${COMPOSITE_BASE}.dtbo" "$COMPOSITE_MK" \
|| refuse "Composite Makefile registration missing after patch."
grep -qxF "$line" "$FLASH_CONF" \
|| refuse "Composite flash-conf registration missing after patch."
Write the build manifest
Walk the
set and emit a manifest entry per implied artifact,
following the
trace-to-dirty policy — only artifacts traceable
to a dirty source repo. Promoting baseline-divergence noise would
attribute it to a customization's audit trail (forbidden).
The full source → kbuild → destination mapping, YAML schema, and
filter rules live in
references/manifest-schema.md
.
Atomic write: stage to
, then
.
Update watermark + summary
On success, rewrite
with the new per-repo HEADs, toolchain,
, and last-run mode (schema in
references/manifest-schema.md
).
Report:
- Toolchain (from ).
- Build mode: (auto-picked or forced by skill argument).
- Dirty repos and their new HEADs.
- Artifacts built: counts per kind (, in-tree , OOT , ).
- Manifest path + entry count.
- Consolidated install stage path (if the "Install consolidation" step ran).
- Next step: .
If a Customize skill triggered this run, prompt the user to re-issue
their original request.
Limitations
The top tier — failure modes that block a build or silently
produce wrong artifacts. See
references/long-tail-gotchas.md
for invariants, deploy patterns, and performance hints.
- Toolchain resolution is 's job. This
skill only reads and exports .
Missing field → refuse and route, never resolve in-skill.
- R36.x Branch-A collision. R36.x's
can leave the dGPU/OpenRM proprietary
Makefile at instead of the Tegra orchestrator;
its target recurses into + ,
pulls host headers, and breaks arm64 cross-builds
with
'-mlittle-endian' unrecognized
. R38+ extractions are
unaffected. 's step 3a is the primary defense
(extract-time); the "Common setup" check here is the safety net.
Don't relax the regex.
- Kernel-DT changes: composite-overlay-only, split ownership.
Direct edits to in-tree / files under
are forbidden for customize-* skills — every kernel-DT change
lands as a fragment in the composite overlay slot
(rule + rationale).
The composite content is owned by each customize-*
skill; the build / Makefile / flash-conf registration is
owned by this skill (gated on the composite existing — so
can't reference an unbuilt ).
- the "Register composite custom overlay" step Makefile insertion point matters. Insert after
the last literal-named entry; inserting after
skips the
$(addprefix makefile-path/,…)
prefix
pass and the build silently drops your . The regex
filters correctly; do not relax it.
- the "Register composite custom overlay" step first-touch needs pristine import. On a fresh
workspace the overlay tracker is empty git-init — the carrier
flash conf is imported from and committed as
before the customization commit. Both commits go
through the workflow acceptance gate.
- Avoid bare in shell snippets inside this SKILL.md. When
invoked with an argument, the harness expands skill-body
against the caller's before handing the rendered prompt to
the model. Use sed-based line splicing or
. See
references/composite-registration.md
.
- No overlay staging. Build outputs stay where the build put
them; the manifest is the contract to .
Deliberate divergence from the original overlay→promote
indirection — keeps the full build output set out of the
overlay tracker's git history.
- vs in DT mode. Different
semantics (srctree vs objtree); do not collapse. the "DT-only" step's
snippet is correct as written.
- OOT mode prereq: previously-built kernel headers. A manual
invocation against a never-built tree refuses with "run
(or ) first" rather than producing a confusing
build error.
Examples
Auto-detect mode from the dirty source tree (typical invocation):
Force a single mode (skips auto-detect):
/jetson-build-source dt # rebuild NVIDIA DTBs only
/jetson-build-source oot # rebuild OOT modules only
/jetson-build-source kernel # rebuild kernel Image + in-tree modules
/jetson-build-source full # rebuild everything + install consolidation
Typical chain after a customize-* skill commits to a kernel-side
repo (the customize-* skill calls this automatically):
/jetson-customize-pcie ... # commits to hardware/nvidia/.../nv-public
↓
/jetson-build-source # auto-picks `dt` from the dirty set
↓
/jetson-promote-image # reads .build-manifest.yaml, stages into bsp_image
↓
/jetson-flash-image # flashes
Troubleshooting
| Error | Cause | Solution |
|---|
source.toolchain points at <...>gcc which does not exist
| Toolchain field stale (path moved, install missing) | Re-run to re-resolve. This skill never resolves toolchain itself. |
No rule to make target '$KOUT/scripts/Makefile.compiler'
| set to instead of $KS/kernel/$KERNEL_SRC_DIR
| Use the DT-mode snippet in references/build-modes.md
verbatim — srctree vs objtree must not collapse. |
'-mlittle-endian' unrecognized
during | R36.x Branch-A collision — dGPU/OpenRM Makefile in place of Tegra orchestrator | The Common-setup safety net normally repairs it; if not, git checkout HEAD -- Makefile
then re-run step 3a. |
run kernel (or full) first
on manual invocation | Kernel source tree never prepared | Run /jetson-build-source kernel
(or ) once, then . |
| and dirty edits exist | Edits uncommitted in a sub-repo but watermark already matches HEAD | Commit the edits, or re-run with an explicit mode argument ( etc.). |
| Composite silently missing from the output set | Per-dir Makefile insertion landed after merge-back line | See references/composite-registration.md
— insert after the last literal-named entry. |
| Promote step copies stale baseline artifacts | Trace-to-dirty filter skipped after a manual into | Only edit via a customize-* skill or ; the dirty detector keys on git HEAD, not file mtime. |
host package missing: <pkg>
| // refuse; others warn. | per references/upstream-recipe.md
. |
See also
references/build-modes.md
— per-mode snippets + install consolidation.
references/manifest-schema.md
— + schemas.
references/composite-registration.md
— the "Register composite custom overlay" step full snippets + rationale.
references/long-tail-gotchas.md
— invariants, deploy patterns, performance hints.
references/upstream-recipe.md
— verbatim NVIDIA recipe, divergences, spec status.
../../context/bsp-customization-workflow.md
— workspace edit protocol.
../../references/bsp-customization-kernel-dtb.md
— composite custom-overlay contract.
../../references/bsp-customization-bpmp-dtb.md
— BPMP-DTB edit contract (routed around this skill).
../jetson-init-source/SKILL.md
— Setup; authors .
../jetson-promote-image/SKILL.md
— Deploy promoter; reads this skill's manifest.