mirror of
				git://git.openwrt.org/openwrt/openwrt.git
				synced 2025-11-04 06:54:27 -05:00 
			
		
		
		
	scripts: ubinize-image.sh: support static volumes, make size optional
In order to support devices having TF-A FIP image or UBI-aware U-Boot SPL we need to include a static volume for the bootloader. Introduce support for adding additional static volumes by prefixing the filename with ':', eg. UBINIZE_PARTS := fip:=$(STAGING_DIR_IMAGE)/u-boot.fip Also add support for rootfs-in-uImage.FIT setups which don't require a rootfs partition and make the (3rd) size parameter in UBINIZE_PARTS optional (see example above without declared size). Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
		
							parent
							
								
									ada3b2190a
								
							
						
					
					
						commit
						6c17d71973
					
				@ -138,9 +138,11 @@ UBI_NAND_SIZE_LIMIT = $(IMAGE_SIZE) - ($(NAND_SIZE)*20/1024 + 4*$(BLOCKSIZE))
 | 
			
		||||
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)) \
 | 
			
		||||
		--rootfs $(IMAGE_ROOTFS) \
 | 
			
		||||
		$(if $(findstring fit,$(1)), \
 | 
			
		||||
		$(if $(KERNEL_IN_UBI),--part fit=$(IMAGE_KERNEL)), \
 | 
			
		||||
		$(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \
 | 
			
		||||
		--rootfs $(IMAGE_ROOTFS)) \
 | 
			
		||||
		$@.tmp \
 | 
			
		||||
		-p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
 | 
			
		||||
		$(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
 | 
			
		||||
 | 
			
		||||
@ -12,15 +12,16 @@ err=""
 | 
			
		||||
ubinize_seq=""
 | 
			
		||||
 | 
			
		||||
ubivol() {
 | 
			
		||||
	volid=$1
 | 
			
		||||
	name=$2
 | 
			
		||||
	image=$3
 | 
			
		||||
	autoresize=$4
 | 
			
		||||
	size="$5"
 | 
			
		||||
	local volid=$1
 | 
			
		||||
	local name=$2
 | 
			
		||||
	local image=$3
 | 
			
		||||
	local autoresize=$4
 | 
			
		||||
	local size="$5"
 | 
			
		||||
	local voltype="${6:-dynamic}"
 | 
			
		||||
	echo "[$name]"
 | 
			
		||||
	echo "mode=ubi"
 | 
			
		||||
	echo "vol_id=$volid"
 | 
			
		||||
	echo "vol_type=dynamic"
 | 
			
		||||
	echo "vol_type=$voltype"
 | 
			
		||||
	echo "vol_name=$name"
 | 
			
		||||
	if [ "$image" ]; then
 | 
			
		||||
		echo "image=$image"
 | 
			
		||||
@ -38,6 +39,7 @@ ubilayout() {
 | 
			
		||||
	local rootsize=
 | 
			
		||||
	local autoresize=
 | 
			
		||||
	local rootfs_type="$( get_fs_type "$2" )"
 | 
			
		||||
	local voltype
 | 
			
		||||
 | 
			
		||||
	if [ "$1" = "ubootenv" ]; then
 | 
			
		||||
		ubivol $vol_id ubootenv
 | 
			
		||||
@ -49,16 +51,26 @@ ubilayout() {
 | 
			
		||||
		name="${part%%=*}"
 | 
			
		||||
		prev="$part"
 | 
			
		||||
		part="${part#*=}"
 | 
			
		||||
		voltype=dynamic
 | 
			
		||||
		[ "$prev" = "$part" ] && part=
 | 
			
		||||
 | 
			
		||||
		image="${part%%=*}"
 | 
			
		||||
		if [ "${image:0:1}" = ":" ]; then
 | 
			
		||||
			voltype=static
 | 
			
		||||
			image="${image:1}"
 | 
			
		||||
		fi
 | 
			
		||||
		prev="$part"
 | 
			
		||||
		part="${part#*=}"
 | 
			
		||||
		[ "$prev" = "$part" ] && part=
 | 
			
		||||
 | 
			
		||||
		size="$part"
 | 
			
		||||
		if [ -z "$size" ]; then
 | 
			
		||||
			size="$( round_up "$( stat -c%s "$image" )" 1024 )"
 | 
			
		||||
		else
 | 
			
		||||
			size="${size}MiB"
 | 
			
		||||
		fi
 | 
			
		||||
 | 
			
		||||
		ubivol $vol_id "$name" "$image" "" "${size}MiB"
 | 
			
		||||
		ubivol $vol_id "$name" "$image" "" "${size}" "$voltype"
 | 
			
		||||
		vol_id=$(( $vol_id + 1 ))
 | 
			
		||||
	done
 | 
			
		||||
	if [ "$3" ]; then
 | 
			
		||||
@ -77,10 +89,10 @@ ubilayout() {
 | 
			
		||||
			rootsize="$( round_up "$( stat -c%s "$2" )" 1024 )"
 | 
			
		||||
			;;
 | 
			
		||||
		esac
 | 
			
		||||
		ubivol $vol_id rootfs "$2" "$autoresize" "$rootsize"
 | 
			
		||||
		ubivol $vol_id rootfs "$2" "$autoresize" "$rootsize" dynamic
 | 
			
		||||
 | 
			
		||||
		vol_id=$(( $vol_id + 1 ))
 | 
			
		||||
		[ "$rootfs_type" = "ubifs" ] || ubivol $vol_id rootfs_data "" 1
 | 
			
		||||
		[ "$rootfs_type" = "ubifs" ] || ubivol $vol_id rootfs_data "" 1 dymamic
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user