From 8c52511bc93b744d5d184308c2bb7c078af33c4a Mon Sep 17 00:00:00 2001 From: Nikita Kosenkov Date: Thu, 22 Sep 2022 12:52:11 +0300 Subject: phosphor-ipmi-host: Added set and save BIOS version --- ...0002-Added-reading-BIOS-version-from-file.patch | 97 ++++++++++++++++++++++ .../flash/phosphor-software-manager_%.bbappend | 1 + .../0001-Add-set-BIOS-version-support.patch | 83 ++++++++++++++++++ .../ipmi/phosphor-ipmi-host_%.bbappend | 5 ++ 4 files changed, 186 insertions(+) create mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/flash/phosphor-software-manager/0002-Added-reading-BIOS-version-from-file.patch create mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/ipmi/phosphor-ipmi-host/0001-Add-set-BIOS-version-support.patch create mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend 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 +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( + 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( + bus, path, version, VersionPurpose::Host, "", "", + std::vector(), +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 +Date: Fri, 13 May 2022 10:30:14 +0800 +Subject: [PATCH] Add set BIOS version support + +Signed-off-by: Nikita Kosenkov +--- + 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(("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("Cannot get service for update version", ++ entry("ERROR=%s", e.what()), ++ entry("INTERFACE=%s", versionIntf)); ++ } ++ catch (sdbusplus::exception::SdBusError& e) ++ { ++ log("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("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 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 -- cgit v1.2.3