summaryrefslogtreecommitdiff
path: root/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/sila-flash-bios/flash-bios
diff options
context:
space:
mode:
Diffstat (limited to 'meta-ibs/meta-cp2-5422/recipes-phosphor/flash/sila-flash-bios/flash-bios')
-rw-r--r--meta-ibs/meta-cp2-5422/recipes-phosphor/flash/sila-flash-bios/flash-bios169
1 files changed, 169 insertions, 0 deletions
diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/sila-flash-bios/flash-bios b/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/sila-flash-bios/flash-bios
new file mode 100644
index 0000000000..0ad86deef4
--- /dev/null
+++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/sila-flash-bios/flash-bios
@@ -0,0 +1,169 @@
+#!/bin/bash
+
+set -eo pipefail
+
+programm=`basename $0`
+
+log() {
+ logger -t ${programm} -p 1 "$@"
+}
+
+FWTYPE="BIOS"
+FWVER="0.00"
+redfish_log_fw_evt() {
+ local evt=$1
+ [ -z "$FWTYPE" ] && return
+ [ -z "$FWVER" ] && return
+ case "$evt" in
+ start)
+ logger -t ${programm} -p 1 "${FWTYPE} firmware update to version ${FWVER} started"
+ ;;
+ success)
+ logger -t ${programm} -p 1 "${FWTYPE} firmware update to version ${FWVER} completed successfully."
+ ;;
+ abort)
+ logger -t ${programm} -p 1 "${FWTYPE} firmware update to version ${FWVER} failed."
+ ;;
+ invalid_args)
+ logger -t ${programm} -p 1 "${FWTYPE} firmware update failed: Invalid argument"
+ ;;
+ invalid_image)
+ logger -t ${programm} -p 1 "${FWTYPE} firmware update failed: Invalid firmware image"
+ ;;
+ *) return ;;
+ esac
+}
+
+wait_for_log_sync()
+{
+ sync
+ sleep 5
+}
+
+interface=xyz.openbmc_project.Software.BMC.Updater
+busctl_path=
+bios_image=
+bios_version=
+bios_ext_version=
+
+get_firmware_busctl_path() {
+ local ipath=$1
+ local bpath=/xyz/openbmc_project/software/`echo "${ipath}" | rev | cut -f1 -d'/' | rev`
+ echo "${bpath}"
+}
+
+get_firmware_purpose() {
+ local iface=$1
+ local fwpath=$2
+ local purpose=`busctl get-property ${iface} ${fwpath} xyz.openbmc_project.Software.Version Purpose | sed 's,^s ",,' | sed 's,"$,,' | rev | cut -f1 -d'.' | rev`
+ echo "${purpose}"
+}
+
+get_firmware_activation() {
+ local iface=$1
+ local fwpath=$2
+ local activation=`busctl get-property ${iface} ${fwpath} xyz.openbmc_project.Software.Activation Activation | sed 's,^s ",,' | sed 's,"$,,' | rev | cut -f1 -d'.' | rev`
+ echo "${activation}"
+}
+
+get_firmware_path() {
+ local iface=$1
+ local fwpath=$2
+ local path=`busctl get-property ${iface} ${fwpath} xyz.openbmc_project.Common.FilePath Path | sed 's,^s ",,' | sed 's,"$,,'`
+ echo "${path}"
+}
+
+get_firmware_version() {
+ local iface=$1
+ local fwpath=$2
+ local version=`busctl get-property ${iface} ${fwpath} xyz.openbmc_project.Software.Version Version | sed 's,^s ",,' | sed 's,"$,,'`
+ echo "${version}"
+}
+
+get_firmware_extended_version() {
+ local iface=$1
+ local fwpath=$2
+ local eversion=`busctl get-property ${iface} ${fwpath} xyz.openbmc_project.Software.ExtendedVersion ExtendedVersion | sed 's,^s ",,' | sed 's,"$,,'`
+ echo "${eversion}"
+}
+
+get_firmware_file_name() {
+ local iface=$1
+ local fwpath=$2
+ local fname=`busctl get-property ${iface} ${fwpath} xyz.openbmc_project.Inventory.Decorator.Compatible Names | grep "as 1" | sed 's,^as 1 ",,' | sed 's,"$,,'`
+ echo "${fname}"
+}
+
+get_bios_image() {
+ local iface=$1
+ local bpath=$2
+ local purpose=`get_firmware_purpose ${iface} ${bpath}`
+ local active=`get_firmware_activation ${iface} ${bpath}`
+ if [ "${purpose}" = "Host" -a "${active}" = "Activating" ] ; then
+ local path=`get_firmware_path ${iface} ${bpath}`
+ local fname=`get_firmware_file_name ${iface} ${bpath}`
+ if [ -f "${path}/${fname}" ] ; then
+ echo "${path}/${fname}"
+ fi
+ fi
+}
+
+get_bios_version() {
+ local image=$1
+ local hash=`echo ${image} | rev | cut -f2 -d'/' | rev`
+ local version=`get_firmware_version ${interface} /xyz/openbmc_project/software/${hash}`
+ echo "${version}"
+}
+
+get_bios_extended_version() {
+ local image=$1
+ local hash=`echo ${image} | rev | cut -f2 -d'/' | rev`
+ local ext_version=`get_firmware_extended_version ${interface} /xyz/openbmc_project/software/${hash}`
+ echo "${ext_version}"
+}
+
+
+image_path=$1
+
+if [ "x${image_path}" = "x" ] ; then
+ redfish_log_fw_evt invalid_args
+ exit 1
+fi
+
+busctl_path="`get_firmware_busctl_path ${image_path}`"
+bios_image="`get_bios_image ${interface} ${busctl_path}`"
+bios_version="`get_bios_version ${bios_image}`"
+bios_ext_version="`get_bios_extended_version ${bios_image}`"
+
+if [ "${bios_image}" = "x" ] ; then
+ redfish_log_fw_evt invalid_image
+ exit 1
+fi
+if [ "${bios_version}" = "x" ] ; then
+ redfish_log_fw_evt invalid_image
+ exit 1
+fi
+
+FWVER="${bios_version}"
+
+#######################
+# Start BIOS Flashing:
+#
+redfish_log_fw_evt start
+
+
+#######################
+# main routine:
+#
+logger -t ${programm} -p 1 "Flashing the '${bios_image}' image..."
+#
+# end of main routine.
+#######################
+
+
+#######################
+# Stop BIOS Flashing:
+#
+redfish_log_fw_evt success
+wait_for_log_sync
+