[OpenWrt-Devel] [PATCH] build: add helpers for generating QSDK sysupgrade compatible images
Piotr Dymacz
pepe2k at gmail.com
Tue Jan 29 18:35:49 EST 2019
Qualcomm SDK (QSDK) sysupgrade compatible images for IPQ40xx, IPQ806x
and IPQ807x use FIT format together with 'dumpimage' tool from U-Boot
for verifying and extracting them. Based on 'images' sections names,
corresponding mtd partitions are flashed. For example, in case of
NOR-only boards, below mapping is used (section name -> mtd name):
hlos* -> 0:HLOS
rootfs* -> rootfs
And for boards with NAND (kernel inside UBI):
ubi* -> rootfs
Above mappings come from unmodified QSDK sources and might be wrong for
boards running custom or modified QSDK-based firmware. Some of vendors
adjust them to meet their modified mtd layout or features like recovery
or dual-image support.
This adds simple script 'mkits-qsdk-ipq-image.sh' (based on 'mkits.sh')
for generating FIT images tree source files, compatible with the QSDK
sysupgrade format. Resulting images can be used for initial (factory ->
OpenWrt) installation and would work both in CLI and GUI.
The script is universal in a way it allows to include as many sections
as needed. To make use of it, two generic/basic build recipes for NOR
and NAND based boards are also included in 'image-commands.mk':
Build/qsdk-ipq-factory-nand
Build/qsdk-ipq-factory-nor
Example usage for board with UBI in NAND:
IMAGE/nand-factory.bin := append-ubi | qsdk-ipq-factory-nand
Signed-off-by: Piotr Dymacz <pepe2k at gmail.com>
---
include/image-commands.mk | 14 ++++++++
scripts/mkits-qsdk-ipq-image.sh | 59 +++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+)
create mode 100755 scripts/mkits-qsdk-ipq-image.sh
diff --git a/include/image-commands.mk b/include/image-commands.mk
index 56bad539b3..47d7193434 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -294,6 +294,20 @@ define Build/openmesh-image
"$(call param_get_default,rootfs,$(1),$@)" "rootfs"
endef
+define Build/qsdk-ipq-factory-nand
+ $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
+ $@.its ubi $@
+ mkimage -f $@.its $@.new
+ @mv $@.new $@
+endef
+
+define Build/qsdk-ipq-factory-nor
+ $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
+ $@.its hlos $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS)
+ mkimage -f $@.its $@.new
+ @mv $@.new $@
+endef
+
define Build/senao-header
$(STAGING_DIR_HOST)/bin/mksenaofw $(1) -e $@ -o $@.new
mv $@.new $@
diff --git a/scripts/mkits-qsdk-ipq-image.sh b/scripts/mkits-qsdk-ipq-image.sh
new file mode 100755
index 0000000000..066e8df579
--- /dev/null
+++ b/scripts/mkits-qsdk-ipq-image.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+#
+# Licensed under the terms of the GNU GPL License version 2 or later.
+# Author: Piotr Dymacz <pepe2k at gmail.com>, based on mkits.sh.
+#
+# Qualcomm SDK (QSDK) sysupgrade compatible images for IPQ40xx, IPQ806x
+# and IPQ807x use FIT format together with 'dumpimage' tool from U-Boot
+# for verifying and extracting them. Based on 'images' sections names,
+# corresponding mtd partitions are flashed.
+# This is a simple script for generating FIT images tree source files,
+# compatible with the QSDK sysupgrade format. Resulting images can be
+# used for initial (factory -> OpenWrt) installation and would work
+# both in CLI and GUI. The script is also universal in a way it allows
+# to include as many sections as needed.
+#
+
+usage() {
+ echo "Usage: `basename $0` output img0_name img0_file [[img1_name img1_file] ...]"
+ exit 1
+}
+
+# We need at least 3 arguments
+[ "$#" -lt 3 ] && usage
+
+# Target output file
+OUTPUT="$1"; shift
+
+# Create a default, fully populated DTS file
+echo "\
+/dts-v1/;
+
+/ {
+ description = \"OpenWrt factory image\";
+ #address-cells = <1>;
+
+ images {" > ${OUTPUT}
+
+while [ -n "$1" -a -n "$2" ]; do
+ [ -f "$2" ] || usage
+
+ name="$1"; shift
+ file="$1"; shift
+
+ echo \
+" ${name} {
+ description = \"${name}\";
+ data = /incbin/(\"${file}\");
+ type = \"Firmware\";
+ arch = \"ARM\";
+ compression = \"none\";
+ hash at 1 {
+ algo = \"crc32\";
+ };
+ };" >> ${OUTPUT}
+done
+
+echo \
+" };
+};" >> ${OUTPUT}
--
2.20.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list