Add build-dtb-image.sh for combined DTB FAT image generation #82
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Introduce
build-dtb-image.sh, a standalone tool to generate aFAT-formatted image containing a single combined DTB for Qualcomm-based
ARM64 platforms. The tool consumes a manifest of DTBs, validates and
concatenates them into a single
combined-dtb.dtb, and packages thatartifact into a minimal FAT image suitable for boot flows and CI
pipelines.
Details
Inputs and manifest handling
The script is driven by two required inputs:
-dtb-src: DTB source directory (e.g.arch/arm64/boot/dts/qcom)-manifest: manifest file listing DTB filenames (one per line)Key behaviors:
.dtbfiles, or-dtb-src.#are ignored.mktemp-generated file.concatenation.
Validation performed:
(non-empty, non-comment).
-sizeargument, if provided, must be a positive integer (MB).Combined DTB generation
After sanitization and validation, the script:
<DTB_SRC>/combined-dtb.dtbxargs -ato preserve ordering and avoid unnecessary subshells.This keeps a deterministic combined DTB artifact in the DTB source tree
while providing a single binary blob for downstream consumers.
FAT image creation and layout
The tool then creates a FAT filesystem image and deploys the combined
DTB:
-size(MB).ddto create a zeroed image file of the requested size.losetup --show -fP.mkfs.vfat.mktemp-generated mount directory.combined-dtb.dtbinto the root of the FAT filesystem.Resulting layout inside the FAT image:
/combined-dtb.dtbonly (no additional files or directories).This keeps the on-image structure minimal and unambiguous for boot
firmware or test infrastructure.
Robust cleanup and error handling
To avoid leaking loop devices or mountpoints and to make the tool safe
for CI and repeated local use, the script:
EXITtrap at startup.cleanup()routine that:syncbest-effort before teardown.currently mounted (
mountpoint -q).if present.
With
set -euo pipefailand these guards in place, the script:stale mountpoints) even on error paths.
Usage
Basic example: