Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,295 @@
From 21929dbc4fae5aa78be51ee389523f6cdb638759 Mon Sep 17 00:00:00 2001
From: "hliangs90" <hliangs90@gmail.com>
Date: Thu, 15 Aug 2024 13:11:23 +0800
Subject: [PATCH] Add CPLD Update for SoftWare Manager.
Signed-off-by: hliangs90 <hliangs90@gmail.com>
---
activation.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++++++
activation.hpp | 8 +++++
item_updater.cpp | 37 +++++++++++++++++++
item_updater.hpp | 19 ++++++++++
meson.build | 5 +++
meson_options.txt | 8 +++++
6 files changed, 169 insertions(+)
diff --git a/activation.cpp b/activation.cpp
index d9ee2d0..f866461 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -143,6 +143,23 @@ auto Activation::activation(Activations value) -> Activations
}
#endif
+#ifdef CPLD_UPGRADE
+ auto purposeTemp = parent.versions.find(versionId)->second->purpose();
+ if (purposeTemp == VersionPurpose::CPLD)
+ {
+ // Enable systemd signals
+ subscribeToSystemdSignals();
+
+ // Set initial progress
+ activationProgress->progress(20);
+
+ // Initiate image writing to flash
+ flashWriteCPLD();
+
+ return softwareServer::Activation::activation(value);
+ }
+#endif
+
activationProgress->progress(10);
parent.freeSpace(*this);
@@ -318,6 +335,15 @@ void Activation::unitStateChange(sdbusplus::message_t& msg)
}
#endif
+#ifdef CPLD_UPGRADE
+ auto purposeTemp = parent.versions.find(versionId)->second->purpose();
+ if (purposeTemp == VersionPurpose::CPLD)
+ {
+ onStateChangesCPLD(msg);
+ return;
+ }
+#endif
+
onStateChanges(msg);
return;
@@ -456,6 +482,72 @@ void Activation::onStateChangesBios(sdbusplus::message_t& msg)
#endif
+#ifdef CPLD_UPGRADE
+void Activation::flashWriteCPLD()
+{
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
+ auto cpldServiceFile = "obmc-flash-cpld@" + versionId + ".service";
+ method.append(cpldServiceFile, "replace");
+ try
+ {
+ auto reply = bus.call(method);
+ }
+ catch (const sdbusplus::exception_t& e)
+ {
+ error("Error in trying to upgrade CPLD: {ERROR}", "ERROR", e);
+ report<InternalFailure>();
+ }
+}
+
+void Activation::onStateChangesCPLD(sdbusplus::message_t& msg)
+{
+ uint32_t newStateID{};
+ sdbusplus::message::object_path newStateObjPath;
+ std::string newStateUnit{};
+ std::string newStateResult{};
+
+ // Read the msg and populate each variable
+ msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
+
+ auto cpldServiceFile = "obmc-flash-cpld@" + versionId + ".service";
+
+ if (newStateUnit == cpldServiceFile)
+ {
+ // unsubscribe to systemd signals
+ unsubscribeFromSystemdSignals();
+
+ if (newStateResult == "done")
+ {
+ // Set activation progress to 100
+ activationProgress->progress(100);
+
+ // Set Activation value to active
+ activation(softwareServer::Activation::Activations::Active);
+
+ info("CPLD upgrade completed successfully.");
+ parent.cpldVersion->version(
+ parent.versions.find(versionId)->second->version());
+
+ // Delete the uploaded activation
+ boost::asio::post(getIOContext(), [this]() {
+ this->parent.erase(this->versionId);
+ });
+ }
+ else if (newStateResult == "failed")
+ {
+ // Set Activation value to Failed
+ activation(softwareServer::Activation::Activations::Failed);
+
+ error("CPLD upgrade failed.");
+ }
+ }
+
+ return;
+}
+
+#endif
+
void Activation::rebootBmc()
{
auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
diff --git a/activation.hpp b/activation.hpp
index 94cc1bb..7d10472 100644
--- a/activation.hpp
+++ b/activation.hpp
@@ -247,6 +247,14 @@ class Activation : public ActivationInherit, public Flash
void onStateChangesBios(sdbusplus::message_t&);
#endif
+#ifdef CPLD_UPGRADE
+ /* @brief write to CPLD flash function */
+ void flashWriteCPLD();
+
+ /** @brief Function that acts on CPLD upgrade service file state changes */
+ void onStateChangesCPLD(sdbusplus::message_t&);
+#endif
+
/** @brief Overloaded function that acts on service file state changes */
void onStateChanges(sdbusplus::message_t&) override;
diff --git a/item_updater.cpp b/item_updater.cpp
index 5613a49..76f72d4 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -71,6 +71,9 @@ void ItemUpdater::createActivation(sdbusplus::message_t& msg)
if (value == VersionPurpose::BMC ||
#ifdef HOST_BIOS_UPGRADE
value == VersionPurpose::Host ||
+#endif
+#ifdef CPLD_UPGRADE
+ value == VersionPurpose::CPLD ||
#endif
value == VersionPurpose::System)
{
@@ -879,6 +882,40 @@ void ItemUpdater::createBIOSObject()
}
#endif
+#ifdef CPLD_UPGRADE
+void ItemUpdater::createCPLDObject()
+{
+ std::string path = CPLD_OBJPATH;
+ // Get version id from last item in the path
+ auto pos = path.rfind("/");
+ if (pos == std::string::npos)
+ {
+ error("No version id found in object path {PATH}", "PATH", path);
+ return;
+ }
+
+ createActiveAssociation(path);
+ createFunctionalAssociation(path);
+
+ auto versionId = path.substr(pos + 1);
+ auto version = "null";
+ AssociationList assocs = {};
+ cpldActivation = std::make_unique<Activation>(
+ bus, path, *this, versionId, server::Activation::Activations::Active,
+ assocs);
+ auto dummyErase = [](std::string /*entryId*/) {
+ // Do nothing;
+ };
+ cpldVersion = std::make_unique<VersionClass>(
+ bus, path, version, VersionPurpose::CPLD, "", "",
+ std::vector<std::string>(),
+ std::bind(dummyErase, std::placeholders::_1), "");
+ cpldVersion->deleteObject =
+ std::make_unique<phosphor::software::manager::Delete>(bus, path,
+ *cpldVersion);
+}
+#endif
+
void ItemUpdater::getRunningSlot()
{
// Check /run/media/slot to get the slot number
diff --git a/item_updater.hpp b/item_updater.hpp
index c50d9de..26b657d 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -67,6 +67,9 @@ class ItemUpdater : public ItemUpdaterInherit
restoreFieldModeStatus();
#ifdef HOST_BIOS_UPGRADE
createBIOSObject();
+#endif
+#ifdef CPLD_UPGRADE
+ createCPLDObject();
#endif
emit_object_added();
};
@@ -280,6 +283,22 @@ class ItemUpdater : public ItemUpdaterInherit
std::unique_ptr<VersionClass> biosVersion;
#endif
+#ifdef CPLD_UPGRADE
+ /** @brief Create the CPLD object without knowing the version.
+ *
+ * The object is created only to provide the DBus access so that an
+ * external service could set the correct CPLD version.
+ * On CPLD code update, the version is updated accordingly.
+ */
+ void createCPLDObject();
+
+ /** @brief Persistent Activation D-Bus object for CPLD */
+ std::unique_ptr<Activation> cpldActivation;
+
+ public:
+ /** @brief Persistent Version D-Bus object for CPLD */
+ std::unique_ptr<VersionClass> cpldVersion;
+#endif
/** @brief Get the slot number of running image */
void getRunningSlot();
};
diff --git a/meson.build b/meson.build
index 41adfde..509d9f7 100644
--- a/meson.build
+++ b/meson.build
@@ -67,6 +67,7 @@ conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
# Configurable features
conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
+conf.set('CPLD_UPGRADE', get_option('cpld-upgrade').enabled())
conf.set('WANT_SIGNATURE_VERIFY', \
get_option('verify-signature').enabled() or \
get_option('verify-full-signature').enabled())
@@ -96,6 +97,10 @@ if get_option('host-bios-upgrade').enabled()
conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path'))
endif
+if get_option('cpld-upgrade').enabled()
+ conf.set_quoted('CPLD_OBJPATH', get_option('cpld-object-path'))
+endif
+
if get_option('bmc-static-dual-image').enabled()
conf.set('BMC_STATIC_DUAL_IMAGE', get_option('bmc-static-dual-image').enabled())
conf.set_quoted('ALT_ROFS_DIR', get_option('alt-rofs-dir'))
diff --git a/meson_options.txt b/meson_options.txt
index d14ed3b..d638c93 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -11,6 +11,8 @@ option('bmc-layout', type: 'combo',
# Features
option('host-bios-upgrade', type: 'feature', value: 'enabled',
description: 'Enable host bios upgrade support.')
+option('cpld-upgrade', type: 'feature', value: 'enabled',
+ description: 'Enable cpld upgrade support.')
option('sync-bmc-files', type: 'feature', value: 'enabled',
description: 'Enable sync of filesystem files.')
@@ -121,6 +123,12 @@ option(
description: 'The BIOS DBus object path.',
)
+option(
+ 'cpld-object-path', type: 'string',
+ value: '/xyz/openbmc_project/software/cpld_active',
+ description: 'The CPLD DBus object path.',
+)
+
option('bmc-static-dual-image', type: 'feature', value: 'enabled',
description: 'Enable the dual image support for static layout.')
--
2.25.1
@@ -0,0 +1,78 @@
From 88d810c49f7101a8bb46b2a1af17626bd61a5d07 Mon Sep 17 00:00:00 2001
From: roly <Rolyli.Li@luxshare-ict.com>
Date: Wed, 18 Dec 2024 13:55:03 +0800
Subject: [PATCH] Detect boot image source
---
detect-slot-aspeed | 21 +++++++++++++++++----
reset-cs0-aspeed | 12 +++++++++++-
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/detect-slot-aspeed b/detect-slot-aspeed
index 231eb33..6631722 100644
--- a/detect-slot-aspeed
+++ b/detect-slot-aspeed
@@ -1,16 +1,29 @@
#!/bin/bash
set -eo pipefail
-# Check the /sys/class/watchdog/watchdog1/access_cs0 and tell if it's running on the primary or the secondary flash.
-
-ACCESS_CS0="/sys/class/watchdog/watchdog1/access_cs0"
SLOT_FILE="/run/media/slot"
+if [ -f ${SLOT_FILE} ]; then
+ # Slot info already detected
+ exit 0
+fi
+
+# Check the sysfs attribute and tell if it's running on the primary or the secondary flash.
+SOC_FAMILY=$(cat /sys/bus/soc/devices/soc0/family)
+if [ "${SOC_FAMILY}" = "AST2500" ]; then
+ ACCESS_PRIMARY="/sys/class/watchdog/watchdog1/access_cs0"
+elif [ "${SOC_FAMILY}" = "AST2600" ]; then
+ ACCESS_PRIMARY="/sys/devices/platform/ahb/1e620000.spi/access_primary"
+else
+ echo "SOC Family is neither AST2500 nor AST2600"
+ exit 1
+fi
+
# Create directory if not exist
mkdir -p "$(dirname "${SLOT_FILE}")"
# Write slot info
-if [ -f ${ACCESS_CS0} ]; then
+if [ -f ${ACCESS_PRIMARY} ]; then
echo "1" > ${SLOT_FILE}
else
echo "0" > ${SLOT_FILE}
diff --git a/reset-cs0-aspeed b/reset-cs0-aspeed
index e2cf1e0..e761e77 100644
--- a/reset-cs0-aspeed
+++ b/reset-cs0-aspeed
@@ -11,11 +11,21 @@ SHUTDOWN_EXTRA_SCRIPT="/run/initramfs/shutdown_task_after_umount"
cat <<'EOF' >"${SHUTDOWN_EXTRA_SCRIPT}"
#!/bin/sh
-ACCESS_CS0="/sys/class/watchdog/watchdog1/access_cs0"
+
+ACCESS_CS0=""
+
+SOC_FAMILY=$(cat /sys/bus/soc/devices/soc0/family)
+if [ "${SOC_FAMILY}" = "AST2500" ]; then
+ ACCESS_CS0="/sys/class/watchdog/watchdog1/access_cs0"
+elif [ "${SOC_FAMILY}" = "AST2600" ]; then
+ ACCESS_CS0="/sys/devices/platform/ahb/1e620000.spi/access_primary"
+fi
+
if [ -f "${ACCESS_CS0}" ]; then
echo "Reset aspeed chip select"
echo 1 > "${ACCESS_CS0}"
fi
+
EOF
chmod +x "${SHUTDOWN_EXTRA_SCRIPT}"
--
2.25.1
@@ -0,0 +1,192 @@
From f96d61f5a96db2deaf34f5ca38b77b3d18704ae6 Mon Sep 17 00:00:00 2001
From: "alex-hl.huang" <alex-hl.huang@luxshare-ict.com>
Date: Thu, 17 Feb 2022 13:52:46 +0800
Subject: [PATCH] add shell script for generate cpld image tar
---
gen-cpld-tar | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 176 insertions(+)
create mode 100755 gen-cpld-tar
diff --git a/gen-cpld-tar b/gen-cpld-tar
new file mode 100755
index 0000000..d0d59c6
--- /dev/null
+++ b/gen-cpld-tar
@@ -0,0 +1,176 @@
+#!/bin/bash
+set -eo pipefail
+
+help=$'Generate Tarball with Cpld image and MANIFEST Script
+
+Generates a Cpld image tarball from given file as input.
+Creates a MANIFEST for image verification and recreation
+Packages the image and MANIFEST together in a tarball
+
+usage: gen-Cpld-tar [OPTION] <Cpld FILE>...
+
+Options:
+-o, --out <file> Specify destination file. Defaults to
+`pwd`/obmc-cpld.tar.gz if unspecified.
+-s, --sign <path> Sign the image. The optional path argument specifies
+the private key file. Defaults to the bash variable
+PRIVATE_KEY_PATH if available, or else uses the
+open-source private key in this script.
+-m, --machine <name> Optionally specify the target machine name of this
+image.
+-v, --version <name> Specify the version of Cpld image file
+-h, --help Display this help text and exit.
+'
+
+#################################################################
+# It's the OpenBMC "public" private key (currently under
+# meta-phosphor/recipes-phosphor/flash/files/OpenBMC.priv):
+# https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/8949/15/
+# meta-phosphor/common/recipes-phosphor/flash/files/OpenBMC.priv
+#
+#################################################################
+private_key=$'-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAPvSDLu6slkP1gri
+PaeQXL9ysD69J/HjbBCIQ0RPfeWBb75US1tRTjPP0Ub8CtH8ExVf8iF1ulsZA78B
+zIjBYZVp9pyD6LbpZ/hjV7rIH6dTNhoVpdA+F8LzmQ7cyhHG8l2JMvdunwF2uX5k
+D4WDcZt/ITKZNQNavPtmIyD5HprdAgMBAAECgYEAuQkTSi5ZNpAoWz76xtGRFSwU
+zUT4wQi3Mz6tDtjKTYXasiQGa0dHC1M9F8fDu6BZ9W7W4Dc9hArRcdzEighuxoI/
+nZI/0uL89iUEywnDEIHuS6D5JlZaj86/nx9YvQnO8F/seM+MX0EAWVrd5wC7aAF1
+h6Fu7ykZB4ggUjQAWwECQQD+AUiDOEO+8btLJ135dQfSGc5VFcZiequnKWVm6uXt
+rX771hEYjYMjLqWGFg9G4gE3GuABM5chMINuQQUivy8tAkEA/cxfy19XkjtqcMgE
+x/UDt6Nr+Ky/tk+4Y65WxPRDas0uxFOPk/vEjgVmz1k/TAy9G4giisluTvtmltr5
+DCLocQJBAJnRHx9PiD7uVhRJz6/L/iNuOzPtTsi+Loq5F83+O6T15qsM1CeBMsOw
+cM5FN5UeMcwz+yjfHAsePMkcmMaU7jUCQHlg9+N8upXuIo7Dqj2zOU7nMmkgvSNE
+5yuNImRZabC3ZolwaTdd7nf5r1y1Eyec5Ag5yENV6JKPe1Xkbb1XKJECQDngA0h4
+6ATvfP1Vrx4CbP11eKXbCsZ9OGPHSgyvVjn68oY5ZP3uPsIattoN7dE2BRfuJm7m
+F0nIdUAhR0yTfKM=
+-----END PRIVATE KEY-----
+'
+
+do_sign=false
+PRIVATE_KEY_PATH=${PRIVATE_KEY_PATH:-}
+private_key_path="${PRIVATE_KEY_PATH}"
+outfile=""
+machine=""
+version=""
+default_cpld_name="cpld.svf"
+while [[ $# -gt 0 ]]; do
+ key="$1"
+ case $key in
+ -o|--out)
+ outfile="$2"
+ shift 2
+ ;;
+ -s|--sign)
+ do_sign=true
+ if [[ -n "${2}" && "${2}" != -* ]]; then
+ private_key_path="$2"
+ shift 2
+ else
+ shift 1
+ fi
+ ;;
+ -m|--machine)
+ machine="$2"
+ shift 2
+ ;;
+ -v|--version)
+ version="$2"
+ shift 2
+ ;;
+ -h|--help)
+ echo "$help"
+ exit
+ ;;
+ -*)
+ echo "Unrecognised option $1"
+ echo "$help"
+ exit
+ ;;
+ *)
+ file="$1"
+ shift 1
+ ;;
+ esac
+done
+
+if [ ! -f "${file}" ]; then
+ echo "${file} not found, Please enter a valid Cpld image file"
+ echo "$help"
+ exit 1
+else
+ cp "$file" $default_cpld_name
+ echo "$file"
+fi
+
+if [[ -z $version ]]; then
+ echo "Please provide version of image with -v option"
+ exit 1
+fi
+
+if [[ -z $outfile ]]; then
+ outfile=$(pwd)/obmc-cpld.tar.gz
+else
+ if [[ $outfile != /* ]]; then
+ outfile=$(pwd)/$outfile
+ fi
+fi
+
+scratch_dir=$(mktemp -d)
+# Remove the temp directory on exit.
+# The files in the temp directory may contain read-only files, so add
+# --interactive=never to skip the prompt.
+trap '{ rm -r --interactive=never ${scratch_dir}; }' EXIT
+
+if [[ "${do_sign}" == true ]]; then
+ if [[ -z "${private_key_path}" ]]; then
+ private_key_path=${scratch_dir}/OpenBMC.priv
+ echo "${private_key}" > "${private_key_path}"
+ echo "Image is NOT secure!! Signing with the open private key!"
+ else
+ if [[ ! -f "${private_key_path}" ]]; then
+ echo "Couldn't find private key ${private_key_path}."
+ exit 1
+ fi
+
+ echo "Signing with ${private_key_path}."
+ fi
+
+ public_key_file=publickey
+ public_key_path=${scratch_dir}/$public_key_file
+ openssl pkey -in "${private_key_path}" -pubout -out "${public_key_path}"
+fi
+
+manifest_location="MANIFEST"
+files_to_sign="$manifest_location $public_key_file"
+
+# Go to scratch_dir
+cp "${file}" "${scratch_dir}"
+cd "${scratch_dir}"
+mv "${file}" ${default_cpld_name}
+file=${default_cpld_name}
+files_to_sign+=" $(basename ${file})"
+
+echo "Creating MANIFEST for the image"
+echo -e "purpose=xyz.openbmc_project.Software.Version.VersionPurpose.CPLD\n\
+version=$version" > $manifest_location
+
+if [[ -n "${machine}" ]]; then
+ echo -e "MachineName=${machine}" >> $manifest_location
+fi
+
+if [[ "${do_sign}" == true ]]; then
+ private_key_name=$(basename "${private_key_path}")
+ key_type="${private_key_name%.*}"
+ echo KeyType="${key_type}" >> $manifest_location
+ echo HashType="RSA-SHA256" >> $manifest_location
+
+ for file in $files_to_sign; do
+ openssl dgst -sha256 -sign "${private_key_path}" -out "${file}.sig" "$file"
+ done
+
+ additional_files="*.sig"
+fi
+# shellcheck disable=SC2086
+tar -czvf $outfile $files_to_sign $additional_files
+echo "Cpld image tarball is at $outfile"
@@ -0,0 +1,128 @@
#!/bin/bash
bios_image=$(ls $1/*.bin)
bios_mtd="/dev/mtd/bios"
bios_id=$(basename "$1")
bios_slot=""
power_obj="xyz.openbmc_project.State.Chassis"
power_path="/xyz/openbmc_project/state/chassis0"
power_intf="xyz.openbmc_project.State.Chassis"
power_prop="CurrentPowerState"
update_obj="xyz.openbmc_project.Software.BMC.Updater"
update_path="/xyz/openbmc_project/software/"
target_intf="xyz.openbmc_project.Software.UpdateTarget"
target_prop="UpdateTargetSlot"
check_env() {
echo "[Info]: Check Environment."
#check power status. if On, set to Off.
#power_status=$(busctl get-property $power_obj $power_path $power_intf $power_prop)
#if [[ $power_status == *On* ]]; then
# busctl set-property $power_obj $power_path $power_intf RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.Off
#fi
sleep 10
#add other action to prepare flash bios.
bios_slot=$(busctl get-property $update_obj $update_path$bios_id $target_intf $target_prop)
bios_slot=$(echo "$bios_slot" |cut -d "\"" -f2)
if [ "$bios_slot" = "xyz.openbmc_project.Software.UpdateTarget.TargetSlot.Primary" ]; then
bios_slot="Primary"
elif [ "$bios_slot" = "xyz.openbmc_project.Software.UpdateTarget.TargetSlot.Secondary" ]; then
bios_slot="Backup"
elif [ "$bios_slot" = "xyz.openbmc_project.Software.UpdateTarget.TargetSlot.Both" ]; then
bios_slot="Both"
fi
}
switch_primary_flash_to_bmc() {
echo "[Info]: Switch Main BIOS Flash To BMC."
if [ -d /sys/bus/platform/drivers/spi-aspeed-smc/1e630000.spi ]; then
echo -n "1e630000.spi" > /sys/bus/platform/drivers/spi-aspeed-smc/unbind
fi
#Set Mux to bmc.
i2ctransfer -y -a 0 w3@0x0d 0xa0 0x03 0x80
#Switch to primary BIOS flash
i2ctransfer -y -a 0 w3@0x0d 0xa1 0x03 0x80
#mount bios flash to BMC
echo -n "1e630000.spi" > /sys/bus/platform/drivers/spi-aspeed-smc/bind
sleep 5
cat /proc/mtd
}
switch_secondary_flash_to_bmc() {
echo "[Info]: Switch Backup BIOS Flash To BMC."
if [ -d /sys/bus/platform/drivers/spi-aspeed-smc/1e630000.spi ]; then
echo -n "1e630000.spi" > /sys/bus/platform/drivers/spi-aspeed-smc/unbind
fi
#Set Mux to bmc.
i2ctransfer -y -a 0 w3@0x0d 0xa0 0x03 0x80
#Switch to backup BIOS flash
i2ctransfer -y -a 0 w3@0x0d 0xa1 0x03 0x40
#mount bios flash to BMC
echo -n "1e630000.spi" > /sys/bus/platform/drivers/spi-aspeed-smc/bind
sleep 5
cat /proc/mtd
}
flash_bios() {
echo "[Info]: Flash BIOS."
#Which flash need to be update, e.g. get for Manifest or Settings.
# bios_update_select=
#Check MTD Exist
if [[ ! -e $bios_mtd ]]; then
echo "[Error]: bios flash not found in $bios_mtd"
exit 3
fi
echo "[Info]: bios_image=$bios_image"
echo "[Info]: bios_mtd=$bios_mtd"
echo "/usr/sbin/flashcp $bios_image $bios_mtd"
/usr/sbin/flashcp $bios_image $bios_mtd
}
switch_flash_to_cpu() {
echo "[Info]: Switch Main BIOS Flash To CPU."
echo -n "1e630000.spi" > /sys/bus/platform/drivers/spi-aspeed-smc/unbind
sleep 5
#Set Mux to CPU.
i2ctransfer -y -a 0 w3@0x0d 0xa0 0x03 0x00
}
power_on_system() {
echo "[Info]: Power On System After Update BIOS."
#check power status. if Off, set to On.
power_status=$(busctl get-property $power_obj $power_path $power_intf $power_prop)
if [[ $power_status == *Off* ]]; then
sleep 5
busctl set-property $power_obj $power_path $power_intf RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.On
fi
}
check_env
if [ "$bios_slot" = "Primary" ]; then
switch_primary_flash_to_bmc
flash_bios
elif [ "$bios_slot" = "Backup" ]; then
switch_secondary_flash_to_bmc
flash_bios
elif [ "$bios_slot" = "Both" ]; then
switch_primary_flash_to_bmc
flash_bios
sleep 5
switch_secondary_flash_to_bmc
flash_bios
fi
switch_flash_to_cpu
#power_on_system
sleep 5
@@ -0,0 +1,29 @@
#!/bin/bash
cpld_image=$(ls $1/*.svf)
jtag_node="/dev/jtag1"
check_env() {
echo "[Info]: Check Environment."
#add action to prepare flash cpld.
#check cpld exist ?
}
flash_cpld() {
echo "[Info]: Flash CPLD."
echo "[Info]: Switch CPLD JTAG mux to BMC."
gpioset 0 124=1
gpioset 0 122=0
echo "[Info]: CPLD Image:$cpld_image"
/usr/bin/svf -n $jtag_node -s -p $cpld_image
}
enable_new_fw() {
echo "[Info]: Enable New Firmware."
}
check_env
flash_cpld
enable_new_fw
@@ -0,0 +1,9 @@
[Unit]
Description=Flash image %I to CPLD
[Service]
Type=oneshot
RemainAfterExit=no
ExecStartPre=/bin/sh -c 'touch /tmp/mbcpld_update_status'
ExecStart=/usr/bin/flashcpld /tmp/images/%i
ExecStopPost=/bin/sh -c 'echo $EXIT_STATUS > /tmp/mbcpld_update_status'
@@ -0,0 +1,9 @@
[Unit]
Description=Flash Host Bios image %I to Host
[Service]
Type=oneshot
RemainAfterExit=no
ExecStartPre=/bin/sh -c 'touch /tmp/bios_update_status'
ExecStart=/usr/bin/flashbios /tmp/images/%i
ExecStopPost=/bin/sh -c 'echo $EXIT_STATUS > /tmp/bios_update_status'