[PATCH v2 4/6] image: fit: allow multiple dtbs
Tomasz Maciej Nowak
tmn505 at terefe.re
Tue Jul 14 10:18:18 PDT 2026
From: Tomasz Maciej Nowak <tmn505 at gmail.com>
Some older U-Boot versions don't know about Device Tree overlays, which
could be used to accommodate for different variants of single board.
Extend fit command to pack multiple dtb to workaround that shortcoming.
Signed-off-by: Tomasz Maciej Nowak <tmn505 at gmail.com>
---
v1 -> v2
No changes.
include/image-commands.mk | 2 +-
scripts/mkits.sh | 51 +++++++++++++++++++++--------
target/linux/airoha/image/an7581.mk | 2 +-
3 files changed, 39 insertions(+), 16 deletions(-)
diff --git a/include/image-commands.mk b/include/image-commands.mk
index fb5ad8e51e0e..b1c99efe4cb1 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -438,7 +438,7 @@ define Build/fit-its
-D $(DEVICE_NAME) -o $@.its -k $@ \
-C $(word 1,$(1)) \
$(if $(DEVICE_DTS),\
- -d $(KERNEL_BUILD_DIR)/image-$$(basename $(firstword $(DEVICE_DTS)).dtb)) \
+ $(foreach dts, $(DEVICE_DTS), -d $(dts):$(KERNEL_BUILD_DIR)/image-$$(basename $(dts)).dtb)) \
$(if $(findstring with-rootfs,$(word 2,$(1))),-r $(IMAGE_ROOTFS)) \
$(if $(findstring with-initrd,$(word 2,$(1))), \
$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS_SEPARATE), \
diff --git a/scripts/mkits.sh b/scripts/mkits.sh
index 33ef3012c5c6..94592b932fce 100755
--- a/scripts/mkits.sh
+++ b/scripts/mkits.sh
@@ -29,7 +29,7 @@ usage() {
printf "\n\t-k ==> include kernel image 'kernel'"
printf "\n\t-D ==> human friendly Device Tree Blob 'name'"
printf "\n\t-n ==> fdt unit-address 'address'"
- printf "\n\t-d ==> include Device Tree Blob 'dtb'"
+ printf "\n\t-d ==> include Device Tree Blob 'name:dtb'"
printf "\n\t-r ==> include RootFS blob 'rootfs'"
printf "\n\t-H ==> specify hash algo instead of SHA1"
printf "\n\t-l ==> legacy mode character (@ etc otherwise -)"
@@ -48,6 +48,7 @@ HASH=sha1
LOADABLES=
DTOVERLAY=
DTADDR=
+DTB=
while getopts ":A:a:c:C:D:d:e:f:i:k:l:n:o:O:v:r:s:H:" OPTION
do
@@ -57,7 +58,7 @@ do
c ) CONFIG=$OPTARG;;
C ) COMPRESS=$OPTARG;;
D ) DEVICE=$OPTARG;;
- d ) DTB=$OPTARG;;
+ d ) DTB="$DTB ${OPTARG}";;
e ) ENTRY_ADDR=$OPTARG;;
f ) COMPATIBLE=$OPTARG;;
i ) INITRD=$OPTARG;;
@@ -117,13 +118,20 @@ if [ -n "${INITRD}" ]; then
INITRD_PROP="ramdisk=\"initrd${REFERENCE_CHAR}${INITRDNUM}\";"
fi
+DEFCONFIG="$CONFIG"
+FDT_NODE=""
+CONFIGS=""
# Conditionally create fdt information
if [ -n "${DTB}" ]; then
- FDT_NODE="
+ for dtb in $DTB; do
+ dtb_blob=${dtb##*:}
+ dtb_name=${dtb%%:*}
+ FDT_NODE="$FDT_NODE
+
fdt${REFERENCE_CHAR}$FDTNUM {
description = \"${ARCH_UPPER} OpenWrt ${DEVICE} device tree blob\";
${COMPATIBLE_PROP}
- data = /incbin/(\"${DTB}\");
+ data = /incbin/(\"${dtb_blob}\");
type = \"flat_dt\";
${DTADDR:+load = <${DTADDR}>;}
arch = \"${ARCH}\";
@@ -136,7 +144,29 @@ if [ -n "${DTB}" ]; then
};
};
"
- FDT_PROP="fdt = \"fdt${REFERENCE_CHAR}$FDTNUM\";"
+ CONFIGS="$CONFIGS
+ ${CONFIG:-$dtb_name} {
+ description = \"OpenWrt ${dtb_name}\";
+ kernel = \"kernel${REFERENCE_CHAR}1\";
+ fdt = \"fdt${REFERENCE_CHAR}$FDTNUM\";
+ ${LOADABLES:+loadables = ${LOADABLES};}
+ ${COMPATIBLE_PROP}
+ ${INITRD_PROP}
+ };
+"
+ FDTNUM=$((FDTNUM + 1))
+ CONFIG=""
+ done
+else
+ CONFIGS="
+ ${CONFIG} {
+ description = \"OpenWrt ${DEVICE}\";
+ kernel = \"kernel${REFERENCE_CHAR}1\";
+ ${LOADABLES:+loadables = ${LOADABLES};}
+ ${COMPATIBLE_PROP}
+ ${INITRD_PROP}
+ };
+"
fi
# add DT overlay blobs
@@ -226,15 +256,8 @@ ${ROOTFS_NODE}
};
configurations {
- default = \"${CONFIG}\";
- ${CONFIG} {
- description = \"OpenWrt ${DEVICE}\";
- kernel = \"kernel${REFERENCE_CHAR}1\";
- ${FDT_PROP}
- ${LOADABLES:+loadables = ${LOADABLES};}
- ${COMPATIBLE_PROP}
- ${INITRD_PROP}
- };
+ default = \"${DEFCONFIG}\";
+ ${CONFIGS}
${OVCONFIGS}
};
};"
diff --git a/target/linux/airoha/image/an7581.mk b/target/linux/airoha/image/an7581.mk
index 0af5d5e1f8c2..2e670f410f1c 100644
--- a/target/linux/airoha/image/an7581.mk
+++ b/target/linux/airoha/image/an7581.mk
@@ -29,7 +29,7 @@ define Build/an7581-chainloader
-a 0x80200000 -e 0x80200000 \
-c conf-uboot \
-A arm64 -v u-boot \
- -d $(STAGING_DIR_IMAGE)/an7581_$1-u-boot.dtb \
+ -d $(DEVICE_NAME):$(STAGING_DIR_IMAGE)/an7581_$1-u-boot.dtb \
-s 0x82000000
PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) \
$(STAGING_DIR_HOST)/bin/mkimage \
--
2.55.0
More information about the openwrt-devel
mailing list