Skip to content

Commit 49dc769

Browse files
build-dtb-image: probe usr/lib/firmware/ first for usrmerge .deb layout
pkg-linux-qcom now installs the device-tree compat symlink under usr/lib/firmware/<KVER>/device-tree (usrmerge layout). Update the --kernel-deb DTB discovery to check usr/lib/firmware/ first and fall back to lib/firmware/ for legacy packages, so both layouts are handled transparently. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
1 parent fa090c8 commit 49dc769

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

kernel/scripts/build-dtb-image.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
# - Provide a Debian kernel package (.deb) as input.
2020
# - The script extracts the .deb via `dpkg-deb -R` into a temp directory.
2121
# - DTBs are expected to be present under:
22-
# $DEB_DIR/lib/firmware/$BASE_KERNEL_VERSION/device-tree
22+
# $DEB_DIR/usr/lib/firmware/$BASE_KERNEL_VERSION/device-tree (usrmerge layout)
23+
# $DEB_DIR/lib/firmware/$BASE_KERNEL_VERSION/device-tree (legacy layout)
2324
# where $BASE_KERNEL_VERSION can be anything.
24-
# - The script assumes there is exactly ONE:
25-
# $DEB_DIR/lib/firmware/*/device-tree
25+
# - The script assumes there is exactly ONE device-tree directory across
26+
# both search paths.
2627
#
2728
# (B) DTB source directory mode (dev/kernel-tree mode)
2829
# - Provide the DTB source directory directly (e.g. a kernel build tree):
@@ -171,7 +172,9 @@ usage() {
171172
Usage: $0 (--kernel-deb <kernel.deb> | --dtb-src <path>) --manifest <file> [--size <MB>] [--out <file>]
172173
173174
--kernel-deb, -kernel-deb Path to Debian kernel package (.deb). DTBs read from:
174-
<extract>/lib/firmware/*/device-tree (must be exactly one)
175+
<extract>/usr/lib/firmware/*/device-tree (usrmerge layout)
176+
<extract>/lib/firmware/*/device-tree (legacy layout)
177+
Exactly one device-tree directory must be found.
175178
176179
--dtb-src, -dtb-src Path to DTB source directory
177180
(e.g. arch/arm64/boot/dts/qcom)
@@ -361,13 +364,21 @@ if [[ -n "${KERNEL_DEB}" ]]; then
361364
echo "[INFO] Extracting kernel .deb to: ${DEB_DIR}"
362365
dpkg-deb -R "${KERNEL_DEB}" "${DEB_DIR}"
363366

364-
# Locate exactly one device-tree directory under lib/firmware/*/device-tree
367+
# Locate exactly one device-tree directory.
368+
# Modern packages (usrmerge / pkg-linux-qcom) install the compat symlink under
369+
# usr/lib/firmware/<KVER>/device-tree; legacy packages used lib/firmware/.
370+
# Check usr/lib/firmware/ first; fall back to lib/firmware/.
365371
shopt -s nullglob
366-
dt_dirs=( "${DEB_DIR}/lib/firmware"/*/device-tree )
372+
dt_dirs=( "${DEB_DIR}/usr/lib/firmware"/*/device-tree )
373+
if (( ${#dt_dirs[@]} == 0 )); then
374+
dt_dirs=( "${DEB_DIR}/lib/firmware"/*/device-tree )
375+
fi
367376
shopt -u nullglob
368377

369378
if (( ${#dt_dirs[@]} == 0 )); then
370-
echo "[ERROR] No DTB directory found at '${DEB_DIR}/lib/firmware/*/device-tree'." >&2
379+
echo "[ERROR] No DTB directory found under:" >&2
380+
echo " '${DEB_DIR}/usr/lib/firmware/*/device-tree'" >&2
381+
echo " '${DEB_DIR}/lib/firmware/*/device-tree'" >&2
371382
exit 1
372383
fi
373384
if (( ${#dt_dirs[@]} > 1 )); then
@@ -519,7 +530,7 @@ else
519530
if (( dtb_count == 0 )); then
520531
echo "[ERROR] No DTB files found under ${DTB_SRC}" >&2
521532
echo " Verify the kernel package was built with DTB support" >&2
522-
echo " and that lib/firmware/*/device-tree resolves correctly." >&2
533+
echo " and that usr/lib/firmware/*/device-tree resolves correctly." >&2
523534
exit 1
524535
fi
525536
echo "[INFO] Staged ${dtb_count} DTB file(s) to ${DTB_STAGE}"

0 commit comments

Comments
 (0)