Skip to content

Commit 13e1e2d

Browse files
build-dtb-image: recurse into vendor subdirs when copying DTBs
The FIT image build path used a flat glob to collect DTBs from the resolved source directory: cp -rap "${DTB_SRC}"/*.dtb* "${DTB_STAGE}/" This assumes all DTB files reside directly in DTB_SRC. In practice, DTBs are always installed one level deeper under a vendor subdirectory: lib/firmware/<KVER>/device-tree/qcom/*.dtb When --kernel-deb is used, DTB_SRC resolves to the device-tree directory (a symlink to usr/lib/linux-image-<KVER>/). The glob expands to nothing because the DTBs are in qcom/, not at the top level, causing the build to fail: cp: cannot stat '.../device-tree/*.dtb*': No such file or directory Replace the flat glob with find -L, which follows symlinks and recurses into all vendor subdirectories, copying every *.dtb and *.dtbo file flat into the mkimage staging directory (arch/arm64/boot/dts/qcom/) as the ITS file expects. Also add a post-copy count check and a sorted DTB listing so that an empty or misconfigured DTB source is caught early with a clear diagnostic rather than a cryptic mkimage FATAL ERROR. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
1 parent bf271c7 commit 13e1e2d

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

kernel/scripts/build-dtb-image.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,27 @@ else
503503
DTB_STAGE="${FIT_STAGE}/arch/arm64/boot/dts/qcom"
504504
mkdir -p "${DTB_STAGE}"
505505

506-
# Copy DTBs from the resolved DTB source directory
506+
# Copy DTBs from the resolved DTB source directory.
507+
# DTBs may be nested under vendor subdirectories (e.g. qcom/), so use
508+
# find -L (follow symlinks) rather than a flat glob to collect them all
509+
# into the staging dir flat — the ITS file references them by basename
510+
# under arch/arm64/boot/dts/qcom/.
507511
echo "[INFO] Copying DTBs from ${DTB_SRC} ..."
508-
cp -rap "${DTB_SRC}"/*.dtb* "${DTB_STAGE}/"
512+
dtb_count=0
513+
while IFS= read -r dtb; do
514+
cp -p "${dtb}" "${DTB_STAGE}/"
515+
(( dtb_count++ )) || true
516+
done < <(find -L "${DTB_SRC}" \( -name '*.dtb' -o -name '*.dtbo' \) -type f)
517+
518+
if (( dtb_count == 0 )); then
519+
echo "[ERROR] No DTB files found under ${DTB_SRC}" >&2
520+
echo " Verify the kernel package was built with DTB support" >&2
521+
echo " and that lib/firmware/*/device-tree resolves correctly." >&2
522+
exit 1
523+
fi
524+
echo "[INFO] Staged ${dtb_count} DTB file(s) to ${DTB_STAGE}"
525+
echo "[INFO] Staged DTBs:"
526+
ls "${DTB_STAGE}"/*.dtb 2>/dev/null | xargs -n1 basename | sort | sed 's/^/ /'
509527

510528
# -----------------------------------------------------------------------
511529
# Step 4. Compile qcom-metadata.dts → qcom-metadata.dtb

0 commit comments

Comments
 (0)