Commit 34e80dc
committed
scripts: add build-dtb-image.sh — self-contained FIT DTB image builder
Introduce build-dtb-image.sh, a production-ready tool for generating
FAT-formatted FIT DTB images for Qualcomm ARM64 platforms.
The script is co-located with the metadata it consumes (qcom-metadata.dts,
qcom-next-fitimage.its), eliminating the need to clone this repository
at build time. The metadata directory is resolved at runtime via
BASH_SOURCE[0], so the script works correctly regardless of the caller's
working directory or CI environment.
FIT image mode is the default and only operating mode. The --fit-image
flag is accepted for backward compatibility with existing callers but is
a no-op.
Two DTB source sub-modes are supported:
--kernel-deb Extract DTBs from a Debian kernel package (.deb).
Probes paths in order:
1. usr/lib/linux-image-*/ (Debian standard)
2. usr/lib/firmware/*/device-tree (Ubuntu, usrmerge)
3. lib/firmware/*/device-tree (Ubuntu, legacy)
This probe order ensures correct operation on both Debian
and Ubuntu regardless of usrmerge layout, and is fully
backward compatible with legacy build-kernel-deb.sh packages.
--dtb-src Read DTBs directly from a kernel build tree directory.
Build pipeline (5 steps):
1. Assemble a temporary staging tree with ITS, compiled metadata DTB,
and all per-platform DTBs laid out as the ITS /incbin/ paths expect.
2. Compile qcom-metadata.dts → qcom-metadata.dtb via dtc.
3. Copy qcom-next-fitimage.its into the staging directory.
4. Invoke mkimage from the staging directory to produce qclinux_fit.img
(-E -B 8). The output filename is hardcoded in UEFI firmware and
must not be changed.
5. Pack qclinux_fit.img into a FAT image (default: dtb.bin, 4 MB).
Hardening:
- Upfront validation that qcom-metadata.dts and the ITS file exist
before any build work begins.
- find -L replaces flat *.dtb* glob, correctly collecting DTBs nested
under vendor subdirectories (e.g. qcom/).
- Staged DTB count check with sorted listing for early diagnosis of
empty or misconfigured DTB sources.
- Cleanup trap covers all temporary resources (loop device, mount
point, .deb extraction dir, staging dir) on any exit path.
Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>1 parent a85260c commit 34e80dc
1 file changed
Lines changed: 435 additions & 0 deletions
0 commit comments