obmc-flash-bmc: Add set_wdt2bite

With commit https://gerrit.openbmc-project.xyz/#/c/10248/
a new u-boot env variable set was introduced to switch
sides on failure to boot. Since a BMC update does not
update the env variables, explicitly set them if they're
not present.

Tested: Verified the new env variables were set after
activating the image and rebooting the BMC.

Change-Id: I807c3e4f9a37d9d9d5f474ba4eb7c60351e3334e
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 4c69713..8327ad9 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
@@ -94,6 +94,16 @@
   echo "${n}"
 }
 
+# Set the u-boot envs that perform a side switch on failure to boot
+set_wdt2bite() {
+  if ! fw_printenv wdt2bite 2>/dev/null; then
+    fw_setenv wdt2bite "mw.l 0x1e785024 0xa 1; mw.b 0x1e78502c 0xb3 1"
+    fw_setenv bootalt "run wdt2bite"
+    fw_setenv obmc_bootcmd "ubi part obmc-ubi; run do_rwreset; ubi read \
+\${loadaddr} \${kernelname}; bootm \${loadaddr} || run bootalt"
+  fi
+}
+
 # Make space on flash before creating new volumes. This can be enhanced
 # determine current flash usage. For now only keep a "keepmax" number of them
 ubi_remove_volumes()
@@ -282,6 +292,8 @@
       fi
     done
   done
+
+  set_wdt2bite
 }
 
 # Read the current env variable and set it on the alternate boot env