[PATCH v7 8/8] board: st: stm32mp25: support dynamic A/B bank bootup
Patrice CHOTARD
patrice.chotard at foss.st.com
Wed Apr 29 09:13:30 CEST 2026
On 4/26/26 17:47, Dario Binacchi wrote:
> Enable automatic detection of the active A/B bank by retrieving
> partition GUIDs from FWU metadata.
>
> This ensures the system correctly identifies the bootable partitions
> even in multi-bank scenarios, falling back to a standard bootable flag
> scan if the UUIDs are missing.
>
> To enable A/B bank bootup on stm32mp25 boards, add the following Kconfig
> options to the stm32mp25_defconfig:
>
> CONFIG_FWU_MULTI_BANK_UPDATE=y
> CONFIG_FWU_MDATA=y
> CONFIG_FWU_NUM_BANKS=2
> CONFIG_FWU_NUM_IMAGES_PER_BANK=3
> CONFIG_CMD_FWU_METADATA=y
> CONFIG_FWU_MDATA_V2=y
>
> Signed-off-by: Dario Binacchi <dario.binacchi at amarulasolutions.com>
> Reviewed-by: Simon Glass <sjg at chromium.org>
>
> ---
>
> (no changes since v5)
>
> Changes in v5:
> - Add Acked-by of Ilias Apalodimas to patch 6/8 "fwu: add helper to get
> image GUID by type and bank index"
>
> Changes in v4:
> - Add patch 7/8 test: dm: fwu_mdata: add test for fwu_mdata_get_image_guid
>
> Changes in v3:
> - Wrap lines exceeding 80 columns in test/cmd/part.c file.
> - Combine run_command() and ut_asserteq() -> ut_asserteq(1, run_command(
> - Add kerneldoc comment for fwu_mdata_get_image_guid() above its declaration
> in fwu.h.
> - Add log_warning() messages to fwu_platform_hook() to catch inconsistent
> FWU metadata (boot GUID found but root GUID missing or viceversa), as
> suggested by Simon Glass.
> - Add Reviewed-by tag of Simon Glass.
>
> Changes in v2:
> - Add links to the XBOOTLDR specification in the commit message of patch
> 1/7 lib: uuid: add partition type GUID for extended bootloader.
> - Update help for 'part start', 'part size' to mention UUID.
> - Add kerneldoc comment for fwu_mdata_get_image_guid().
> - Pass efi_guid_t by pointer in fwu_mdata_get_image_guid().
> - Add patches:
> 5/7 test: cmd: part: add UUID lookup tests
> 3/7 test: cmd: add unit tests for part command
> 2/7 test: dm: part: add test for part_get_info_by_uuid
> - Pass efi_guid_t by pointer in fwu_mdata_get_image_guid() calls.
>
> board/st/stm32mp2/stm32mp2.c | 32 +++++++++++++++++++++++++++
> include/configs/stm32mp25_st_common.h | 15 +++++++++++++
> 2 files changed, 47 insertions(+)
>
> diff --git a/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c
> index 43bc583378e6..5cbbbc322a3a 100644
> --- a/board/st/stm32mp2/stm32mp2.c
> +++ b/board/st/stm32mp2/stm32mp2.c
> @@ -208,4 +208,36 @@ void fwu_plat_get_bootidx(uint *boot_idx)
> *boot_idx = (readl(TAMP_FWU_BOOT_INFO_REG) >>
> TAMP_FWU_BOOT_IDX_OFFSET) & TAMP_FWU_BOOT_IDX_MASK;
> }
> +
> +int fwu_platform_hook(struct udevice *dev, struct fwu_data *data)
> +{
> + uint boot_idx;
> + efi_guid_t boot_uuid, root_uuid;
> + const efi_guid_t boot_type_guid = PARTITION_XBOOTLDR;
> + const efi_guid_t root_type_guid =
> + PARTITION_LINUX_FILE_SYSTEM_DATA_GUID;
> + char uuidbuf[UUID_STR_LEN + 1];
> + int retb, retr;
> +
> + fwu_plat_get_bootidx(&boot_idx);
> +
> + retb = fwu_mdata_get_image_guid(&boot_uuid, &boot_type_guid, boot_idx);
> + retr = fwu_mdata_get_image_guid(&root_uuid, &root_type_guid, boot_idx);
> +
> + if (!retb && !retr) {
> + uuid_bin_to_str(boot_uuid.b, uuidbuf, UUID_STR_FORMAT_GUID);
> + env_set("boot_partuuid", uuidbuf);
> +
> + uuid_bin_to_str(root_uuid.b, uuidbuf, UUID_STR_FORMAT_GUID);
> + env_set("root_partuuid", uuidbuf);
> + } else if (!retb && retr) {
> + log_warning("%s: found boot GUID but missing root GUID (%d)\n",
> + __func__, retr);
> + } else if (!retr && retb) {
> + log_warning("%s: found root GUID but missing boot GUID (%d)\n",
> + __func__, retb);
> + }
> +
> + return 0;
> +}
> #endif /* CONFIG_FWU_MULTI_BANK_UPDATE */
> diff --git a/include/configs/stm32mp25_st_common.h b/include/configs/stm32mp25_st_common.h
> index cb679eb1be22..0b0267ae99b0 100644
> --- a/include/configs/stm32mp25_st_common.h
> +++ b/include/configs/stm32mp25_st_common.h
> @@ -8,7 +8,22 @@
> #ifndef __CONFIG_STM32MP25_ST_COMMON_H__
> #define __CONFIG_STM32MP25_ST_COMMON_H__
>
> +#ifdef CONFIG_FWU_MULTI_BANK_UPDATE
> +#define SCAN_DEV_FOR_BOOT_PARTS \
> + "setenv devplist; " \
> + "env exists boot_partuuid && " \
> + "part number ${devtype} ${devnum} ${boot_partuuid} devplist; " \
> + "env exists devplist || " \
> + "part list ${devtype} ${devnum} -bootable devplist; "
> +
> +#define ST_STM32MP25_FWU_ENV \
> + "altbootcmd=${bootcmd}\0"
> +#else
> +#define ST_STM32MP25_FWU_ENV
> +#endif
> +
> #define STM32MP_BOARD_EXTRA_ENV \
> + ST_STM32MP25_FWU_ENV \
> "usb_pgood_delay=2000\0" \
> "console=ttySTM0\0"
>
Hi Dario
Reviewed-by: Patrice Chotard <patrice.chotard at foss.st.com>
Thanks
Patrice
More information about the U-Boot
mailing list