summaryrefslogtreecommitdiff
path: root/lib/fwu_updates
diff options
context:
space:
mode:
authorSughosh Ganu <sughosh.ganu@linaro.org>2022-10-21 15:46:03 +0300
committerTom Rini <trini@konsulko.com>2022-10-31 21:47:32 +0300
commit86794052418b7aa15d94025add3082cd357a0b12 (patch)
treef41630f0e51fb7f25db164009d8af79ad4c25267 /lib/fwu_updates
parent7e9814cc6c1dcda8cb8028e1d34483387889e149 (diff)
downloadu-boot-86794052418b7aa15d94025add3082cd357a0b12.tar.xz
FWU: Add support for the FWU Multi Bank Update feature
The FWU Multi Bank Update feature supports updating firmware images to one of multiple sets(also called banks) of images. The firmware images are clubbed together in banks, with the system booting images from the active bank. Information on the images such as which bank they belong to is stored as part of the metadata structure, which is stored on the same storage media as the firmware images on a dedicated partition. At the time of update, the metadata is read to identify the bank to which the images need to be flashed(update bank). On a successful update, the metadata is modified to set the updated bank as active bank to subsequently boot from. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'lib/fwu_updates')
-rw-r--r--lib/fwu_updates/Kconfig33
-rw-r--r--lib/fwu_updates/Makefile7
-rw-r--r--lib/fwu_updates/fwu.c22
3 files changed, 62 insertions, 0 deletions
diff --git a/lib/fwu_updates/Kconfig b/lib/fwu_updates/Kconfig
new file mode 100644
index 0000000000..78759e6618
--- /dev/null
+++ b/lib/fwu_updates/Kconfig
@@ -0,0 +1,33 @@
+config FWU_MULTI_BANK_UPDATE
+ bool "Enable FWU Multi Bank Update Feature"
+ depends on EFI_CAPSULE_ON_DISK
+ select PARTITION_TYPE_GUID
+ select EFI_SETUP_EARLY
+ imply EFI_CAPSULE_ON_DISK_EARLY
+ select EVENT
+ help
+ Feature for updating firmware images on platforms having
+ multiple banks(copies) of the firmware images. One of the
+ bank is selected for updating all the firmware components
+
+config FWU_NUM_BANKS
+ int "Number of Banks defined by the platform"
+ depends on FWU_MULTI_BANK_UPDATE
+ help
+ Define the number of banks of firmware images on a platform
+
+config FWU_NUM_IMAGES_PER_BANK
+ int "Number of firmware images per bank"
+ depends on FWU_MULTI_BANK_UPDATE
+ help
+ Define the number of firmware images per bank. This value
+ should be the same for all the banks.
+
+config FWU_TRIAL_STATE_CNT
+ int "Number of times system boots in Trial State"
+ depends on FWU_MULTI_BANK_UPDATE
+ default 3
+ help
+ With FWU Multi Bank Update feature enabled, number of times
+ the platform is allowed to boot in Trial State after an
+ update.
diff --git a/lib/fwu_updates/Makefile b/lib/fwu_updates/Makefile
new file mode 100644
index 0000000000..1993088e5b
--- /dev/null
+++ b/lib/fwu_updates/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (c) 2022, Linaro Limited
+#
+
+obj-$(CONFIG_FWU_MULTI_BANK_UPDATE) += fwu.o
+obj-$(CONFIG_FWU_MDATA_GPT_BLK) += fwu_gpt.o
diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
index c9a9022a59..6e159c050c 100644
--- a/lib/fwu_updates/fwu.c
+++ b/lib/fwu_updates/fwu.c
@@ -630,6 +630,28 @@ u8 fwu_empty_capsule_checks_pass(void)
return in_trial && boottime_check;
}
+/**
+ * fwu_trial_state_ctr_start() - Start the Trial State counter
+ *
+ * Start the counter to identify the platform booting in the
+ * Trial State. The counter is implemented as an EFI variable.
+ *
+ * Return: 0 if OK, -ve on error
+ *
+ */
+int fwu_trial_state_ctr_start(void)
+{
+ int ret;
+ u16 trial_state_ctr;
+
+ trial_state_ctr = 0;
+ ret = trial_counter_update(&trial_state_ctr);
+ if (ret)
+ log_err("Unable to initialise TrialStateCtr\n");
+
+ return ret;
+}
+
static int fwu_boottime_checks(void *ctx, struct event *event)
{
int ret;