openpower-software-manager: Adjust the size of the ubi volume

The ubi volume size is the allocated size when they're created
so need to set the max size needed at creation time. The size
will be passed in with an argument (via openbmc/openbmc#1979)
so for now approximate the sizes based on current file sizes.

Decrease the size of the read-only partition to save some space,
since even though the volume size adjusts to the size of the image,
ubi will still reserve that space for the volume.

Increase the size of the read-write volume to be able to fit
the read-write partitions.
Slightly increase the size of the prsv volume, there are only
3 pnor prsv partitions of a few KB each.

Change-Id: I3175c731fa19127b6b16db5fe7af0cebc66e7ead
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
index 2b83947..cbe58e1 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
@@ -57,11 +57,12 @@
     mkdir "${mountdir}"
   fi
 
-  # Create a static ubi volume of arbitrary size 32MB,
-  # the volume will shrink to fit the pnor image if smaller
+  # Create a static ubi volume of arbitrary size 24MB,
+  # the current pnor image is ~19MB
+  # TODO Set size based on file size openbmc/openbmc#1840
   vol="$(findubi "${name}")"
   if [ -z "${vol}" ]; then
-    ubimkvol "${ubidev}" -N "${name}" -s 32MiB --type=static
+    ubimkvol "${ubidev}" -N "${name}" -s 24MiB --type=static
     vol="$(findubi "${name}")"
   fi
 
@@ -86,15 +87,19 @@
   ubidev="/dev/ubi${pnor}"
   mountdir="/media/${name}"
 
+  if [[ "${name}" == "pnor-prsv" ]]; then
+    size="2MiB"
+  else
+    size="16MiB"
+  fi
+
   if [ ! -d "${mountdir}" ]; then
     mkdir "${mountdir}"
   fi
 
-  # Create a dynamic ubi volume of initial arbitrary size 1MB,
-  # the volume will grow dynamically as needed
   vol="$(findubi "${name}")"
   if [ -z "${vol}" ]; then
-    ubimkvol "${ubidev}" -N "${name}" -s 1MiB
+    ubimkvol "${ubidev}" -N "${name}" -s "${size}"
   fi
 
   if ! is_mounted "${name}"; then