scripts/ubinize-image.sh: add support for adding custom partitions

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau 2016-07-31 18:34:02 +02:00
parent f29774bee3
commit a84a74f618
3 changed files with 29 additions and 2 deletions

View file

@ -114,6 +114,7 @@ define Build/append-ubi
sh $(TOPDIR)/scripts/ubinize-image.sh \ sh $(TOPDIR)/scripts/ubinize-image.sh \
$(if $(UBOOTENV_IN_UBI),--uboot-env) \ $(if $(UBOOTENV_IN_UBI),--uboot-env) \
$(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \ $(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \
$(foreach part,$(UBINIZE_PARTS),--part $(part)) \
$(IMAGE_ROOTFS) \ $(IMAGE_ROOTFS) \
$@.tmp \ $@.tmp \
-p $(BLOCKSIZE) -m $(PAGESIZE) \ -p $(BLOCKSIZE) -m $(PAGESIZE) \

View file

@ -347,6 +347,7 @@ define Device/Init
SUBPAGESIZE := SUBPAGESIZE :=
VID_HDR_OFFSET := VID_HDR_OFFSET :=
UBINIZE_OPTS := -E 5 UBINIZE_OPTS := -E 5
UBINIZE_PARTS :=
MKUBIFS_OPTS := MKUBIFS_OPTS :=
FS_OPTIONS/ubifs = $$(MKUBIFS_OPTS) FS_OPTIONS/ubifs = $$(MKUBIFS_OPTS)
@ -365,7 +366,7 @@ DEFAULT_DEVICE_VARS := \
DEVICE_DTS DEVICE_DTS_DIR BOARD_NAME CMDLINE \ DEVICE_DTS DEVICE_DTS_DIR BOARD_NAME CMDLINE \
UBOOTENV_IN_UBI KERNEL_IN_UBI \ UBOOTENV_IN_UBI KERNEL_IN_UBI \
BLOCKSIZE PAGESIZE SUBPAGESIZE VID_HDR_OFFSET \ BLOCKSIZE PAGESIZE SUBPAGESIZE VID_HDR_OFFSET \
UBINIZE_OPTS UIMAGE_NAME UBINIZE_OPTS UIMAGE_NAME UBINIZE_PARTS
define Device/ExportVar define Device/ExportVar
$(1) : $(2):=$$($(2)) $(1) : $(2):=$$($(2))

View file

@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh
part=""
ubootenv="" ubootenv=""
ubinize_param="" ubinize_param=""
kernel="" kernel=""
@ -22,6 +23,7 @@ ubivol() {
name=$2 name=$2
image=$3 image=$3
autoresize=$4 autoresize=$4
size="$5"
echo "[$name]" echo "[$name]"
echo "mode=ubi" echo "mode=ubi"
echo "vol_id=$volid" echo "vol_id=$volid"
@ -29,6 +31,7 @@ ubivol() {
echo "vol_name=$name" echo "vol_name=$name"
if [ "$image" ]; then if [ "$image" ]; then
echo "image=$image" echo "image=$image"
[ -n "$size" ] && echo "vol_size=${size}MiB"
else else
echo "vol_size=1MiB" echo "vol_size=1MiB"
fi fi
@ -46,6 +49,22 @@ ubilayout() {
ubivol $vol_id ubootenv2 ubivol $vol_id ubootenv2
vol_id=$(( $vol_id + 1 )) vol_id=$(( $vol_id + 1 ))
fi 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 if [ "$3" ]; then
ubivol $vol_id kernel "$3" ubivol $vol_id kernel "$3"
vol_id=$(( $vol_id + 1 )) vol_id=$(( $vol_id + 1 ))
@ -68,6 +87,12 @@ while [ "$1" ]; do
shift shift
continue continue
;; ;;
"--part")
parts="$parts $2"
shift
shift
continue
;;
"-"*) "-"*)
ubinize_param="$@" ubinize_param="$@"
break break
@ -88,7 +113,7 @@ while [ "$1" ]; do
done done
if [ ! -r "$rootfs" -o ! -r "$kernel" -a ! "$outfile" ]; then 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 exit 1
fi fi