summaryrefslogtreecommitdiff
path: root/meta-ampere/meta-jade
diff options
context:
space:
mode:
authorThang Q. Nguyen <thang@os.amperecomputing.com>2021-01-07 10:16:50 +0300
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2021-02-01 16:44:47 +0300
commit25254b72534874a19e28baa00446247765ccdbde (patch)
tree679be069166258eb40271c5e0981ceaeb14a03a0 /meta-ampere/meta-jade
parent189431e93efb0dfd7efa69c40fead8bd11a9b01a (diff)
downloadopenbmc-25254b72534874a19e28baa00446247765ccdbde.tar.xz
meta-ampere: mtjade: Add Host firmware update support
Enable flash_bios feature and configure to use backend script to flash UEFI firmware via Redfish, WebUI and Rest. Tested: 1. Flash UEFI firmware via WebUI. 2. Flash UEFI firmware via Redfish UpdateService 3. Flash UEFI firmware via Rest interface. Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com> Change-Id: I772e6a409414e374ed01e72e3c69985d0b413cb5
Diffstat (limited to 'meta-ampere/meta-jade')
-rw-r--r--meta-ampere/meta-jade/conf/machine/mtjade.conf13
-rw-r--r--meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils.bb23
-rwxr-xr-xmeta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh103
3 files changed, 139 insertions, 0 deletions
diff --git a/meta-ampere/meta-jade/conf/machine/mtjade.conf b/meta-ampere/meta-jade/conf/machine/mtjade.conf
index 5999392f45..2180189536 100644
--- a/meta-ampere/meta-jade/conf/machine/mtjade.conf
+++ b/meta-ampere/meta-jade/conf/machine/mtjade.conf
@@ -6,8 +6,21 @@ require conf/machine/include/ast2500.inc
require conf/machine/include/obmc-bsp-common.inc
require conf/distro/include/phosphor-isolation.inc
+OBMC_MACHINE_FEATURES += "\
+ obmc-phosphor-chassis-mgmt \
+ obmc-phosphor-flash-mgmt \
+ obmc-chassis-state-mgmt \
+ obmc-bmc-state-mgmt \
+ "
+
VOLATILE_LOG_DIR = "no"
OBMC_IMAGE_EXTRA_INSTALL_append = "\
ampere-usbnet \
+ ampere-flash-utils \
"
+
+PREFERRED_PROVIDER_virtual/obmc-chassis-mgmt = "packagegroup-ampere-apps"
+PREFERRED_PROVIDER_virtual/obmc-system-mgmt = "packagegroup-ampere-apps"
+PREFERRED_PROVIDER_virtual/obmc-flash-mgmt = "packagegroup-ampere-apps"
+PREFERRED_PROVIDER_virtual/phosphor-ipmi-fru-hostfw-config ?= "hostboot-inventory-config-native"
diff --git a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils.bb b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils.bb
new file mode 100644
index 0000000000..9b28401345
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils.bb
@@ -0,0 +1,23 @@
+
+SUMMARY = "Ampere Computing LLC Flashing Utilities"
+DESCRIPTION = "Application to support flashing utilities on Ampere platforms"
+PR = "r0"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+RDEPENDS_${PN} = "bash"
+DEPENDS = "zlib"
+
+SRC_URI += "\
+ file://ampere_flash_bios.sh \
+ "
+
+S = "${WORKDIR}"
+ROOT = "${STAGING_DIR_TARGET}"
+
+LDFLAGS += "-L ${ROOT}/usr/lib/ -lz "
+
+do_install_append() {
+ install -d ${D}/usr/sbin
+ install -m 0755 ${S}/ampere_flash_bios.sh ${D}/${sbindir}/ampere_flash_bios.sh
+}
diff --git a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
new file mode 100755
index 0000000000..876671c1bb
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
@@ -0,0 +1,103 @@
+#!/bin/bash
+#
+# Copyright (c) 2021 Ampere Computing LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+do_flash () {
+ # Check the PNOR partition available
+ HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
+ if [ -z "$HOST_MTD" ];
+ then
+ # If the PNOR partition is not available, then bind again driver
+ echo "--- Bind the ASpeed SMC driver"
+ echo 1e630000.spi > /sys/bus/platform/drivers/aspeed-smc/bind
+ sleep 2
+
+ HOST_MTD=$(cat /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
+
+ echo "--- Flashing firmware to @/dev/$HOST_MTD"
+ flash_eraseall /dev/$HOST_MTD
+ flashcp -v $IMAGE /dev/$HOST_MTD
+
+ echo "--- Unbind the ASpeed SMC driver"
+ echo 1e630000.spi > /sys/bus/platform/drivers/aspeed-smc/unbind
+ else
+ echo "--- Flashing firmware to @/dev/$HOST_MTD"
+ flash_eraseall /dev/$HOST_MTD
+ flashcp -v $IMAGE /dev/$HOST_MTD
+ fi
+}
+
+
+if [ $# -eq 0 ]; then
+ echo "Usage: $(basename $0) <BIOS image file>"
+ exit 0
+fi
+
+IMAGE="$1"
+if [ ! -f $IMAGE ]; then
+ echo $IMAGE
+ echo "The image file $IMAGE does not exist"
+ exit 1
+fi
+
+# Turn off the Host if it is currently ON
+chassisstate=$(obmcutil chassisstate | awk -F. '{print $NF}')
+echo "--- Current Chassis State: $chassisstate"
+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
+fi
+
+# Switch the host SPI bus to BMC"
+echo "--- Switch the host SPI bus to BMC."
+gpioset 0 226=0
+
+if [[ $? -ne 0 ]]; then
+ echo "ERROR: Switch the host SPI bus to BMC. Please check gpio state"
+ exit 1
+fi
+
+# Flash the firmware
+do_flash
+
+# Switch the host SPI bus to HOST."
+echo "--- Switch the host SPI bus to HOST."
+gpioset 0 226=1
+
+if [[ $? -ne 0 ]]; then
+ echo "ERROR: Switch the host SPI bus to HOST. Please check gpio state"
+ exit 1
+fi
+
+if [ "$chassisstate" == 'On' ];
+then
+ sleep 5
+ echo "Turn on the Host"
+ obmcutil chassison
+fi