Defect fix for DIMM VPD corruption
This commit has the fix for DIMM VPD corruption by moving
the EEPROM write pointer to a safe position.
(Safe position - 2048 'th byte for DIMM).
Test: Tested on rainier. Write pointer moved to the
desired location.
Signed-off-by: Priyanga Ramasamy <priyanga24@in.ibm.com>
Change-Id: Ibc567c4f242978532d865cf4af6c54e4fb12610e
diff --git a/ibm_vpd_app.cpp b/ibm_vpd_app.cpp
index 9464405..c5c1452 100644
--- a/ibm_vpd_app.cpp
+++ b/ibm_vpd_app.cpp
@@ -323,6 +323,31 @@
}
}
+/*API to reset EEPROM pointer to a safe position to avoid VPD corruption.
+ * Currently do reset only for DIMM VPD.*/
+static void resetEEPROMPointer(const nlohmann::json& js, const string& file,
+ ifstream& vpdFile)
+{
+ for (const auto& item : js["frus"][file])
+ {
+ if (item.find("extraInterfaces") != item.end())
+ {
+ if (item["extraInterfaces"].find(
+ "xyz.openbmc_project.Inventory.Item.Dimm") !=
+ item["extraInterfaces"].end())
+ {
+ // moves the EEPROM pointer to 2048 'th byte.
+ vpdFile.seekg(2047, std::ios::beg);
+ // Read that byte and discard - to affirm the move
+ // operation.
+ char ch;
+ vpdFile.read(&ch, sizeof(ch));
+ }
+ return;
+ }
+ }
+}
+
static Binary getVpdDataInVector(const nlohmann::json& js, const string& file)
{
uint32_t offset = 0;
@@ -348,6 +373,8 @@
vpdFile.read(reinterpret_cast<char*>(&vpdVector[0]), maxVPDSize);
vpdVector.resize(vpdFile.gcount());
+ resetEEPROMPointer(js, file, vpdFile);
+
return vpdVector;
}