diff options
author | Nikita Kosenkov <NKosenkov@IBS.RU> | 2022-09-22 12:52:11 +0300 |
---|---|---|
committer | Nikita Kosenkov <NKosenkov@IBS.RU> | 2022-09-22 12:52:11 +0300 |
commit | 8c52511bc93b744d5d184308c2bb7c078af33c4a (patch) | |
tree | aa7d411d52e4f9a3f385acf2da0ab17b3af64403 /meta-ibs | |
parent | 20c98fe3cdc88a518c8375149076bfaf751f14a3 (diff) | |
download | openbmc-8c52511bc93b744d5d184308c2bb7c078af33c4a.tar.xz |
phosphor-ipmi-host: Added set and save BIOS version
Diffstat (limited to 'meta-ibs')
4 files changed, 186 insertions, 0 deletions
diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/phosphor-software-manager/0002-Added-reading-BIOS-version-from-file.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/phosphor-software-manager/0002-Added-reading-BIOS-version-from-file.patch new file mode 100644 index 0000000000..e1a395565b --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/phosphor-software-manager/0002-Added-reading-BIOS-version-from-file.patch @@ -0,0 +1,97 @@ +From ef7f6eb7107c2c7116ddc20de8d251d6a55db75f Mon Sep 17 00:00:00 2001 +From: Nikita Kosenkov <NKosenkov@IBS.RU> +Date: Thu, 22 Sep 2022 11:46:44 +0300 +Subject: [PATCH] Added reading BIOS version from file + +--- + item_updater.cpp | 9 ++++++++- + version.cpp | 11 +++++++++-- + version.hpp | 10 ++++++++++ + 3 files changed, 27 insertions(+), 3 deletions(-) + +diff --git a/item_updater.cpp b/item_updater.cpp +index 96782f2..48fb698 100644 +--- a/item_updater.cpp ++++ b/item_updater.cpp +@@ -849,7 +849,6 @@ void ItemUpdater::createBIOSObject() + createFunctionalAssociation(path); + + auto versionId = path.substr(pos + 1); +- auto version = "null"; + AssociationList assocs = {}; + biosActivation = std::make_unique<Activation>( + bus, path, *this, versionId, server::Activation::Activations::Active, +@@ -857,6 +856,14 @@ void ItemUpdater::createBIOSObject() + auto dummyErase = [](std::string /*entryId*/) { + // Do nothing; + }; ++ ++ auto version = VersionClass::getVersion( ++ "/var/lib/phosphor-bmc-code-mgmt/bios-release"); ++ if(version.empty()) ++ { ++ version = "null"; ++ } ++ + biosVersion = std::make_unique<VersionClass>( + bus, path, version, VersionPurpose::Host, "", "", + std::vector<std::string>(), +diff --git a/version.cpp b/version.cpp +index 847148e..523a855 100644 +--- a/version.cpp ++++ b/version.cpp +@@ -179,14 +179,14 @@ std::string Version::getBMCExtendedVersion(const std::string& releaseFilePath) + return extendedVersion; + } + +-std::string Version::getBMCVersion(const std::string& releaseFilePath) ++std::string Version::getVersion(const std::string& versionFilePath) + { + std::string versionKey = "VERSION_ID="; + std::string versionValue{}; + std::string version{}; + std::ifstream efile; + std::string line; +- efile.open(releaseFilePath); ++ efile.open(versionFilePath); + + while (getline(efile, line)) + { +@@ -216,6 +216,13 @@ std::string Version::getBMCVersion(const std::string& releaseFilePath) + } + efile.close(); + ++ return version; ++} ++ ++std::string Version::getBMCVersion(const std::string& releaseFilePath) ++{ ++ auto version = getVersion(releaseFilePath); ++ + if (version.empty()) + { + error("BMC current version is empty"); +diff --git a/version.hpp b/version.hpp +index 5c74f99..e8956fa 100644 +--- a/version.hpp ++++ b/version.hpp +@@ -150,6 +150,16 @@ class Version : public VersionInherit + static std::string + getBMCExtendedVersion(const std::string& releaseFilePath); + ++ /** ++ * @brief Get the active VERSION_ID string. ++ * ++ * @param[in] releaseFilePath - The path to the file which contains ++ * the release version string. ++ * ++ * @return The version string (e.g. v1.99.10-19). ++ */ ++ static std::string getVersion(const std::string& versionFilePath); ++ + /** + * @brief Get the active BMC version string. + * +-- +2.35.1 + diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/phosphor-software-manager_%.bbappend b/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/phosphor-software-manager_%.bbappend index aedba88044..60cad71b43 100644 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/phosphor-software-manager_%.bbappend +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/flash/phosphor-software-manager_%.bbappend @@ -5,6 +5,7 @@ PACKAGECONFIG:append = " verify_signature flash_bios" SRC_URI:append = " \ file://gen-bios-tarball \ file://0001-IBS-Use-usr-bin-flash-bios-tool-for-BIOS-update.patch \ + file://0002-Added-reading-BIOS-version-from-file.patch \ " EXTRA_OEMESON += "\ diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/ipmi/phosphor-ipmi-host/0001-Add-set-BIOS-version-support.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/ipmi/phosphor-ipmi-host/0001-Add-set-BIOS-version-support.patch new file mode 100644 index 0000000000..36cba8bc71 --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/ipmi/phosphor-ipmi-host/0001-Add-set-BIOS-version-support.patch @@ -0,0 +1,83 @@ +From 5faa6e4ced98082b10570eaa141381763f10be0b Mon Sep 17 00:00:00 2001 +From: Brian Ma <chma0@nuvoton.com> +Date: Fri, 13 May 2022 10:30:14 +0800 +Subject: [PATCH] Add set BIOS version support + +Signed-off-by: Nikita Kosenkov <NKosenkov@IBS.RU> +--- + apphandler.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 45 insertions(+) + +diff --git a/apphandler.cpp b/apphandler.cpp +index 8e47288..0fc9b2f 100644 +--- a/apphandler.cpp ++++ b/apphandler.cpp +@@ -52,6 +52,8 @@ static constexpr auto versionIntf = "xyz.openbmc_project.Software.Version"; + static constexpr auto activationIntf = + "xyz.openbmc_project.Software.Activation"; + static constexpr auto softwareRoot = "/xyz/openbmc_project/software"; ++static constexpr auto biosObjPath = "/xyz/openbmc_project/software/bios_active"; ++static constexpr auto biosFile = "/var/lib/phosphor-bmc-code-mgmt/bios-release"; + + void register_netfn_app_functions() __attribute__((constructor)); + +@@ -1419,6 +1421,46 @@ ipmi::RspType<uint8_t, // Parameter revision + return ipmi::responseSuccess(paramRevision, setSelector, configData); + } + ++void handleFirmwareVersion(uint8_t paramSelector, std::string version){ ++ // only handle FW version ++ if (paramSelector != IPMI_SYSINFO_SYSTEM_FW_VERSION) ++ { ++ return; ++ } ++ sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; ++ ++ log<level::INFO>(("ipmid get BIOS version:" + version).c_str()); ++ ++ // update host version to software manager ++ std::string service; ++ try ++ { ++ service = ipmi::getService(bus, versionIntf, biosObjPath); ++ ipmi::setDbusProperty(bus, service, biosObjPath, versionIntf, ++ "Version", version); ++ } ++ catch (const std::runtime_error& e) ++ { ++ log<level::ERR>("Cannot get service for update version", ++ entry("ERROR=%s", e.what()), ++ entry("INTERFACE=%s", versionIntf)); ++ } ++ catch (sdbusplus::exception::SdBusError& e) ++ { ++ log<level::ERR>("sdbusplus exception - Unable to update BIOS version", ++ entry("ERROR=%s", e.what()), ++ entry("INTERFACE=%s", versionIntf), ++ entry("SERVICE=%s", service.c_str())); ++ } ++ // write version file to storage ++ log<level::DEBUG>("write BIOS version file."); ++ std::ofstream myfile(biosFile, std::ofstream::out); ++ std::string ver = "VERSION_ID=\"" + version + "\""; ++ myfile << ver << std::endl; ++ myfile.close(); ++} ++ ++ + ipmi::RspType<> ipmiAppSetSystemInfo(uint8_t paramSelector, uint8_t data1, + std::vector<uint8_t> configData) + { +@@ -1508,6 +1550,9 @@ ipmi::RspType<> ipmiAppSetSystemInfo(uint8_t paramSelector, uint8_t data1, + std::copy_n(configData.begin(), count, paramString.begin() + offset); + } + sysInfoParamStore->update(paramSelector, paramString); ++ ++ // update BIOS version ++ handleFirmwareVersion(paramSelector, paramString); + return ipmi::responseSuccess(); + } + +-- +2.35.1 + diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend b/meta-ibs/meta-cp2-5422/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend new file mode 100644 index 0000000000..e776ab54c9 --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend @@ -0,0 +1,5 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI:append = " \ + file://0001-Add-set-BIOS-version-support.patch \ + "
\ No newline at end of file |