From 560d8f32703ffa748197f6b782884952697669ff Mon Sep 17 00:00:00 2001 From: Dario Binacchi Date: Mon, 18 May 2026 08:54:27 +0200 Subject: board: st: stm32mp15: support dynamic A/B bank bootup Following commit 4300f9f4c5d7 ("board: st: stm32mp25: support dynamic A/B bank bootup"), this patch enables automatic detection of the active A/B bank on STM32MP15 platforms 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 STM32MP15 boards, add the following Kconfig options to the stm32mp15[_basic]_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 Reviewed-by: Patrice Chotard --- board/st/stm32mp1/stm32mp1.c | 33 +++++++++++++++++++++++++++++++++ include/configs/stm32mp15_st_common.h | 15 +++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 88ede4e3910..8164a62e9a3 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -857,4 +857,37 @@ 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/stm32mp15_st_common.h b/include/configs/stm32mp15_st_common.h index 60838cb0e3f..7727e583fc7 100644 --- a/include/configs/stm32mp15_st_common.h +++ b/include/configs/stm32mp15_st_common.h @@ -8,7 +8,22 @@ #ifndef __CONFIG_STM32MP15_ST_COMMON_H__ #define __CONFIG_STM32MP15_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_STM32MP15_FWU_ENV \ + "altbootcmd=${bootcmd}\0" +#else +#define ST_STM32MP15_FWU_ENV +#endif + #define STM32MP_BOARD_EXTRA_ENV \ + ST_STM32MP15_FWU_ENV \ "usb_pgood_delay=2000\0" \ "console=ttySTM0\0" \ "splashimage=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \ -- cgit v1.2.3 From 4369c6a05035351089b09e26bd8f4915cd5f5d9f Mon Sep 17 00:00:00 2001 From: Dario Binacchi Date: Mon, 18 May 2026 08:54:28 +0200 Subject: board: st: factorize STM32MP FWU multi-bank support Factorize FWU multi-bank support code common to STM32MP1 and STM32MP2 platforms into a dedicated shared source file. No functional change intended. Signed-off-by: Dario Binacchi Reviewed-by: Patrice Chotard --- board/st/common/Makefile | 1 + board/st/common/stm32mp_fwu.c | 55 +++++++++++++++++++++++++++++++++++++++++++ board/st/stm32mp1/stm32mp1.c | 54 ------------------------------------------ board/st/stm32mp2/stm32mp2.c | 53 ----------------------------------------- 4 files changed, 56 insertions(+), 107 deletions(-) create mode 100644 board/st/common/stm32mp_fwu.c diff --git a/board/st/common/Makefile b/board/st/common/Makefile index 122b13c3aa8..36dfaddfa0e 100644 --- a/board/st/common/Makefile +++ b/board/st/common/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_PMIC_STPMIC1) += stpmic1.o ifeq ($(CONFIG_ARCH_STM32MP),y) obj-$(CONFIG_SET_DFU_ALT_INFO) += stm32mp_dfu.o obj-$(CONFIG_$(PHASE_)DFU_VIRT) += stm32mp_dfu_virt.o +obj-$(CONFIG_FWU_MULTI_BANK_UPDATE) += stm32mp_fwu.o endif obj-$(CONFIG_TYPEC_STUSB160X) += stusb160x.o diff --git a/board/st/common/stm32mp_fwu.c b/board/st/common/stm32mp_fwu.c new file mode 100644 index 00000000000..ac7ca6bdca2 --- /dev/null +++ b/board/st/common/stm32mp_fwu.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +/* + * Copyright (C) 2026 Amarula Solutions, Dario Binacchi + */ + +#include +#include +#include +/** + * fwu_plat_get_bootidx() - Get the value of the boot index + * @boot_idx: Boot index value + * + * Get the value of the bank(partition) from which the platform + * has booted. This value is passed to U-Boot from the earlier + * stage bootloader which loads and boots all the relevant + * firmware images + * + */ +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; +} diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 8164a62e9a3..9b933a2ba0b 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -837,57 +837,3 @@ static void board_copro_image_process(ulong fw_image, size_t fw_size) } U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process); - -#if defined(CONFIG_FWU_MULTI_BANK_UPDATE) - -#include - -/** - * fwu_plat_get_bootidx() - Get the value of the boot index - * @boot_idx: Boot index value - * - * Get the value of the bank(partition) from which the platform - * has booted. This value is passed to U-Boot from the earlier - * stage bootloader which loads and boots all the relevant - * firmware images - * - */ -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/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c index 5cbbbc322a3..7bc7d2a608f 100644 --- a/board/st/stm32mp2/stm32mp2.c +++ b/board/st/stm32mp2/stm32mp2.c @@ -188,56 +188,3 @@ void board_quiesce_devices(void) { led_boot_off(); } - -#if defined(CONFIG_FWU_MULTI_BANK_UPDATE) - -#include - -/** - * fwu_plat_get_bootidx() - Get the value of the boot index - * @boot_idx: Boot index value - * - * Get the value of the bank(partition) from which the platform - * has booted. This value is passed to U-Boot from the earlier - * stage bootloader which loads and boots all the relevant - * firmware images - * - */ -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 */ -- cgit v1.2.3 From 70456905ec52e480ae15dd78691451b7b4ba28ad Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Mon, 18 May 2026 15:28:09 +0200 Subject: configs: stm32mp15: Increase SYS_MALLOC_F_LEN Using stm32mp15_defconfig with stm32mp157c-dk2-scmi.dtsi device tree with optee-4.10.0, we got: U-Boot 2026.07-rc2-00052-g215496fec59b (May 18 2026 - 15:05:34 +0200) CPU: STM32MP157CAC Rev.B Model: STMicroelectronics STM32MP157C-DK2 SCMI Discovery Board Board: stm32mp1 in trusted mode (st,stm32mp157c-dk2-scmi) alloc space exhausted ptr 80060 limit 80000 optee optee: PTA_BSEC invoke failed TEE err: 0, err:fffffff4 alloc space exhausted ptr 80040 limit 80000 alloc space exhausted ptr 80020 limit 80000 DRAM: alloc space exhausted ptr 80040 limit 80000 RAM init failed: -12 initcall_run_f(): initcall dram_init() failed CONFIG_SYS_MALLOC_F_LEN need to be increased to fix this issue Reported-by: Yann Gautier Signed-off-by: Patrice Chotard Reviewed-by: Patrick Delaunay --- configs/stm32mp15_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig index b9e44254087..cc4dfd9af70 100644 --- a/configs/stm32mp15_defconfig +++ b/configs/stm32mp15_defconfig @@ -1,7 +1,7 @@ CONFIG_ARM=y CONFIG_ARCH_STM32MP=y CONFIG_TFABOOT=y -CONFIG_SYS_MALLOC_F_LEN=0x80000 +CONFIG_SYS_MALLOC_F_LEN=0x90000 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc0100000 CONFIG_ENV_OFFSET=0x900000 CONFIG_ENV_SECT_SIZE=0x40000 -- cgit v1.2.3 From 5b2e264a7739e4139bd0039ffa9b4a2ff4d0a362 Mon Sep 17 00:00:00 2001 From: Lionel Debieve Date: Wed, 20 May 2026 18:07:13 +0200 Subject: configs: stm32mp15: enable WDT_ARM_SMC driver Enable the arm watchdog over SMC driver. This allows using a secure watchdog, based on IWDG1 peripheral and managed by OP-TEE. The driver will be probed if a watchdog node with "arm,smc-wdt" compatible is enabled. Signed-off-by: Lionel Debieve Signed-off-by: Yann Gautier Reviewed-by: Patrice Chotard --- configs/stm32mp15_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig index cc4dfd9af70..53903376524 100644 --- a/configs/stm32mp15_defconfig +++ b/configs/stm32mp15_defconfig @@ -169,5 +169,6 @@ CONFIG_BMP_24BPP=y CONFIG_BMP_32BPP=y CONFIG_WDT=y CONFIG_WDT_STM32MP=y +CONFIG_WDT_ARM_SMC=y # CONFIG_BINMAN_FDT is not set CONFIG_ERRNO_STR=y -- cgit v1.2.3 From a3a09d28d52b7da7fa337c44526747399055c281 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Wed, 20 May 2026 18:07:14 +0200 Subject: configs: stm32mp13: activate watchdog No watchdog was enabled for STM32MP13 platform. Add the required flags to support it. As done for STM32MP15 (in SCMI config) and STM32MP2x, we use the Arm SMC watchdog. The required nodes were already present in Linux imported DT files (stm32mp13.dtsi & stm32mp135f-dk.dts). To enable this SMC watchdog on other platforms based on STM32MP13, check that both the following flags are enabled in the dedicated config file: CONFIG_WDT=y CONFIG_WDT_ARM_SMC=y And that there is a node in Linux board DT that enables the feature, as it is done in stm32mp135f-dk.dts: &arm_wdt { timeout-sec = <32>; status = "okay"; }; Signed-off-by: Patrick Delaunay Signed-off-by: Yann Gautier Reviewed-by: Patrice Chotard --- configs/stm32mp13_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig index 620a6da2efe..2ad57e23e44 100644 --- a/configs/stm32mp13_defconfig +++ b/configs/stm32mp13_defconfig @@ -113,4 +113,6 @@ CONFIG_USB_GADGET_MANUFACTURER="STMicroelectronics" CONFIG_USB_GADGET_VENDOR_NUM=0x0483 CONFIG_USB_GADGET_PRODUCT_NUM=0x5720 CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_WDT=y +CONFIG_WDT_ARM_SMC=y CONFIG_ERRNO_STR=y -- cgit v1.2.3 From d6ddbbb0008c4e59c5ce4c9d94265db966368462 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Wed, 20 May 2026 18:07:15 +0200 Subject: ARM: dts: stm32: enable SMC watchdog for STM32MP15 SCMI config For this configuration, the watchdog (iwdg1) is secured and managed by OP-TEE. Add an watchdog node with arm,smc-wdt compatible, and disable iwdg2 node which is then no more used. Signed-off-by: Yann Gautier Reviewed-by: Patrice Chotard --- arch/arm/dts/stm32mp15-scmi-u-boot.dtsi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/stm32mp15-scmi-u-boot.dtsi b/arch/arm/dts/stm32mp15-scmi-u-boot.dtsi index 79494ecad90..600316205fc 100644 --- a/arch/arm/dts/stm32mp15-scmi-u-boot.dtsi +++ b/arch/arm/dts/stm32mp15-scmi-u-boot.dtsi @@ -21,6 +21,13 @@ pinctrl1 = &pinctrl_z; }; + arm_wdt: watchdog { + compatible = "arm,smc-wdt"; + arm,smc-id = <0xbc000000>; + timeout-sec = <32>; + status = "okay"; + }; + binman: binman { multiple-images; }; @@ -103,7 +110,7 @@ }; &iwdg2 { - bootph-all; + status = "disabled"; }; /* pre-reloc probe = reserve video frame buffer in video_reserve() */ -- cgit v1.2.3 From 0c035ff60c1e8caee7fccd2673ce75380dee825b Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Tue, 24 Feb 2026 18:31:50 +0100 Subject: stm32mp2: update part number for STM32MP251/3 update part number for STM32MP251/3 for last cut revision. Signed-off-by: Patrice Chotard Reviewed-by: Patrick Delaunay --- arch/arm/mach-stm32mp/include/mach/sys_proto.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-stm32mp/include/mach/sys_proto.h b/arch/arm/mach-stm32mp/include/mach/sys_proto.h index a875907ac3e..05ce869c428 100644 --- a/arch/arm/mach-stm32mp/include/mach/sys_proto.h +++ b/arch/arm/mach-stm32mp/include/mach/sys_proto.h @@ -61,20 +61,20 @@ /* ID for STM32MP25x = Device Part Number (RPN) (bit31:0) */ #define CPU_STM32MP257Cxx 0x00002000 #define CPU_STM32MP255Cxx 0x00082000 -#define CPU_STM32MP253Cxx 0x000B2004 -#define CPU_STM32MP251Cxx 0x000B3065 +#define CPU_STM32MP253Cxx 0x000B300C +#define CPU_STM32MP251Cxx 0x000B306D #define CPU_STM32MP257Axx 0x40002E00 #define CPU_STM32MP255Axx 0x40082E00 -#define CPU_STM32MP253Axx 0x400B2E04 -#define CPU_STM32MP251Axx 0x400B3E65 +#define CPU_STM32MP253Axx 0x400B3E0C +#define CPU_STM32MP251Axx 0x400B3E6D #define CPU_STM32MP257Fxx 0x80002000 #define CPU_STM32MP255Fxx 0x80082000 -#define CPU_STM32MP253Fxx 0x800B2004 -#define CPU_STM32MP251Fxx 0x800B3065 +#define CPU_STM32MP253Fxx 0x800B300C +#define CPU_STM32MP251Fxx 0x800B306D #define CPU_STM32MP257Dxx 0xC0002E00 #define CPU_STM32MP255Dxx 0xC0082E00 -#define CPU_STM32MP253Dxx 0xC00B2E04 -#define CPU_STM32MP251Dxx 0xC00B3E65 +#define CPU_STM32MP253Dxx 0xC00B3E0C +#define CPU_STM32MP251Dxx 0xC00B3E6D /* return CPU_STMP32MP...Xxx constants */ u32 get_cpu_type(void); -- cgit v1.2.3