obmc-flash-bmc: Create a duplicate kernel volume in alt
Create a backup copy of the kernel volume in the alt mtd.
This requires allowing a duplicate volume with the same
name to be created, and perform two deletes to remove
the original and duplicate kernel volumes.
Resolves openbmc/openbmc#2200
Change-Id: I5dd57c1e3319705be9f0766d72ba9f6f3b94f22e
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 d94f472..116b486 100644
--- a/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
+++ b/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
@@ -69,6 +69,10 @@
( "${rmname}" != "${kernelname}" ) ]]; then
ubi_remove "rofs-${rmversion}"
ubi_remove "kernel-${rmversion}"
+ # Remove the kernel copy in alt if any
+ if [[ "${name}" =~ "kernel" ]]; then
+ ubi_remove "kernel-${rmversion}" "${ro}"
+ fi
break
fi
done
@@ -115,6 +119,12 @@
# Create a static ubi volume
# TODO Get the actual image size openbmc/openbmc#1840
vol="$(findubi "${name}")"
+ if [ ! -z "${vol}" ]; then
+ # Allow a duplicate kernel volume on the alt mtd
+ if [[ "${name}" =~ "kernel" ]]; then
+ vol="$(findubi_onmtd "${name%-*}-" "${ro}")"
+ fi
+ fi
if [ -z "${vol}" ]; then
ubimkvol "${ubidev}" -N "${name}" -s "${imgsize}" --type=static
vol="$(findubi "${name}")"
@@ -239,6 +249,18 @@
ubi_setenv "root=${block}"
}
+# Create a copy in the alt mtd
+create_vol_in_alt() {
+ alt="alt-bmc"
+ altmtd="$(findmtd "${alt}")"
+ if [ ! -z "${altmtd}" ]; then
+ reqmtd="${alt}"
+ reqmtd2="${alt}"
+ ubi_ro
+ ubi_updatevol
+ fi
+}
+
case "$1" in
mtduboot)
reqmtd="$2"
@@ -271,6 +293,7 @@
imgsize="4MiB"
ubi_ro
ubi_updatevol
+ create_vol_in_alt
;;
ubiremove)
name="$2"