From 8f618671364e4dc88c58446b4dd96ec06dbd8e2f Mon Sep 17 00:00:00 2001 From: Gunnar Mills Date: Wed, 25 Oct 2017 11:24:39 -0500 Subject: Pass in the size of the UBI image Allow user to pass in the size of the PNOR UBI image. Default is 128. Change-Id: Ifbd7ff0e9185e4d445f39be144f07eb907f0051e Signed-off-by: Gunnar Mills --- generate-ubi | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/generate-ubi b/generate-ubi index 2633500c3..511edcb7b 100755 --- a/generate-ubi +++ b/generate-ubi @@ -13,8 +13,12 @@ Options: `pwd`/.ubi.mtd (For example, "generate-ubi my.pnor.squashfs.tar" would generate `pwd`/my.pnor.ubi.mtd output.) + -s, --size Specify the size of the PNOR UBI image in MiBs. + Defaults to 128. -h, --help Display this help text and exit. ' +# 128MiB is the default image size +image_size="128" while [[ $# -gt 0 ]]; do key="$1" @@ -23,6 +27,10 @@ while [[ $# -gt 0 ]]; do outfile="$2" shift 2 ;; + -s|--size) + image_size="$2" + shift 2 + ;; -h|--help) echo "$help" exit @@ -81,9 +89,9 @@ fi FLASH_PAGE_SIZE="1" # kibibyte(KiB) FLASH_PEB_SIZE="64" -# Future enhancement would be to allow this to be passed in -# 128MiB (128 * 1024) -FLASH_SIZE="131072" + +# Convert image size from MiB to KiB +image_size=$((${image_size} * 1024)) # Create UBI volume add_volume() @@ -133,7 +141,7 @@ add_volume $config_file 2 dynamic pnor-rw-${version_id} "" 16MiB # Build the UBI image ubinize -p ${FLASH_PEB_SIZE}KiB -m ${FLASH_PAGE_SIZE} -o ${tmpfile} $config_file -mk_nor_image ${outfile} ${FLASH_SIZE} +mk_nor_image ${outfile} ${image_size} dd bs=1k conv=notrunc seek=0 if=${tmpfile} of=${outfile} echo "PNOR UBI image at ${outfile}" -- cgit v1.2.1