dual-image: Implement BMC update when running on secondary
Implement the BMC code update when it's running on the secondary image.
It will update the alt flash by obmc-flash-bmc-alt@.service and
wait for the completion.
After the update is done, it needs reboot to take effect.
Note if the BMC is running on the secondary, it requires a following
commit to reset the CS to make the SoC to boot from the primary flash.
This commit only flashes the alt image when it's running on the
secondary image, there will be future commits to support other cases,
e.g. flashing both images.
Tested: Verify the code update process is successful and it flashes the
whole primary chip when the BMC is running on the secondary
chip.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Ifa849e55c28f17b46d7f999ff43a7ad7e73f2ea1
diff --git a/item_updater.cpp b/item_updater.cpp
index 5d820d6..cfe0ae5 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -716,8 +716,29 @@
updateUbootEnvVars(lowestPriorityVersion);
}
-void ItemUpdater::freeSpace(const Activation& caller)
+void ItemUpdater::freeSpace([[maybe_unused]] const Activation& caller)
{
+#ifdef BMC_STATIC_DUAL_IMAGE
+ // For the golden image case, always remove the version on the primary side
+ std::string versionIDtoErase;
+ for (const auto& iter : activations)
+ {
+ if (iter.second->redundancyPriority &&
+ iter.second->redundancyPriority.get()->priority() == 0)
+ {
+ versionIDtoErase = iter.second->versionId;
+ break;
+ }
+ }
+ if (!versionIDtoErase.empty())
+ {
+ erase(versionIDtoErase);
+ }
+ else
+ {
+ warning("Failed to find version to erase");
+ }
+#else
// Versions with the highest priority in front
std::priority_queue<std::pair<int, std::string>,
std::vector<std::pair<int, std::string>>,
@@ -768,6 +789,7 @@
versionsPQ.pop();
count--;
}
+#endif
}
void ItemUpdater::mirrorUbootToAlt()