summaryrefslogtreecommitdiff
path: root/meta-ibm/meta-system1
diff options
context:
space:
mode:
authorAsmitha Karunanithi <asmitk01@in.ibm.com>2024-08-22 15:57:24 +0300
committerAsmitha Karunanithi <asmitk01@in.ibm.com>2024-09-24 16:57:57 +0300
commit22403a02c318a86b67d1e65cdd0a53df2fc668e1 (patch)
tree48fa76cb9d1a2c52704d748ff342064c43e9c623 /meta-ibm/meta-system1
parentc975a84b1479085d2cff387611bbf8d51f26483c (diff)
downloadopenbmc-22403a02c318a86b67d1e65cdd0a53df2fc668e1.tar.xz
meta-ibm: system1: Add bios version package
This commit includes changes to update the bios version flashed in x86 PCH SPI flash. The version is updated in the dbus as well and cached for later use to avoid reading SPI flash subsequently. This service is started after "xyz.openbmc_project.Software.Version.service", typically during boot or when flashing a host firmware via BMC to update version information. Tested By: Built openbmc, and verified that the service is installed on the bmc. The host firmware version is updated on the dbus [1] and updated in the `/var/cache/bios_version` file, when PCH is in standby. [1] busctl get-property xyz.openbmc_project.Software.BMC.Updater /xyz/openbmc_project/software/bios_active xyz.openbmc_project.Software.Version Version Change-Id: Ic7b4bb1250b8f1b8fc62fc7fd46654375937a459 Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com>
Diffstat (limited to 'meta-ibm/meta-system1')
-rw-r--r--meta-ibm/meta-system1/recipes-phosphor/flash/bios-version.bb26
-rw-r--r--meta-ibm/meta-system1/recipes-phosphor/flash/bios-version/bios-version.service12
-rw-r--r--meta-ibm/meta-system1/recipes-phosphor/flash/bios-version/bios-version.sh58
-rw-r--r--meta-ibm/meta-system1/recipes-phosphor/flash/phosphor-software-manager_%.bbappend1
4 files changed, 97 insertions, 0 deletions
diff --git a/meta-ibm/meta-system1/recipes-phosphor/flash/bios-version.bb b/meta-ibm/meta-system1/recipes-phosphor/flash/bios-version.bb
new file mode 100644
index 0000000000..99336c4819
--- /dev/null
+++ b/meta-ibm/meta-system1/recipes-phosphor/flash/bios-version.bb
@@ -0,0 +1,26 @@
+SUMMARY = "YAML configuration for IBM System1"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit systemd
+
+RDEPENDS:${PN} += "bash flashrom"
+
+SRC_URI += " \
+ file://bios-version.sh \
+ file://bios-version.service \
+ "
+
+do_install:append() {
+ install -d ${D}/${sbindir}
+ install -m 0755 ${WORKDIR}/bios-version.sh ${D}/${sbindir}/
+
+ install -d ${D}${systemd_system_unitdir}
+ install -m 0644 ${WORKDIR}/bios-version.service ${D}${systemd_system_unitdir}/
+}
+
+SYSTEMD_SERVICE:${PN} += "bios-version.service"
+
+FILES:${PN} += "${systemd_system_unitdir}/bios-version.service ${sbindir}/bios-version.sh"
+
diff --git a/meta-ibm/meta-system1/recipes-phosphor/flash/bios-version/bios-version.service b/meta-ibm/meta-system1/recipes-phosphor/flash/bios-version/bios-version.service
new file mode 100644
index 0000000000..edcb861c56
--- /dev/null
+++ b/meta-ibm/meta-system1/recipes-phosphor/flash/bios-version/bios-version.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Update current Host FW version
+After=xyz.openbmc_project.Software.Version.service
+Wants=xyz.openbmc_project.Software.Version.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/bin/bash /usr/sbin/bios-version.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-ibm/meta-system1/recipes-phosphor/flash/bios-version/bios-version.sh b/meta-ibm/meta-system1/recipes-phosphor/flash/bios-version/bios-version.sh
new file mode 100644
index 0000000000..16b0dd51e6
--- /dev/null
+++ b/meta-ibm/meta-system1/recipes-phosphor/flash/bios-version/bios-version.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+set -e
+
+# Find the GPIO pin associated with "pch-ready"
+GPIO_PIN=$(gpiofind "pch-ready")
+
+if [ -z "${GPIO_PIN}" ]; then
+ echo "gpio 'pch-ready' not found in device tree. Exiting."
+ exit 0
+fi
+
+# Read the value of the GPIO pin
+GPIO_CHIP=$(echo "$GPIO_PIN" | cut -d' ' -f1) # Extract gpiochip
+GPIO_LINE=$(echo "$GPIO_PIN" | cut -d' ' -f2) # Extract line offset
+GPIO_VALUE=$(gpioget "$GPIO_CHIP" "$GPIO_LINE")
+
+if [ "${GPIO_VALUE}" != "0" ]; then
+ echo "PCH is not on standby. Exiting host firmware version read."
+ exit 0
+fi
+
+# Fetch the MTD device number for the specified espi flash device
+DEVICE_NAME="espi-flash-mafs"
+MTD_DEVICE_NUMBER=$(grep "$DEVICE_NAME" /proc/mtd | awk -F: '{print $1}' | awk -F'mtd' '{print $2}')
+
+if [ -n "$MTD_DEVICE_NUMBER" ]; then
+ echo "Found MTD device number: $MTD_DEVICE_NUMBER"
+else
+ echo "Error: MTD device with name '$DEVICE_NAME' not found!"
+ exit 0
+fi
+
+BIOS_FILE="$(mktemp)"
+flashrom -p linux_mtd:dev="${MTD_DEVICE_NUMBER}" --ifd -i bios -r "${BIOS_FILE}"
+
+bios_version=$(strings "${BIOS_FILE}" | grep COREBOOT_EXTR | head -n 1 | awk '{ print $3}' | sed 's/"//g' | sed 's/^-\(.*\)/\1/')
+
+if [ "${bios_version}" == "" ] ; then
+ bios_version=$(strings "${BIOS_FILE}" | grep COREBOOT_VERS | head -n 1 | awk '{ print $3}' | sed 's/"//g' | sed 's/^-\(.*\)/\1/')
+fi
+
+# Clean up the temporary BIOS file
+rm "${BIOS_FILE}"
+
+# If BIOS version is found, cache it and update the BMC property
+if [ "${bios_version}" != "" ] ; then
+ if [ -f /var/cache/bios_version ] ; then
+ rm /var/cache/bios_version
+ fi
+
+ echo "coreboot-${bios_version}" > /var/cache/bios_version
+fi
+
+if [ -f /var/cache/bios_version ] ; then
+ busctl set-property xyz.openbmc_project.Software.BMC.Updater \
+ /xyz/openbmc_project/software/bios_active \
+ xyz.openbmc_project.Software.Version Version s "$(cat /var/cache/bios_version)"
+fi
diff --git a/meta-ibm/meta-system1/recipes-phosphor/flash/phosphor-software-manager_%.bbappend b/meta-ibm/meta-system1/recipes-phosphor/flash/phosphor-software-manager_%.bbappend
new file mode 100644
index 0000000000..226181ac4e
--- /dev/null
+++ b/meta-ibm/meta-system1/recipes-phosphor/flash/phosphor-software-manager_%.bbappend
@@ -0,0 +1 @@
+RDEPENDS:${PN} += "bash flashrom bios-version"