diff options
author | Eddie James <eajames@us.ibm.com> | 2018-02-02 01:46:40 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-02-08 18:34:11 +0300 |
commit | 506e1601e09cf151bdba2cafc8cb2a6ba073b1e6 (patch) | |
tree | 8144d8e8ec8f49992930498f9503d99cf212fa7f /meta-phosphor | |
parent | 98d77428072ac10df2026cf6727607948247b166 (diff) | |
download | openbmc-506e1601e09cf151bdba2cafc8cb2a6ba073b1e6.tar.xz |
fix alternate boot after watchdog reset
If the watchdog resets and results in booting from the alternate flash
chip, the ubiblock uboot environment variables were not set correctly
by simply mirroring the primary flash values. Instead, we need to flip
the chip so that we correctly boot from the backup kernel.
Resolves openbmc/openbmc#2840
Change-Id: Iabf93053015704049244aea81e83a797b0b16650
Signed-off-by: Eddie James <eajames@us.ibm.com>
Diffstat (limited to 'meta-phosphor')
-rw-r--r-- | meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc | 46 |
1 files changed, 44 insertions, 2 deletions
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 da62b10da..4bb70918f 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 @@ -29,6 +29,13 @@ findmtd() { echo "${m}" } +# Get the mtd device number only (return X of mtdX) +findmtdnum() { + m="$(findmtd "$1")" + m="${m##mtd}" + echo "${m}" +} + # Get the ubi device number (ubiX_Y) findubi() { u="$(grep -xl "$1" /sys/class/ubi/ubi?/subsystem/ubi*/name)" @@ -258,6 +265,41 @@ copy_env_var_to_alt() { fw_setenv -c /etc/alt_fw_env.config "${varName}" "${value}" } +# When the alternate bmc chip boots, u-boot thinks its the primary mtdX. +# Therefore need to swap the chip numbers when copying the ubiblock and root to +# alternate bmc u-boot environment. +copy_ubiblock_to_alt() { + value="$(fw_printenv -n ubiblock)" + bmcNum="$(findmtdnum "bmc")" + altNum="$(findmtdnum "alt-bmc")" + replaceAlt="${value/${altNum},/${bmcNum},}" + + if [[ "${value}" == "${replaceAlt}" ]]; then + replaceBmc="${value/${bmcNum},/${altNum},}" + value=${replaceBmc} + else + value=${replaceAlt} + fi + + fw_setenv -c /etc/alt_fw_env.config ubiblock "${value}" +} + +copy_root_to_alt() { + value="$(fw_printenv -n root)" + bmcNum="$(findmtdnum "bmc")" + altNum="$(findmtdnum "alt-bmc")" + replaceAlt="${value/${altNum}_/${bmcNum}_}" + + if [[ "${value}" == "${replaceAlt}" ]]; then + replaceBmc="${value/${bmcNum}_/${altNum}_}" + value=${replaceBmc} + else + value=${replaceAlt} + fi + + fw_setenv -c /etc/alt_fw_env.config root "${value}" +} + ubi_setenv() { # The U-Boot environment maintains two banks of environment variables. # The banks need to be consistent with each other to ensure that these @@ -283,8 +325,8 @@ mtd_write() { backup_env_vars() { copy_env_var_to_alt kernelname - copy_env_var_to_alt ubiblock - copy_env_var_to_alt root + copy_ubiblock_to_alt + copy_root_to_alt } update_env_vars() { |