update sysfw version path for compatibility with new bios updater
The new BIOS updater[1] reads and writes the BIOS version from
/var/bios/host0_bios_version.txt. This change updates the version
path from /var/lib/fb-ipmi-oem/appData.json to
/var/bios/host0_bios_version.txt to ensure compatibility and allow the
new updater to retrieve the BIOS version correctly.
[1] https://gerrit.openbmc.org/c/openbmc/phosphor-bmc-code-mgmt/+/76101
Tested on Harma:
```
curl --silent $creds https://$bmc/redfish/v1/UpdateService/FirmwareInventory/Harma_BIOS_7246
{
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/Harma_BIOS_7246",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Description": "Unknown image",
"Id": "Harma_BIOS_7246",
"Name": "Software Inventory",
"Status": {
"Health": "Warning",
"HealthRollup": "OK",
"State": "Disabled"
},
"Updateable": true,
"Version": "F0M_2A08"
}
```
Signed-off-by: Kevin Tung <Kevin.Tung@quantatw.com>
Change-Id: If19b4b006961cd7514ac9556dfbf34845b7c1b74
diff --git a/src/usb-dbg.cpp b/src/usb-dbg.cpp
index 4e2847d..d125016 100644
--- a/src/usb-dbg.cpp
+++ b/src/usb-dbg.cpp
@@ -528,23 +528,20 @@
static int getBiosVer(std::string& ver, size_t hostPosition)
{
- nlohmann::json appObj;
-
- std::ifstream file(JSON_APP_DATA_FILE);
- if (file)
+ std::string sysfwVersionFile = std::format(SYSFW_VER_FILE, hostPosition);
+ std::ifstream file(sysfwVersionFile);
+ if (!file)
{
- file >> appObj;
- file.close();
- std::string version_key = KEY_SYSFW_VER + std::to_string(hostPosition);
-
- if (appObj.find(version_key) != appObj.end())
- {
- ver = appObj[version_key].get<std::string>();
- return 0;
- }
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Failed to open system firmware version file",
+ phosphor::logging::entry("FILE=%s", sysfwVersionFile.c_str()));
+ return -1;
}
- return -1;
+ std::getline(file, ver);
+ file.close();
+
+ return 0;
}
int sendBicCmd(uint8_t netFn, uint8_t cmd, uint8_t bicAddr,