[OpenWrt-Devel] [PATCH RFC 09/10] image: add a build recipe to wrap an ubi image in a itb file
Jonas Gorski
jogo at openwrt.org
Fri Aug 21 07:17:38 EDT 2015
Signed-off-by: Jonas Gorski <jogo at openwrt.org>
---
include/image.mk | 7 +++++
scripts/mkits-ubi.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+)
create mode 100755 scripts/mkits-ubi.sh
diff --git a/include/image.mk b/include/image.mk
index 8ac3593..261cbb2 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -318,6 +318,13 @@ define Build/fit
@mv $@.new $@
endef
+define Build/ubi-fit
+ $(TOPDIR)/scripts/mkits-ubi.sh \
+ -D $(DEVICE_NAME) -o $@.its -u $@ -A $(ARCH)
+ PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
+ @mv $@.new $@
+endef
+
define Build/lzma
$(STAGING_DIR_HOST)/bin/lzma e $@ -lc1 -lp2 -pb2 $(1) $@.new
@mv $@.new $@
diff --git a/scripts/mkits-ubi.sh b/scripts/mkits-ubi.sh
new file mode 100755
index 0000000..e84a3fa
--- /dev/null
+++ b/scripts/mkits-ubi.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+#
+# Licensed under the terms of the GNU GPL License version 2 or later.
+#
+# Author: Peter Tyser <ptyser at xes-inc.com>
+#
+# U-Boot firmware supports the booting of images in the Flattened Image
+# Tree (FIT) format. The FIT format uses a device tree structure to
+# describe a kernel image, device tree blob, ramdisk, etc. This script
+# creates an Image Tree Source (.its file) which can be passed to the
+# 'mkimage' utility to generate an Image Tree Blob (.itb file). The .itb
+# file can then be booted by U-Boot (or other bootloaders which support
+# FIT images). See doc/uImage.FIT/howto.txt in U-Boot source code for
+# additional information on FIT images.
+#
+
+usage() {
+ echo "Usage: `basename $0` -A arch -D name -u ubi -o its_file"
+ echo -e "\t-A ==> set architecture to 'arch'"
+ echo -e "\t-u ==> include ubi image 'kernel'"
+ echo -e "\t-D ==> human friendly UBI 'name'"
+ echo -e "\t-o ==> create output file 'its_file'"
+ exit 1
+}
+
+while getopts ":A:D:o:u:v:" OPTION
+do
+ case $OPTION in
+ A ) ARCH=$OPTARG;;
+ D ) DEVICE=$OPTARG;;
+ u ) UBI=$OPTARG;;
+ o ) OUTPUT=$OPTARG;;
+ * ) echo "Invalid option passed to '$0' (options:$@)"
+ usage;;
+ esac
+done
+
+# Make sure user entered all required parameters
+if [ -z "${ARCH}" ] || [ -z "${UBI}" ] || [ -z "${OUTPUT}" ]; then
+ usage
+fi
+
+ARCH_UPPER=`echo $ARCH | tr '[:lower:]' '[:upper:]'`
+
+# Create a default, fully populated DTS file
+DATA="/dts-v1/;
+
+/ {
+ description = \"${ARCH_UPPER} OpenWrt FIT (Flattened Image Tree)\";
+ #address-cells = <1>;
+
+ images {
+ ubi at 1 {
+ description = \"${ARCH_UPPER} OpenWrt ${DEVICE} ubi rootfs\";
+ data = /incbin/(\"${UBI}\");
+ type = \"firmware\";
+ arch = \"${ARCH}\";
+ compression = \"none\";
+ hash at 1 {
+ algo = \"crc32\";
+ };
+ hash at 2 {
+ algo = \"sha1\";
+ };
+ };
+
+ };
+
+ configurations {
+ default = \"config at 1\";
+ config at 1 {
+ description = \"OpenWrt\";
+ ubi = \"ubi at 1\";
+ };
+ };
+};"
+
+# Write .its file to disk
+echo "$DATA" > ${OUTPUT}
--
2.1.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list