obmc-flash-bmc: Ignore error if rwfs_size is not set
Ignore the return code of fw_printenv in case rwfs_size doesn't
exist, otherwise the function fails and doesn't get set.
Also check that the imgsize variable is set before calling
fw_setenv to prevent accidentally clearing the rwfs_size.
Tested: Verified that rwfs_size gets set when it didn't exist.
Also that it gets updated when the value is different than
the one passed. And that it doesn't get cleared if the function
is called without passing the imgsize argument.
Change-Id: I02e3414e3b22da55890b7343b8805402139b6bad
Signed-off-by: Adriana Kobylak <anoo@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 d570e83..26b83e6 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
@@ -108,9 +108,12 @@
rw="${rwmtd#mtd}"
ubidev="/dev/ubi${rw}"
- rwsize="$(fw_printenv -n rwfs_size)"
- if [[ "${imgsize}" != "${rwsize}" ]]; then
- fw_setenv rwfs_size "${imgsize}"
+ # Update rwfs_size, check imgsize was specified, otherwise it'd clear the var
+ if [ ! -z "$imgsize" ]; then
+ rwsize="$(fw_printenv -n rwfs_size 2>/dev/null)" || true
+ if [[ "${imgsize}" != "${rwsize}" ]]; then
+ fw_setenv rwfs_size "${imgsize}"
+ fi
fi
vol="$(findubi "${name}")"