mmc: Update and remove functions for the kernel and rootfs
Add support for update and remove of eMMC images.
The code update tarball contains an image-kernel and image-rofs
files. These can be flashed directly to the eMMC partitions since
they're filesystem files compressed with zstd:
https://gerrit.openbmc-project.xyz/c/openbmc/meta-phosphor/+/30781
https://gerrit.openbmc-project.xyz/c/openbmc/meta-phosphor/+/34334
The image-rofs contains the BMC rootfs files, and the image-kernel
contains the fitImage file which is loaded by U-Boot.
Tested: Verified the non-running rofs and kernel partitions were updated.
Change-Id: Ic983dec1df389d56f11f12dc2e82589d1a2b9dcc
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/mmc/flash.cpp b/mmc/flash.cpp
index afaadfb..dd12b0d 100644
--- a/mmc/flash.cpp
+++ b/mmc/flash.cpp
@@ -1,3 +1,5 @@
+#include "config.h"
+
#include "flash.hpp"
#include "activation.hpp"
@@ -9,14 +11,49 @@
namespace updater
{
+namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
+
void Activation::flashWrite()
{
- // Empty
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
+ auto serviceFile = "obmc-flash-mmc@" + versionId + ".service";
+ method.append(serviceFile, "replace");
+ bus.call_noreply(method);
}
-void Activation::onStateChanges(sdbusplus::message::message& /*msg*/)
+void Activation::onStateChanges(sdbusplus::message::message& msg)
{
- // Empty
+ uint32_t newStateID{};
+ sdbusplus::message::object_path newStateObjPath;
+ std::string newStateUnit{};
+ std::string newStateResult{};
+
+ // Read the msg and populate each variable
+ msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
+
+ auto mmcServiceFile = "obmc-flash-mmc@" + versionId + ".service";
+
+ if (newStateUnit == mmcServiceFile && newStateResult == "done")
+ {
+ roVolumeCreated = true;
+ activationProgress->progress(activationProgress->progress() + 1);
+ }
+
+ if (newStateUnit == mmcServiceFile)
+ {
+ if (newStateResult == "failed" || newStateResult == "dependency")
+ {
+ Activation::activation(
+ softwareServer::Activation::Activations::Failed);
+ }
+ else if (roVolumeCreated)
+ {
+ Activation::onFlashWriteSuccess();
+ }
+ }
+
+ return;
}
} // namespace updater