From a3150fa514dde605a1e90e1ae28ab6c034bd0fa1 Mon Sep 17 00:00:00 2001 From: Chanh Nguyen Date: Tue, 7 Sep 2021 17:50:12 +0700 Subject: meta-ampere: fwupdate: detect Host FW to flash Support a wrapper script to detect the Host firmware image by checking the ExtendedVersion field from the MANIFEST file to flash into the appropriate device components. The supported image type include: - ExtendedVersion=secondary: flash to secondary Host SPI-NOR - ExtendedVersion=scp-primary: flash to primary Boot EEPROM - ExtendedVersion=scp-secondary: flash to alternative Boot EEPROM - ExtendedVersion=fru: write to the FRU EEPROM. Tested: 1. Flash UEFI firmware into the primary Host SPI-NOR via WebUI 2. Flash UEFI firmware into the secondary Host SPI-NOR via WebUI Signed-off-by: Chanh Nguyen Change-Id: I7dff2ca0f8b9de85c2cbac1a49d04b6e14721a03 --- .../packagegroups/packagegroup-ampere-apps.bb | 1 + .../phosphor-software-manager/firmware_update.sh | 101 +++++++++++++++++++++ .../obmc-flash-host-bios@.service | 2 +- .../flash/phosphor-software-manager_%.bbappend | 15 ++- 4 files changed, 116 insertions(+), 3 deletions(-) create mode 100755 meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh (limited to 'meta-ampere') diff --git a/meta-ampere/meta-common/recipes-ac01/packagegroups/packagegroup-ampere-apps.bb b/meta-ampere/meta-common/recipes-ac01/packagegroups/packagegroup-ampere-apps.bb index 856d3dc0a..9e323864f 100644 --- a/meta-ampere/meta-common/recipes-ac01/packagegroups/packagegroup-ampere-apps.bb +++ b/meta-ampere/meta-common/recipes-ac01/packagegroups/packagegroup-ampere-apps.bb @@ -36,4 +36,5 @@ RDEPENDS:${PN}-system = " \ SUMMARY:${PN}-flash = "Ampere Flash" RDEPENDS:${PN}-flash = " \ ampere-flash-utils \ + phosphor-software-manager \ " 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 new file mode 100755 index 000000000..af3e2bead --- /dev/null +++ b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh @@ -0,0 +1,101 @@ +#!/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. + +# This script updates the EDKII / SCP firmware. +# Author : Chanh Nguyen (chnguyen@amperecomputing.com) +# Date : Sep 7, 2021 +# Modified: + +usage () { + echo "Usage:" + echo " $(basename $0) " + echo "Where:" + echo " : the path link to folder, which include image file and MANIFEST" + echo "Example:" + echo " $(basename $0) /tmp/images/ghdh1393" +} + + +IMG_PATH="$1" +if [ ! -d $IMG_PATH ]; then + echo $IMG_PATH + echo "The folder $IMG_PATH does not exist" + usage + exit 1 +fi + +MANIFEST_PATH="${IMG_PATH}/MANIFEST" +if [ ! -f $MANIFEST_PATH ]; then + echo $MANIFEST_PATH + echo "The MANIFEST file $MANIFEST_PATH does not exist" + usage + exit 1 +fi + +EXTENDED_VERSION=$(awk '/ExtendedVersion/ {print}' ${MANIFEST_PATH} | cut -d "=" -f 2) + +# If the ExtendedVersion is empty, set default to update UEFI/EDKII on primary device +if [ -z "$EXTENDED_VERSION" ] +then + EXTENDED_VERSION="primary" +fi + +# Assign the command based on the ExtendedVersion +case ${EXTENDED_VERSION} in + "primary") + export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \)) + export CMD='/usr/sbin/ampere_flash_bios.sh $IMAGE 1' + ;; + + "secondary") + export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \)) + export CMD='/usr/sbin/ampere_flash_bios.sh $IMAGE 2' + ;; + + "scp-primary") + export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \)) + export CMD='/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 1' + ;; + + "scp-secondary") + export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \)) + export CMD='/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 2' + ;; + + "fru") + export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.bin" \)) + export CMD='/usr/sbin/ampere_firmware_upgrade.sh fru $IMAGE' + ;; + + *) + echo "Invalid ExtendedVersion: ${EXTENDED_VERSION}. Please check MANIFEST file!" + exit 1 + ;; +esac + + +if [ -z "$IMAGE" ] +then + echo "ERROR: The image file: No such file or directory" + exit 1 +else + eval $CMD +fi + +if [[ $? -ne 0 ]]; then + echo "ERROR: The firmware update not successfull" + exit 1 +fi diff --git a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service index c344600b2..036b78928 100644 --- a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service +++ b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-host-bios@.service @@ -4,4 +4,4 @@ Description=Ampere service for flashing the Host firmware image [Service] Type=oneshot RemainAfterExit=no -ExecStart=/usr/sbin/ampere_flash_bios.sh /tmp/images/%I/*.img +ExecStart=/usr/sbin/firmware_update.sh /tmp/images/%I diff --git a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager_%.bbappend b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager_%.bbappend index f5a250d60..7e855bcf5 100644 --- a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager_%.bbappend +++ b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager_%.bbappend @@ -1,7 +1,18 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" +SRC_URI += " \ + file://firmware_update.sh \ + " + PACKAGECONFIG[flash_bios] = "-Dhost-bios-upgrade=enabled, -Dhost-bios-upgrade=disabled" -PACKAGECONFIG:append_ = " flash_bios" +PACKAGECONFIG:append:mtjade = " flash_bios" + +SYSTEMD_SERVICE:${PN}:updater += "${@bb.utils.contains('PACKAGECONFIG', 'flash_bios', 'obmc-flash-host-bios@.service', '', d)}" + +RDEPENDS:${PN} += "bash" -SYSTEMD_SERVICE:${PN}-updater += "${@bb.utils.contains('PACKAGECONFIG', 'flash_bios', 'obmc-flash-host-bios@.service', '', d)}" +do_install:append:mtjade() { + install -d ${D}/usr/sbin + install -m 0755 ${WORKDIR}/firmware_update.sh ${D}/usr/sbin/firmware_update.sh +} -- cgit v1.2.3