[RFC PATCH 10/14] FWU: Reboot soon after successfully install the new firmware

Masami Hiramatsu masami.hiramatsu at linaro.org
Thu Jan 20 16:31:00 CET 2022


Reboot to the trial state soon after successfully installing
the new firmware to the next bank and updating the active_index.
This is enabled by CONFIG_FWU_REBOOT_AFTER_UPDATE and is a
recommended option.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu at linaro.org>
---
 lib/efi_loader/efi_capsule.c |   10 ++++++++--
 lib/fwu_updates/Kconfig      |    9 +++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 83c89a0cbb..0928425b5f 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -1355,10 +1355,16 @@ efi_status_t efi_launch_capsules(void)
 			} else {
 				log_debug("Successfully updated the active_index\n");
 				status = fwu_trial_state_ctr_start();
-				if (status < 0)
+				if (status < 0) {
 					ret = EFI_DEVICE_ERROR;
-				else
+				} else {
 					ret = EFI_SUCCESS;
+					if (IS_ENABLED(CONFIG_FWU_REBOOT_AFTER_UPDATE)) {
+						log_info("New firmware is installed in bank#%d. Reboot from that bank.\n",
+							 update_index);
+						do_reset(NULL, 0, 0, NULL);
+					}
+				}
 			}
 		} else if (capsule_update == true && update_status == false) {
 			log_err("All capsules were not updated. Not updating FWU metadata\n");
diff --git a/lib/fwu_updates/Kconfig b/lib/fwu_updates/Kconfig
index 6de28e0c9c..0940a90747 100644
--- a/lib/fwu_updates/Kconfig
+++ b/lib/fwu_updates/Kconfig
@@ -29,3 +29,12 @@ config FWU_TRIAL_STATE_CNT
 	  With FWU Multi Bank Update feature enabled, number of times
 	  the platform is allowed to boot in Trial State after an
 	  update.
+
+config FWU_REBOOT_AFTER_UPDATE
+	bool "Reboot soon after installing new firmware"
+	depends on FWU_MULTI_BANK_UPDATE
+	default y
+	help
+	  Reboot the machine soon after installing a new firmware
+	  and start trial boot. You can disable this option for
+	  debugging or FWU development, but recommended to enable it.



More information about the U-Boot mailing list