Skip to content

Commit dd9d3f1

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 c325ff3 commit dd9d3f1

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):
@@ -170,7 +171,9 @@ usage() {
170171
Usage: $0 (--kernel-deb <kernel.deb> | --dtb-src <path>) --manifest <file> [--size <MB>] [--out <file>]
171172
172173
--kernel-deb, -kernel-deb Path to Debian kernel package (.deb). DTBs read from:
173-
<extract>/lib/firmware/*/device-tree (must be exactly one)
174+
<extract>/usr/lib/firmware/*/device-tree (usrmerge layout)
175+
<extract>/lib/firmware/*/device-tree (legacy layout)
176+
Exactly one device-tree directory must be found.
174177
175178
--dtb-src, -dtb-src Path to DTB source directory
176179
(e.g. arch/arm64/boot/dts/qcom)
@@ -360,13 +363,21 @@ if [[ -n "${KERNEL_DEB}" ]]; then
360363
echo "[INFO] Extracting kernel .deb to: ${DEB_DIR}"
361364
dpkg-deb -R "${KERNEL_DEB}" "${DEB_DIR}"
362365

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

368377
if (( ${#dt_dirs[@]} == 0 )); then
369-
echo "[ERROR] No DTB directory found at '${DEB_DIR}/lib/firmware/*/device-tree'." >&2
378+
echo "[ERROR] No DTB directory found under:" >&2
379+
echo " '${DEB_DIR}/usr/lib/firmware/*/device-tree'" >&2
380+
echo " '${DEB_DIR}/lib/firmware/*/device-tree'" >&2
370381
exit 1
371382
fi
372383
if (( ${#dt_dirs[@]} > 1 )); then
@@ -518,7 +529,7 @@ else
518529
if (( dtb_count == 0 )); then
519530
echo "[ERROR] No DTB files found under ${DTB_SRC}" >&2
520531
echo " Verify the kernel package was built with DTB support" >&2
521-
echo " and that lib/firmware/*/device-tree resolves correctly." >&2
532+
echo " and that usr/lib/firmware/*/device-tree resolves correctly." >&2
522533
exit 1
523534
fi
524535
echo "[INFO] Staged ${dtb_count} DTB file(s) to ${DTB_STAGE}"

0 commit comments

Comments
 (0)