static layout: support factory reset
Implement factory reset for static flash layout, that starts
obmc-flash-bmc-setenv to set factory-reset u-boot env and let
init to do the cleanup.
Tested: Invoke factory reset on /xyz/openbmc_project/software and verify
everything in rwfs is deleted, and after reboot, the BMC acts
like a fresh new one.
Change-Id: I20e361519af6c3c12703315070debabd8cf88060
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/static/item_updater_helper.cpp b/static/item_updater_helper.cpp
index e639e63..19ac61d 100644
--- a/static/item_updater_helper.cpp
+++ b/static/item_updater_helper.cpp
@@ -1,3 +1,4 @@
+#include "config.h"
#include "item_updater_helper.hpp"
namespace phosphor
@@ -6,6 +7,10 @@
{
namespace updater
{
+// openbmconce=clean-rwfs-filesystem factory-reset
+#define ENV_FACTORY_RESET "openbmconce\\x3dfactory\\x2dreset"
+#define SERVICE_FACTORY_RESET \
+ "obmc-flash-bmc-setenv@" ENV_FACTORY_RESET ".service"
void Helper::setEntry(const std::string& entryId, uint8_t value)
{
@@ -24,7 +29,12 @@
void Helper::factoryReset()
{
- // TODO
+ // Set openbmconce=factory-reset env in U-Boot.
+ // The init will cleanup rwfs during boot.
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
+ method.append(SERVICE_FACTORY_RESET, "replace");
+ bus.call_noreply(method);
}
void Helper::removeVersion(const std::string& versionId)