[PATCH 5/6] image: fit: add boot script blob
Tomasz Maciej Nowak
tmn505 at terefe.re
Wed Jun 10 15:40:10 PDT 2026
From: Tomasz Maciej Nowak <tmn505 at gmail.com>
Some boards might need a complex set of commands in U-Boot to properly
initialize. This can greatly complicate OpenWrt installation process.
Extend fit command to allow packing U-Boot script, which can run all
complex commands, leaving user only with loading the script from fit
image and executing it.
Signed-off-by: Tomasz Maciej Nowak <tmn505 at gmail.com>
---
include/image-commands.mk | 1 +
include/image.mk | 3 ++-
scripts/mkits.sh | 24 +++++++++++++++++++++++-
target/linux/mvebu/image/Makefile | 2 +-
target/linux/qualcommax/image/ipq50xx.mk | 1 -
target/linux/rockchip/image/Makefile | 1 -
target/linux/tegra/image/Makefile | 2 +-
7 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/include/image-commands.mk b/include/image-commands.mk
index b1c99efe4cb1..f99ba5c5eb4f 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -448,6 +448,7 @@ define Build/fit-its
$(if $(DEVICE_DTS_DELIMITER),-l $(DEVICE_DTS_DELIMITER)) \
$(if $(DEVICE_DTS_LOADADDR),-s $(DEVICE_DTS_LOADADDR)) \
$(if $(DEVICE_DTS_OVERLAY),$(foreach dtso,$(DEVICE_DTS_OVERLAY), -O $(dtso):$(KERNEL_BUILD_DIR)/image-$(dtso).dtbo)) \
+ $(if $(BOOT_SCRIPT),-b $(PLATFORM_DIR)/image/$(BOOT_SCRIPT)) \
-c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \
-A $(LINUX_KARCH) -v $(LINUX_VERSION)
endef
diff --git a/include/image.mk b/include/image.mk
index 3f5268efaccb..5dd037a99006 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -554,6 +554,7 @@ define Device/Init
FILESYSTEMS := $(TARGET_FILESYSTEMS)
UBOOT_PATH := $(STAGING_DIR_IMAGE)/uboot-$(1)
+ BOOT_SCRIPT :=
BROKEN :=
DEFAULT :=
@@ -567,7 +568,7 @@ DEFAULT_DEVICE_VARS := \
DEVICE_DTS_DIR DEVICE_DTS_OVERLAY DEVICE_DTS_LOADADDR \
DEVICE_FDT_NUM DEVICE_IMG_PREFIX SOC BOARD_NAME UIMAGE_MAGIC UIMAGE_NAME \
UIMAGE_TIME SUPPORTED_DEVICES IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR \
- UBOOT_PATH IMAGE_SIZE NAND_SIZE \
+ UBOOT_PATH BOOT_SCRIPT IMAGE_SIZE NAND_SIZE \
FACTORY_IMG_NAME FACTORY_SIZE \
DEVICE_PACKAGES DEVICE_COMPAT_VERSION DEVICE_COMPAT_MESSAGE \
DEVICE_VENDOR DEVICE_MODEL DEVICE_VARIANT \
diff --git a/scripts/mkits.sh b/scripts/mkits.sh
index 94592b932fce..fb9d957820c2 100755
--- a/scripts/mkits.sh
+++ b/scripts/mkits.sh
@@ -31,6 +31,7 @@ usage() {
printf "\n\t-n ==> fdt unit-address 'address'"
printf "\n\t-d ==> include Device Tree Blob 'name:dtb'"
printf "\n\t-r ==> include RootFS blob 'rootfs'"
+ printf "\n\t-b ==> include U-Boot script 'script'"
printf "\n\t-H ==> specify hash algo instead of SHA1"
printf "\n\t-l ==> legacy mode character (@ etc otherwise -)"
printf "\n\t-o ==> create output file 'its_file'"
@@ -50,11 +51,12 @@ DTOVERLAY=
DTADDR=
DTB=
-while getopts ":A:a:c:C:D:d:e:f:i:k:l:n:o:O:v:r:s:H:" OPTION
+while getopts ":A:a:b:c:C:D:d:e:f:i:k:l:n:o:O:v:r:s:H:" OPTION
do
case $OPTION in
A ) ARCH=$OPTARG;;
a ) LOAD_ADDR=$OPTARG;;
+ b ) BOOTSCRIPT=$OPTARG;;
c ) CONFIG=$OPTARG;;
C ) COMPRESS=$OPTARG;;
D ) DEVICE=$OPTARG;;
@@ -225,6 +227,25 @@ if [ -n "${ROOTFS}" ]; then
LOADABLES="${LOADABLES:+$LOADABLES, }\"rootfs${REFERENCE_CHAR}${ROOTFSNUM}\""
fi
+if [ -n "${BOOTSCRIPT}" ]; then
+ BOOTSCRIPT_NODE="
+ bootscript {
+ description = \"${ARCH_UPPER} OpenWrt ${DEVICE} boot script\";
+ ${COMPATIBLE_PROP}
+ data = /incbin/(\"${BOOTSCRIPT}\");
+ type = \"script\";
+ arch = \"${ARCH}\";
+ compression = \"none\";
+ hash${REFERENCE_CHAR}1 {
+ algo = \"crc32\";
+ };
+ hash${REFERENCE_CHAR}2 {
+ algo = \"${HASH}\";
+ };
+ };
+"
+fi
+
# Create a default, fully populated DTS file
DATA="/dts-v1/;
@@ -253,6 +274,7 @@ ${INITRD_NODE}
${FDT_NODE}
${FDTOVERLAY_NODE}
${ROOTFS_NODE}
+${BOOTSCRIPT_NODE}
};
configurations {
diff --git a/target/linux/mvebu/image/Makefile b/target/linux/mvebu/image/Makefile
index 89bfa515259b..1a25d07a67cb 100644
--- a/target/linux/mvebu/image/Makefile
+++ b/target/linux/mvebu/image/Makefile
@@ -8,7 +8,7 @@ JFFS2_BLOCKSIZE = 128k
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
-DEVICE_VARS += BOOT_SCRIPT UBOOT
+DEVICE_VARS += UBOOT
KERNEL_LOADADDR := 0x00008000
define Build/boot-scr
diff --git a/target/linux/qualcommax/image/ipq50xx.mk b/target/linux/qualcommax/image/ipq50xx.mk
index c62bb985c7a1..536d00db51f6 100644
--- a/target/linux/qualcommax/image/ipq50xx.mk
+++ b/target/linux/qualcommax/image/ipq50xx.mk
@@ -1,5 +1,4 @@
DTS_DIR := $(DTS_DIR)/qcom
-DEVICE_VARS += BOOT_SCRIPT
define Build/mstc-header
$(eval version=$(word 1,$(1)))
diff --git a/target/linux/rockchip/image/Makefile b/target/linux/rockchip/image/Makefile
index 236d984551ed..1cc787070e60 100644
--- a/target/linux/rockchip/image/Makefile
+++ b/target/linux/rockchip/image/Makefile
@@ -48,7 +48,6 @@ define Device/Default
PROFILES := Default
KERNEL = kernel-bin | lzma | fit lzma
KERNEL_LOADADDR :=
- BOOT_SCRIPT :=
IMAGES := sysupgrade.img.gz
IMAGE/sysupgrade.img.gz = boot-common | boot-script $$(BOOT_SCRIPT) | pine64-img | gzip | append-metadata
DEVICE_DTS_DIR = $$(DTS_DIR)/rockchip
diff --git a/target/linux/tegra/image/Makefile b/target/linux/tegra/image/Makefile
index 96b095e64929..3d6ca9c35b1f 100644
--- a/target/linux/tegra/image/Makefile
+++ b/target/linux/tegra/image/Makefile
@@ -28,7 +28,7 @@ define Build/tegra-sdcard
$(if $(UBOOT),dd if=$(STAGING_DIR_IMAGE)/$(UBOOT).img of=$@ bs=512 skip=1 seek=1 conv=notrunc)
endef
-DEVICE_VARS += BOOT_SCRIPT UBOOT
+DEVICE_VARS += UBOOT
define Device/Default
BOOT_SCRIPT := generic-bootscript
--
2.54.0
More information about the openwrt-devel
mailing list