From 9eb1d1039b596f2da92c4f05a57c89891bfef448 Mon Sep 17 00:00:00 2001 From: Thang Tran Date: Thu, 17 Nov 2022 10:35:04 +0700 Subject: [PATCH] meta-ampere: mtjade: flash: fix EDKII flashing sometime fail Issue: Users can not flash EDKII when request to flash SCP before. Steps to reproduce this issue as below: 1. Request to flash SCP via Redfish. 2. Sleep 120s, when CPU is booting (did not jump to OS) 3. Request to flash EDKII via Redfish. 4. HOST is turned off, EDKII is not updated. Root cause: Before EDKII is updated, BMC turns off the HOST and waits 10s. After that, BMC checks the chassis status, if it still is "On", BMC stops flashing and did not turn on the HOST. But during HOST is booting, BMC needs more time to turn off the HOST, therefore waiting for 10s is not enough. Solution: increase waiting time to 60s, BMC checks the chassis status each 10s. Tested: 1. Repeat step 1 -> 3 in "Issue" part. CPU is turned on after flashing is completed. 2. In the CPU console, check the EDKII version dmidecode -t 0 3. New EDKII is updated Signed-off-by: Thang Tran --- .../ampere-utils/ampere_firmware_upgrade.sh | 51 +++++++++++-------- .../ampere-utils/ampere_flash_bios.sh | 28 +++++++--- 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_firmware_upgrade.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_firmware_upgrade.sh index 130682d12a89..4ded729897aa 100755 --- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_firmware_upgrade.sh +++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_firmware_upgrade.sh @@ -31,14 +31,26 @@ do_smpmpro_upgrade() { then echo "Turning the Chassis off" obmcutil chassisoff - sleep 15 - # Check if HOST was OFF - chassisstate_off=$(obmcutil chassisstate | awk -F. '{print $NF}') - if [ "$chassisstate_off" == 'On' ]; - then - echo "Error : Failed turning the Chassis off" - exit - fi + + # Wait 60s until Chassis is off + cnt=30 + while [ "$cnt" -gt 0 ]; + do + cnt=$((cnt - 1)) + sleep 2 + # Check if HOST was OFF + chassisstate_off=$(obmcutil chassisstate | awk -F. '{print $NF}') + if [ "$chassisstate_off" != 'On' ]; + then + break + fi + + if [ "$cnt" == "0" ]; + then + echo "--- Error : Failed turning the Chassis off" + exit 1 + fi + done fi if [[ $SECPRO == 1 ]]; then @@ -73,6 +85,15 @@ do_smpmpro_upgrade() { # 226 is BMC_GPIOAC2_SPI0_PROGRAM_SEL gpioset 0 226=1 + # Deassert SECPRO GPIO PINs + if [[ $SECPRO == 1 ]]; then + echo "De-asserting special GPIO PINs" + # 3 is S0_SPECIAL_BOOT + gpioset 0 3=0 + # 66 is S1_SPECIAL_BOOT + gpioset 0 66=0 + fi + if [ "$chassisstate" == 'On' ]; then sleep 5 @@ -80,20 +101,6 @@ do_smpmpro_upgrade() { obmcutil poweron fi - # Deassert SECPRO GPIO PINs - if [[ $SECPRO == 1 ]]; then - chassisstate=$(obmcutil chassisstate | awk -F. '{print $NF}') - if [ "$chassisstate_off" == 'Off' ]; then - obmcutil poweron - fi - - sleep 30s - echo "De-asserting special GPIO PINs" - # 3 is S0_SPECIAL_BOOT - gpioset 0 3=0 - # 66 is S1_SPECIAL_BOOT - gpioset 0 66=0 - fi } diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh index 7852dc4acca8..5a13da481c4a 100755 --- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh +++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh @@ -69,14 +69,26 @@ if [ "$chassisstate" == 'On' ]; then echo "--- Turning the Chassis off" obmcutil chassisoff - sleep 10 - # Check if HOST was OFF - chassisstate_off=$(obmcutil chassisstate | awk -F. '{print $NF}') - if [ "$chassisstate_off" == 'On' ]; - then - echo "--- Error : Failed turning the Chassis off" - exit 1 - fi + + # Wait 60s until Chassis is off + cnt=30 + while [ "$cnt" -gt 0 ]; + do + cnt=$((cnt - 1)) + sleep 2 + # Check if HOST was OFF + chassisstate_off=$(obmcutil chassisstate | awk -F. '{print $NF}') + if [ "$chassisstate_off" != 'On' ]; + then + break + fi + + if [ "$cnt" == "0" ]; + then + echo "--- Error : Failed turning the Chassis off" + exit 1 + fi + done fi # Switch the host SPI bus to BMC"