[PATCH v3 6/7] fwu: add helper to get image GUID by type and bank index

Simon Glass sjg at chromium.org
Thu Apr 16 20:52:18 CEST 2026


Hi Dario,

On 2026-04-15T18:31:27, Dario Binacchi
<dario.binacchi at amarulasolutions.com> wrote:
> fwu: add helper to get image GUID by type and bank index
>
> Introduce fwu_mdata_get_image_guid() to retrieve a specific image GUID
> from the FWU metadata based on the bank index and image type GUID.
>
> This allows identifying the correct partition in multi-bank (A/B)
> scenarios, ensuring the correct image is targeted depending on the
> current bank.
>
> Signed-off-by: Dario Binacchi <dario.binacchi at amarulasolutions.com>
>
> include/fwu.h         | 11 +++++++++++
>  lib/fwu_updates/fwu.c | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)

> diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
> @@ -243,6 +243,39 @@ int fwu_sync_mdata(struct fwu_mdata *mdata, int part)
> +int fwu_mdata_get_image_guid(efi_guid_t *image_guid,
> +                          const efi_guid_t *image_type_guid, u32 bank_index)
> +{
> +     struct fwu_data *data = &g_fwu_data;
> +     struct fwu_image_entry *image;
> +     int i;
> +
> +     if (bank_index >= data->num_banks)
> +             return -EINVAL;
> +
> +     for (i = 0; i < data->num_images; i++) {

Using data->num_images here is the proper approach for new code. Some
existing functions still use CONFIG_FWU_NUM_IMAGES_PER_BANK in their
loops but using the runtime value is more correct, especially since
FWU v2 populates num_images from the metadata itself.

Is there a unit test for this new function? Since you have added tests
for the part command in patches 2, 3, and 5, it would be good to add
coverage here as well, e.g. testing success, -EINVAL for invalid bank
index, and -ENOENT for missing image type.

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list