diff options
| author | Lei YU <mine260309@gmail.com> | 2019-02-26 17:27:23 +0800 |
|---|---|---|
| committer | Lei YU <mine260309@gmail.com> | 2019-03-13 11:01:53 +0800 |
| commit | 6cecc9b4a8e11327b5c59924c2865da5865f7d7d (patch) | |
| tree | 659822cffd11a2d22e92a13ceda57f7a10969241 | |
| parent | a7b4adee12a944d3d937fdf05c56ed58a1cd3cf9 (diff) | |
| download | openpower-pnor-code-mgmt-6cecc9b4a8e11327b5c59924c2865da5865f7d7d.tar.gz openpower-pnor-code-mgmt-6cecc9b4a8e11327b5c59924c2865da5865f7d7d.zip | |
Static layout: Use pflash to get partitions to clear
Use pflash -i to get partitions that should be cleared during factory
reset, instead of hard-coded ones.
Tested: From log verify the partitions with REPROVISION flag are cleared
during factory reset.
Change-Id: I5f1681d0c5092e89a4a964ce41991b116252b9dd
Signed-off-by: Lei YU <mine260309@gmail.com>
| -rw-r--r-- | static/item_updater_static.cpp | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/static/item_updater_static.cpp b/static/item_updater_static.cpp index 023425507..628f824f4 100644 --- a/static/item_updater_static.cpp +++ b/static/item_updater_static.cpp @@ -114,11 +114,11 @@ std::string getPNORVersion() return version; } -inline void pnorClear(const std::string& part, bool shouldEcc = true) +void pnorClear(const std::string& part, bool shouldEcc = true) { int rc; std::tie(rc, std::ignore) = - pflash("-P", part, shouldEcc ? "-c" : "-e", "-f >/dev/null"); + utils::pflash("-P", part, shouldEcc ? "-c" : "-e", "-f >/dev/null"); if (rc != 0) { log<level::ERR>("Failed to clear partition", @@ -132,6 +132,42 @@ inline void pnorClear(const std::string& part, bool shouldEcc = true) } } +// The pair contains the partition name and if it should use ECC clear +using PartClear = std::pair<std::string, bool>; + +std::vector<PartClear> getPartsToClear(const std::string& info) +{ + std::vector<PartClear> ret; + std::istringstream iss(info); + std::string line; + + while (std::getline(iss, line)) + { + // Each line looks like + // ID=06 MVPD 0x0012d000..0x001bd000 (actual=0x00090000) [E--P--F-C-] + // Flag 'F' means REPROVISION + // Flag 'C' means CLEARECC + auto flags = line.substr(line.find('[')); + if (flags.find('F') != std::string::npos) + { + // This is a partition to be cleared + line = line.substr(line.find_first_of(' ')); // Skiping "ID=xx" + line = line.substr(line.find_first_not_of(' ')); // Skipping spaces + line = line.substr(0, line.find_first_of(' ')); // The part name + bool ecc = flags.find('C') != std::string::npos; + ret.emplace_back(line, ecc); + } + } + return ret; +} + +// Get partitions that should be cleared +std::vector<PartClear> getPartsToClear() +{ + const auto& [rc, pflashInfo] = pflash("-i | grep ^ID | grep 'F'"); + return getPartsToClear(pflashInfo); +} + } // namespace utils namespace openpower @@ -242,22 +278,7 @@ void ItemUpdaterStatic::processPNORImage() void ItemUpdaterStatic::reset() { - // The pair contains the partition name and if it should use ECC clear - using PartClear = std::pair<const char*, bool>; - constexpr std::array<PartClear, 11> partitions = {{ - {"HBEL", true}, - {"GUARD", true}, - {"NVRAM", false}, - {"DJVPD", true}, - {"MVPD", true}, - {"CVPD", true}, - {"FIRDATA", true}, - {"BMC_INV", false}, - {"ATTR_TMP", false}, - {"ATTR_PERM", true}, - {"HB_VOLATILE", true}, - }}; - + auto partitions = utils::getPartsToClear(); std::vector<uint8_t> mboxdArgs; // Suspend mboxd - no args required. |

