BMC firmware update: Dynamically size UBI volume to fit image
This commit improves the BMC firmware update process by dynamically
sizing the UBI volumes created to hold the read-only images.
Tested: Verified that a BMC update performed using this version of the
script resulted in UBI volumes sized for the corresponding read-only
images and rebooted successfully.
Resolves openbmc/openbmc#2888
Change-Id: Id1cf9eaace35af80ed1001f3276dad5ea0ad5569
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
index b8a33ae..90ed71d 100644
--- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
+++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
@@ -140,8 +140,15 @@
ubi_remove_volumes
- # Create a static ubi volume
- # TODO Get the actual image size openbmc/openbmc#1840
+ if [ -z "${imgfile}" ]; then
+ echo "Unable to create read-only volume. Image file not specified."
+ return 1
+ fi
+
+ # Create a ubi volume, dynamically sized to fit BMC image if size unspecified
+ img="/tmp/images/${version}/${imgfile}"
+ imgsize="$(stat -c '%s' ${img})"
+
vol="$(findubi "${name}")"
if [ ! -z "${vol}" ]; then
# Allow a duplicate kernel volume on the alt mtd
@@ -403,7 +410,6 @@
name="$3"
version="$4"
imgfile="image-rofs"
- imgsize="16MiB"
ubi_ro
ubi_updatevol
ubi_block
@@ -414,7 +420,6 @@
name="$3"
version="$4"
imgfile="image-kernel"
- imgsize="4MiB"
ubi_ro
ubi_updatevol
create_vol_in_alt