summaryrefslogtreecommitdiff
path: root/meta-ampere
diff options
context:
space:
mode:
authorThang Q. Nguyen <thang@os.amperecomputing.com>2022-11-08 10:43:42 +0300
committerThang Q. Nguyen <thang@os.amperecomputing.com>2024-08-12 08:34:42 +0300
commite6a0291e774f20105254155032ba31ef1f8180c6 (patch)
tree3379a5711306a182437736d9f02a47f6ee2dfa69 /meta-ampere
parent5cb45e15210a407bf97a5461c4d7b76875eb8f98 (diff)
downloadopenbmc-e6a0291e774f20105254155032ba31ef1f8180c6.tar.xz
meta-ampere: flash: refine script to flash Host firmware
Refine the scripts to flash Host firmware images to be consistent across platforms. Also update the control logic to flash UEFI firmware image to the Host SPI-NOR. Change-Id: I81205b8b9d34568db6f99e00befbe44c44f6bcc9 Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Diffstat (limited to 'meta-ampere')
-rwxr-xr-xmeta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh28
-rwxr-xr-xmeta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_firmware_upgrade.sh17
-rwxr-xr-xmeta-ampere/meta-mitchell/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh81
3 files changed, 67 insertions, 59 deletions
diff --git a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
index 96094bb054..6e2f12b275 100755
--- a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
+++ b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
@@ -44,22 +44,12 @@ case ${EXTENDED_VERSION} in
CMD="/usr/sbin/ampere_flash_bios.sh $IMAGE 2"
;;
- "scp-primary")
- IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
- CMD="/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 1"
- ;;
-
- "scp-secondary")
- IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
- CMD="/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 2"
- ;;
-
- "eeprom" | "eeprom-primary")
+ "eeprom" | "eeprom-primary" | "scp-primary")
IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" -o -name "*.bin" \))
CMD="/usr/sbin/ampere_firmware_upgrade.sh eeprom $IMAGE 1"
;;
- "eeprom-secondary")
+ "eeprom-secondary" | "scp-secondary")
IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" -o -name "*.bin" \))
CMD="/usr/sbin/ampere_firmware_upgrade.sh eeprom $IMAGE 2"
;;
@@ -76,14 +66,18 @@ case ${EXTENDED_VERSION} in
;;
"mbcpld")
- IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.jed" \))
- CMD="/usr/bin/ampere_firmware_upgrade.sh mb_cpld $IMAGE"
+ IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.jed" -o -name "*.bin" \))
+ CMD="/usr/sbin/ampere_firmware_upgrade.sh mb_cpld $IMAGE"
;;
"bmccpld")
- IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.jed" \))
- CMD="/usr/bin/ampere_firmware_upgrade.sh bmc_cpld $IMAGE"
+ IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.jed" -o -name "*.bin" \))
+ CMD="/usr/sbin/ampere_firmware_upgrade.sh bmc_cpld $IMAGE"
+ ;;
+ "bpcpld"*)
+ IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.jed" -o -name "*.bin" \))
+ TARGET="${EXTENDED_VERSION:6}"
+ CMD="/usr/sbin/ampere_firmware_upgrade.sh bp_cpld $IMAGE $TARGET"
;;
-
*)
echo "Invalid ExtendedVersion: ${EXTENDED_VERSION}. Please check MANIFEST file!"
exit 1
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 227f264923..91a45a54e3 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
@@ -102,8 +102,8 @@ if [ $# -eq 0 ]; then
echo "Usage:"
echo " $(basename "$0") <Type> <Image file> <DEV_SEL> [SECPRO]"
echo "Where:"
- echo " <Type>: smpmpro or fru"
- echo " If Type is smpmpro, then DEV_SEL must is 1 (MAIN EEPROM), 2 (Failover)"
+ echo " <Type>: eeprom or fru"
+ echo " If Type is eeprom, then DEV_SEL must is 1 (MAIN EEPROM), 2 (Failover)"
echo " SECPRO: Optional, input '1' to enter & flash secpro mode. Default: 0"
exit 0
fi
@@ -138,8 +138,11 @@ if [ $SECPRO == 1 ] && [ "$DEV_SEL" == 2 ]; then
exit
fi
-if [[ $TYPE == "smpmpro" ]]; then
- do_smpmpro_upgrade
-elif [[ $TYPE == "fru" ]]; then
- do_fru_upgrade
-fi
+case $TYPE in
+ "smpmpro" | "eeprom")
+ do_smpmpro_upgrade
+ ;;
+ "fru")
+ do_fru_upgrade
+ ;;
+esac
diff --git a/meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh b/meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh
index 3c9cd42aaa..d5fcf5c402 100755
--- a/meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh
+++ b/meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh
@@ -18,31 +18,25 @@
# 0 => to switch SPI_CS0_L to second SPI Nor device
# shellcheck disable=SC2046
+# shellcheck disable=SC2086
do_flash () {
- # Check the HNOR partition available
+ # always unbind then bind the ASpeed SMC driver again to prevent
+ # the changing of the device erasesize by nvparm
HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
- if [ -z "$HOST_MTD" ];
+ if [ -n "$HOST_MTD" ];
then
- # Check the ASpeed SMC driver binded before
- HOST_SPI=/sys/bus/platform/drivers/spi-aspeed-smc/1e630000.spi
- if [ -d "$HOST_SPI" ]; then
- echo "Unbind the ASpeed SMC driver"
- echo 1e630000.spi > /sys/bus/platform/drivers/spi-aspeed-smc/unbind
- sleep 2
- fi
-
- # If the HNOR partition is not available, then bind again driver
- echo "--- Bind the ASpeed SMC driver"
- echo 1e630000.spi > /sys/bus/platform/drivers/spi-aspeed-smc/bind
+ echo 1e630000.spi > /sys/bus/platform/drivers/spi-aspeed-smc/unbind
sleep 2
+ fi
+ echo 1e630000.spi > /sys/bus/platform/drivers/spi-aspeed-smc/bind
- HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
- if [ -z "$HOST_MTD" ];
- then
- echo "Fail to probe Host SPI-NOR device"
- exit 1
- fi
+ # Check the PNOR partition available
+ HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
+ if [ -z "$HOST_MTD" ];
+ then
+ echo "Fail to probe the Host SPI-NOR device"
+ exit 1
fi
echo "--- Flashing firmware image $IMAGE to @/dev/$HOST_MTD"
@@ -54,7 +48,7 @@ if [ $# -eq 0 ]; then
echo "Usage: $(basename "$0") <UEFI/EDKII image file> <DEV_SEL> [SPECIAL_BOOT]"
echo "Where:"
echo " DEV_SEL 1 is Primary SPI (by default), 2 is Second SPI"
- echo " SPECIAL_BOOT: Optional, input '1' to enter & flash SPECIAL_BOOT mode. Default: 0"
+ echo " SPECIAL_BOOT: Optional, input '1' to flash "Secure Provisioning" image and enter Special Boot mode. Default: 0"
exit 0
fi
@@ -106,16 +100,16 @@ if [[ $DEV_SEL == 1 ]]; then
echo "Run update Primary Host SPI-NOR"
gpioset $(gpiofind spi0-backup-sel)=1 # Primary SPI
elif [[ $DEV_SEL == 2 ]]; then
- echo "Run update Second Host SPI-NOR"
+ echo "Run update Secondary Host SPI-NOR"
gpioset $(gpiofind spi0-backup-sel)=0 # Second SPI
else
echo "Please choose primary SPI (1) or second SPI (2)"
exit 0
fi
-# Restrict to flash Second Host SPI-NOR in case of SPECIAL_BOOT
+# Restrict to flash Secondary Host SPI-NOR in case of SPECIAL_BOOT
if [ $SPECIAL_BOOT == 1 ] && [ "$DEV_SEL" == 2 ]; then
- echo "Not allow to flash the Second Host SPI-NOR with SPECIAL_BOOT image"
+ echo "Flashing 2nd Host SPI NOR image with SECProv image is not allowed"
exit
fi
@@ -125,16 +119,20 @@ do_flash
# Assert SPECIAL_BOOT GPIO PIN
if [[ $SPECIAL_BOOT == 1 ]]; then
gpioset $(gpiofind host0-special-boot)=1
+ # Set HOST BOOTCOUNT to 0 to prevent Host reboot
+ busctl set-property xyz.openbmc_project.State.Host0 \
+ /xyz/openbmc_project/state/host0 \
+ xyz.openbmc_project.Control.Boot.RebootAttempts RetryAttempts u 0
fi
-# Switch the SPI bus to the primary spi device
+# Switch the SPI bus to the primary SPI device
echo "Switch to the Primary Host SPI-NOR"
gpioset $(gpiofind spi0-backup-sel)=1 # Primary SPI
# Switch the host SPI bus to HOST."
echo "--- Switch the host SPI bus to HOST."
if ! gpioset $(gpiofind spi0-program-sel)=0; then
- echo "ERROR: Switch the host SPI bus to HOST. Please check gpio state"
+ echo "ERROR: Switch the host SPI bus to HOST. Please check GPIO state"
exit 1
fi
@@ -145,18 +143,31 @@ then
obmcutil poweron
fi
-# Deassert SPECIAL_BOOT GPIO PIN if it is being asserted
+# Detection SECProv of failure or success
if [[ $SPECIAL_BOOT == 1 ]]; then
- # Time out checking for Host ON is 60s
- cnt=12
- while [ "$cnt" -gt 0 ];
+ # 30s time out in wait for FW_BOOT_OK
+ state=0
+ cnt=60
+ while [ $cnt -gt 0 ];
do
- cnt=$((cnt - 1))
- if systemctl status obmc-host-already-on@0.target | grep "Active: active"; then
- echo "Deassert SPECIAL_BOOT GPIO PIN if it is being asserted."
- gpioset $(gpiofind host0-special-boot)=0
- exit 0
+ # Monitor FW_BOOT_OK gpio
+ state=$(gpioget $(gpiofind s0-fw-boot-ok))
+ if [[ "$state" == "1" ]]; then
+ break
fi
- sleep 5
+ sleep 0.5
+ cnt=$((cnt - 1))
done
+
+ echo "--- Turning the Chassis off"
+ obmcutil chassisoff
+
+ # Deassert SPECIAL_BOOT GPIO PIN
+ gpioset $(gpiofind host0-special-boot)=0
+
+ sleep 10
+ # Recover HOST BOOTCOUNT to default
+ busctl set-property xyz.openbmc_project.State.Host0 \
+ /xyz/openbmc_project/state/host0 \
+ xyz.openbmc_project.Control.Boot.RebootAttempts RetryAttempts u 3
fi