diff options
author | Peter Yin <peter.yin@quantatw.com> | 2023-12-19 18:50:46 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2024-01-04 18:42:06 +0300 |
commit | 309918cd167f16c95dd508ac5a6afd9701470737 (patch) | |
tree | 05829198778db3d1209a10cf93635b5bd09d9bc5 | |
parent | a5bb1b519246435f22a034f9040505ee7302bfdb (diff) | |
download | openbmc-309918cd167f16c95dd508ac5a6afd9701470737.tar.xz |
meta-facebook: harma: flash:bios
Support for BIOS update.
root@harma:/tmp# ./bios-update.sh F0M_1A02.BIN
Bios upgrade started at Tue Dec 19 07:06:04 PST 2023
Power off host server
Host server powered off
Set GPIO to access SPI flash from BMC used by host
switch bios GPIO to bmc
set_gpio: set bmc-spi-mux-select-0 = 1 success
bind aspeed-smc spi driver
Bios image is F0M_1A02.BIN
mtd6 is not a pnor device
mtd6 not available
Flashing bios image to mtd7...
Erasing block: 256/256 (100%)
Writing kb: 16384/16384 (100%)
Verifying kb: 16384/16384 (100%)
bios updated successfully...
Unbind aspeed-smc spi driver
Set GPIO back for host to access SPI flash
switch bios GPIO to CPU
set_gpio: set bmc-spi-mux-select-0 = 0 success
Please do sled cycle.
Change-Id: I9e1c8afca44abb1917fa342ee505ad38e845d192
Signed-off-by: Peter Yin <peter.yin@quantatw.com>
3 files changed, 104 insertions, 0 deletions
diff --git a/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh b/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh new file mode 100755 index 0000000000..0d52876a08 --- /dev/null +++ b/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +# shellcheck source=meta-facebook/recipes-fb/obmc_functions/files/fb-common-functions +source /usr/libexec/fb-common-functions +# shellcheck source=meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/power-cmd +source /usr/libexec/phosphor-state-manager/power-cmd + +IMAGE_FILE=$1 + +SPI_DEV="spi1.0" +SPI_PATH="/sys/bus/spi/drivers/spi-nor" + +set_gpio_to_bmc() +{ + echo "switch bios GPIO to bmc" + # bmc-spi-mux-select-0: 1:BMC / 0:CPU + set_gpio bmc-spi-mux-select-0 1 + return 0 +} + +set_gpio_to_cpu() +{ + echo "switch bios GPIO to CPU" + # bmc-spi-mux-select-0: 1:BMC / 0:CPU + set_gpio bmc-spi-mux-select-0 0 + return 0 +} + +echo "Bios upgrade started at $(date)" + +#Power off host server. +echo "Power off host server" +power_off +sleep 15 +if [ "$(power_status)" != "off" ]; +then + echo "Host server didn't power off" + echo "Bios upgrade failed" + exit 1 +fi +echo "Host server powered off" + +#Flip GPIO to access SPI flash used by host. +echo "Set GPIO $GPIO to access SPI flash from BMC used by host" +set_gpio_to_bmc + +#Bind spi driver to access flash +echo "bind aspeed-smc spi driver" +echo -n $SPI_DEV > $SPI_PATH/bind +sleep 1 + +#Flashcp image to device. +if [ -e "$IMAGE_FILE" ]; +then + echo "Bios image is $IMAGE_FILE" + for d in mtd6 mtd7 ; do + if [ -e "/dev/$d" ]; then + mtd=$(cat /sys/class/mtd/$d/name) + if [ "$mtd" == "pnor" ]; then + echo "Flashing bios image to $d..." + if flashcp -v "$IMAGE_FILE" /dev/$d; then + echo "bios updated successfully..." + else + echo "bios update failed..." + fi + break + fi + echo "$d is not a pnor device" + fi + echo "$d not available" + done +else + echo "Bios image $IMAGE_FILE doesn't exist" +fi + +#Unbind spi driver +sleep 1 +echo "Unbind aspeed-smc spi driver" +echo -n $SPI_DEV > $SPI_PATH/unbind +sleep 10 + +#Flip GPIO back for host to access SPI flash +echo "Set GPIO $GPIO back for host to access SPI flash" +set_gpio_to_cpu +sleep 5 + +echo "Please do sled cycle." diff --git a/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service b/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service new file mode 100644 index 0000000000..7e098908e5 --- /dev/null +++ b/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service @@ -0,0 +1,7 @@ +[Unit] +Description=Flash Host Bios image %I to Host + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/usr/sbin/bios-update.sh /tmp/images/%i diff --git a/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager_%.bbappend b/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager_%.bbappend new file mode 100644 index 0000000000..047f01970a --- /dev/null +++ b/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager_%.bbappend @@ -0,0 +1,10 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" +SRC_URI += "file://bios-update.sh" + +PACKAGECONFIG:append = " flash_bios" +RDEPENDS:${PN} += "bash" + +do_install:append() { + install -d ${D}/${sbindir} + install -m 0755 ${WORKDIR}/bios-update.sh ${D}/${sbindir}/ +} |