scripts/ubinize-image.sh: add support for adding custom partitions
authorFelix Fietkau <nbd@nbd.name>
Sun, 31 Jul 2016 16:34:02 +0000 (18:34 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 31 Aug 2016 11:05:19 +0000 (13:05 +0200)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
include/image-commands.mk
include/image.mk
scripts/ubinize-image.sh

index 00cb3410e95631a7808b8a624d0ee32f0445907c..40a9619c31c4d3015d9d001b140081d27f5aea24 100644 (file)
@@ -114,6 +114,7 @@ define Build/append-ubi
        sh $(TOPDIR)/scripts/ubinize-image.sh \
                $(if $(UBOOTENV_IN_UBI),--uboot-env) \
                $(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \
+               $(foreach part,$(UBINIZE_PARTS),--part $(part)) \
                $(IMAGE_ROOTFS) \
                $@.tmp \
                -p $(BLOCKSIZE) -m $(PAGESIZE) \
index c85a9d6505fae02d6713b79d24cc55b36fda8741..7079f187867c44d6916cdb8a5267525a14bc21f4 100644 (file)
@@ -347,6 +347,7 @@ define Device/Init
   SUBPAGESIZE :=
   VID_HDR_OFFSET :=
   UBINIZE_OPTS := -E 5
+  UBINIZE_PARTS :=
   MKUBIFS_OPTS :=
 
   FS_OPTIONS/ubifs = $$(MKUBIFS_OPTS)
@@ -365,7 +366,7 @@ DEFAULT_DEVICE_VARS := \
   DEVICE_DTS DEVICE_DTS_DIR BOARD_NAME CMDLINE \
   UBOOTENV_IN_UBI KERNEL_IN_UBI \
   BLOCKSIZE PAGESIZE SUBPAGESIZE VID_HDR_OFFSET \
-  UBINIZE_OPTS UIMAGE_NAME
+  UBINIZE_OPTS UIMAGE_NAME UBINIZE_PARTS
 
 define Device/ExportVar
   $(1) : $(2):=$$($(2))
index b87cbb48dc8cc004d754e3b9c8001beb5f111393..09a00b1898cec141bf99a776eb26697d29fec864 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+part=""
 ubootenv=""
 ubinize_param=""
 kernel=""
@@ -22,6 +23,7 @@ ubivol() {
        name=$2
        image=$3
        autoresize=$4
+       size="$5"
        echo "[$name]"
        echo "mode=ubi"
        echo "vol_id=$volid"
@@ -29,6 +31,7 @@ ubivol() {
        echo "vol_name=$name"
        if [ "$image" ]; then
                echo "image=$image"
+               [ -n "$size" ] && echo "vol_size=${size}MiB"
        else
                echo "vol_size=1MiB"
        fi
@@ -46,6 +49,22 @@ ubilayout() {
                ubivol $vol_id ubootenv2
                vol_id=$(( $vol_id + 1 ))
        fi
+       for part in $parts; do
+               name="${part%%=*}"
+               prev="$part"
+               part="${part#*=}"
+               [ "$prev" = "$part" ] && part=
+
+               image="${part%%=*}"
+               prev="$part"
+               part="${part#*=}"
+               [ "$prev" = "$part" ] && part=
+
+               size="$part"
+
+               ubivol $vol_id "$name" "$image" "" "$size"
+               vol_id=$(( $vol_id + 1 ))
+       done
        if [ "$3" ]; then
                ubivol $vol_id kernel "$3"
                vol_id=$(( $vol_id + 1 ))
@@ -68,6 +87,12 @@ while [ "$1" ]; do
                shift
                continue
                ;;
+       "--part")
+               parts="$parts $2"
+               shift
+               shift
+               continue
+               ;;
        "-"*)
                ubinize_param="$@"
                break
@@ -88,7 +113,7 @@ while [ "$1" ]; do
 done
 
 if [ ! -r "$rootfs" -o ! -r "$kernel" -a ! "$outfile" ]; then
-       echo "syntax: $0 [--uboot-env] [--kernel kernelimage] rootfs out [ubinize opts]"
+       echo "syntax: $0 [--uboot-env] [--part <name>=<file>] [--kernel kernelimage] rootfs out [ubinize opts]"
        exit 1
 fi