support specifying MB FRU eeprom path
The MB FRUID should be exposed with ID 0 for BIOS to get the data to
fill out SMBIOS table during POST. However, current IDs depend on the
ordering of the FruDevice object paths.
(1) Using the object with "Type: EEPROM" and "Name: MB FRU" in the
EntityManager to figure out the MB FRU eeprom path. Other FRUIDs still
depend on the ordering of the FruDevice object paths.
example of the entity-manager config:
```
{
"Address": "$address",
"Bus": "$bus",
"Name": "MB FRU",
"Type": "EEPROM"
},
```
(2) For System GUID that BIOS populates into SMBIOS table during POST,
also use the MB FRU eeprom path instead of the hardcoding eeprom path.
Change-Id: If950c471f92b99180bab1a629d56d3a912d3b5f4
Signed-off-by: Cosmo Chou <cosmo.chou@quantatw.com>
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 3206a0a..8d1d0d5 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -1255,21 +1255,34 @@
int fd = -1;
ssize_t len;
int ret = 0;
+ std::string eepromPath = FRU_EEPROM;
+
+ // find the eeprom path of MB FRU
+ auto device = getMbFruDevice();
+ if (device)
+ {
+ auto [bus, address] = *device;
+ std::stringstream ss;
+ ss << "/sys/bus/i2c/devices/" << static_cast<int>(bus) << "-"
+ << std::setw(4) << std::setfill('0') << std::hex
+ << static_cast<int>(address) << "/eeprom";
+ eepromPath = ss.str();
+ }
errno = 0;
// Check if file is present
- if (access(FRU_EEPROM, F_OK) == -1)
+ if (access(eepromPath.c_str(), F_OK) == -1)
{
- std::cerr << "Unable to access: " << FRU_EEPROM << std::endl;
+ std::cerr << "Unable to access: " << eepromPath << std::endl;
return errno;
}
// Open the file
- fd = open(FRU_EEPROM, O_WRONLY);
+ fd = open(eepromPath.c_str(), O_WRONLY);
if (fd == -1)
{
- std::cerr << "Unable to open: " << FRU_EEPROM << std::endl;
+ std::cerr << "Unable to open: " << eepromPath << std::endl;
return errno;
}