obmc-flash-bmc: Set boot env variables with info of new image
When an image is updated, update the env variables to indicate
u-boot and kernel the ubi information to find the new image.
Store their current values to the alternate env variable before
updating in case the there chips switch due to a failure,
there is a pointer to an existing version.
Update the env variable if the volume was succesfully updated,
create the ubiblock after the successful volume update.
Change-Id: Ia6e3eb133a6535b5de6ecbba4af262c63f2dc140
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc b/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
index 4be7585..c6879cf 100644
--- a/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
+++ b/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
@@ -76,7 +76,15 @@
block="/dev/ubiblock${ubidevid}"
if [ ! -e "$block" ]; then
ubiblock --create "/dev/ubi${ubidevid}"
+ if [ $? != 0 ]; then
+ echo "Unable to create ubiblock ${name}:${ubidevid}"
+ return 1
+ fi
fi
+ copy_env_var_to_alt ubiblock
+ ubi_setenv "ubiblock=$(echo "${ubidevid}" | sed 's/_/,/')"
+ copy_env_var_to_alt root
+ ubi_setenv "root=${block}"
}
ubi_updatevol() {
@@ -84,6 +92,14 @@
ubidevid="${vol#ubi}"
img="/tmp/images/${version}/${imgfile}"
ubiupdatevol "/dev/ubi${ubidevid}" "${img}"
+ if [ $? != 0 ]; then
+ echo "Unable to update volume ${name}!"
+ return 1
+ fi
+ if [[ "${name}" =~ "kernel" ]]; then
+ copy_env_var_to_alt kernelname
+ ubi_setenv "kernelname=${name}"
+ fi
}
ubi_remove() {
@@ -139,7 +155,15 @@
done
}
+# Read the current env variable and set it on the alternate boot env
+copy_env_var_to_alt() {
+ varName=$1
+ value="$(fw_printenv -n "${varName}")"
+ fw_setenv -c /etc/alt_fw_env.config "${varName}" "${value}"
+}
+
ubi_setenv() {
+ variable=$1
varName="${variable%=*}"
value="${variable##*=}"
fw_setenv "$varName" "$value"
@@ -171,8 +195,8 @@
imgfile="image-rofs"
imgsize="16MiB"
ubi_ro
- ubi_block
ubi_updatevol
+ ubi_block
;;
ubikernel)
reqmtd="$(echo "$2" | cut -d "+" -f 1)"
@@ -189,8 +213,7 @@
ubi_remove
;;
ubisetenv)
- variable="$2"
- ubi_setenv
+ ubi_setenv "$2"
;;
ubiremount)
remount_ubi