diff options
author | Vijay Khemka <vijaykhemka@fb.com> | 2020-06-13 00:30:49 +0300 |
---|---|---|
committer | Andrew Geissler <geissonator@yahoo.com> | 2020-06-16 01:35:07 +0300 |
commit | d978c32c464d8cc1d6ec7980135aea475e438a2a (patch) | |
tree | 55f092c079a054333e08daf880931b69220a1d09 /meta-facebook/recipes-phosphor/flash/phosphor-software-manager | |
parent | 000c8ff82e8991744da91f3fccceab8ee81eb70a (diff) | |
download | openbmc-d978c32c464d8cc1d6ec7980135aea475e438a2a.tar.xz |
meta-facebook: move flash path
flash feature was included earlier for bios upgrade but by mistake
it added a new directory structure meta-facebook under meta-facebook.
So corrected this here.
(From meta-facebook rev: 515339cf26a50d544156bdff80e754ff0bead63f)
Change-Id: I67fd0b2f06cdd95e13aefb56b87bd89fb0a8e429
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'meta-facebook/recipes-phosphor/flash/phosphor-software-manager')
-rwxr-xr-x | meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh | 142 | ||||
-rw-r--r-- | meta-facebook/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service | 7 |
2 files changed, 149 insertions, 0 deletions
diff --git a/meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh b/meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh new file mode 100755 index 000000000..fd1c52b2a --- /dev/null +++ b/meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh @@ -0,0 +1,142 @@ +#!/bin/bash + +set -e + +POWER_CMD="/usr/sbin/power-util mb" +IMAGE_FILE=$1/bios.bin +GPIO=389 + +IPMB_OBJ="xyz.openbmc_project.Ipmi.Channel.Ipmb" +IPMB_PATH="/xyz/openbmc_project/Ipmi/Channel/Ipmb" +IPMB_INTF="org.openbmc.Ipmb" +IPMB_CALL="sendRequest yyyyay" +ME_CMD_RECOVER="1 0x2e 0 0xdf 4 0x57 0x01 0x00 0x01" +ME_CMD_RESET="1 6 0 0x2 0" +SPI_DEV="1e630000.spi" +SPI_PATH="/sys/bus/platform/drivers/aspeed-smc" + +set_gpio_to_bmc() +{ + echo "switch bios GPIO to bmc" + if [ ! -d /sys/class/gpio/gpio$GPIO ]; then + cd /sys/class/gpio + echo $GPIO > export + cd gpio$GPIO + else + cd /sys/class/gpio/gpio$GPIO + fi + direc=`cat direction` + if [ $direc == "in" ]; then + echo "out" > direction + fi + data=`cat value` + if [ "$data" == "0" ]; then + echo 1 > value + fi + return 0 +} + +set_gpio_to_pch() +{ + echo "switch bios GPIO to pch" + if [ ! -d /sys/class/gpio/gpio$GPIO ]; then + cd /sys/class/gpio + echo $GPIO > export + cd gpio$GPIO + else + cd /sys/class/gpio/gpio$GPIO + fi + direc=`cat direction` + if [ $direc == "in" ]; then + echo "out" > direction + fi + data=`cat value` + if [ "$data" == "1" ]; then + echo 0 > value + fi + echo "in" > direction + echo $GPIO > /sys/class/gpio/unexport + return 0 +} + +echo "Bios upgrade started at $(date)" + +#Power off host server. +echo "Power off host server" +$POWER_CMD off +sleep 15 +if [ $($POWER_CMD status) != "off" ]; +then + echo "Host server didn't power off" + echo "Bios upgrade failed" + exit -1 +fi +echo "Host server powered off" + +#Set ME to recovery mode +echo "Set ME to recovery mode" +busctl call $IPMB_OBJ $IPMB_PATH $IPMB_INTF $IPMB_CALL $ME_CMD_RECOVER +sleep 5 + +#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..." + flashcp -v $IMAGE_FILE /dev/$d + if [ $? -eq 0 ]; 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_pch +sleep 5 + +#Reset ME to boot from new bios +echo "Reset ME to boot from new bios" +busctl call $IPMB_OBJ $IPMB_PATH $IPMB_INTF $IPMB_CALL $ME_CMD_RESET +sleep 10 + +#Power on server +echo "Power on server" +$POWER_CMD on +sleep 5 + +# Retry to power on once again if server didn't powered on +if [ $($POWER_CMD status) != "on" ]; +then + sleep 5 + echo "Powering on server again" + $POWER_CMD on +fi diff --git a/meta-facebook/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service b/meta-facebook/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service new file mode 100644 index 000000000..7e098908e --- /dev/null +++ b/meta-facebook/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 |