board: st: stm32mp15: support dynamic A/B bank bootup
PATCH 1/2 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
---
board/st/stm32mp1/stm32mp1.c | 33 +++++++++++++++++++++++++++ include/configs/stm32mp15_st_common.h | 15 ++++++++++++ 2 files changed, 48 insertions(+)
board/st/stm32mp1/stm32mp1.c +33 -0
@@ -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 */ +
include/configs/stm32mp15_st_common.h +15 -0
@@ -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" \
Signature · 4 lines
2.43.0 base-commit: 215496fec59b3fa09256b4fb62f92af46e2ec7f9 branch: fwumdata-ab-stm32mp1
PATCH 2/2 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.
---
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
board/st/common/Makefile +1 -0
@@ -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
board/st/common/stm32mp_fwu.c new file +55 -0
55 lines not on this page · raw message
board/st/stm32mp1/stm32mp1.c +0 -54
57 lines not on this page · raw message
board/st/stm32mp2/stm32mp2.c +0 -53
56 lines not on this page · raw message
Signature · 4 lines
2.43.0 base-commit: 215496fec59b3fa09256b4fb62f92af46e2ec7f9 branch: fwumdata-ab-stm32mp1
Re: [PATCH 2/2] board: st: factorize STM32MP FWU multi-bank support
Quoted 201 lines · Dario Binacchi
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 <[email protected]>---
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.cboard/st/common/Makefile +1
-0@@ -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.oboard/st/common/stm32mp_fwu.c new file +55
-0@@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +/* +* Copyright (C) 2026 Amarula Solutions, Dario Binacchi <[email protected]> +*/ + +#include <fwu.h> +#include <part_efi.h> +#include <asm/io.h> +/** +* 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 ; +}board/st/stm32mp1/stm32mp1.c +0
-54@@ -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.h> - -/** -* 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 */ -board/st/stm32mp2/stm32mp2.c +0
-43@@ -188,56 +188,3 @@ void board_quiesce_devices(void) {led_boot_off (); } - -#if defined(CONFIG_FWU_MULTI_BANK_UPDATE ) - -#include <fwu.h> - -/** -* 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) {
board/st/stm32mp2/stm32mp2.c void board_quiesce_devices(void) · line 243
Quoted 10 lines
board/st/stm32mp2/stm32mp2.c +0
-10-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 */
Thanks
Patrice
Re: [PATCH 2/2] board: st: factorize STM32MP FWU multi-bank support
In reply to Dario BinacchiQuoted 201 lines · Dario Binacchi
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 <[email protected]>---
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.cboard/st/common/Makefile +1
-0@@ -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.oboard/st/common/stm32mp_fwu.c new file +55
-0@@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +/* +* Copyright (C) 2026 Amarula Solutions, Dario Binacchi <[email protected]> +*/ + +#include <fwu.h> +#include <part_efi.h> +#include <asm/io.h> +/** +* 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 ; +}board/st/stm32mp1/stm32mp1.c +0
-54@@ -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.h> - -/** -* 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 */ -board/st/stm32mp2/stm32mp2.c +0
-43@@ -188,56 +188,3 @@ void board_quiesce_devices(void) {led_boot_off (); } - -#if defined(CONFIG_FWU_MULTI_BANK_UPDATE ) - -#include <fwu.h> - -/** -* 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) {
board/st/stm32mp2/stm32mp2.c void board_quiesce_devices(void) · line 243
Quoted 10 lines
board/st/stm32mp2/stm32mp2.c +0
-10-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 */
Applied to u-boot-stm32/master
Thanks
Patrice
Quoted 85 lines · Dario Binacchi
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
Kconfigoptions 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=ySigned-off-by Dario Binacchi <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 33 +++++++++++++++++++++++++++ include/configs/stm32mp15_st_common.h | 15 ++++++++++++ 2 files changed, 48 insertions(+)board/st/stm32mp1/stm32mp1.c +33
-0@@ -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 */ +include/configs/stm32mp15_st_common.h +9
-0@@ -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 \
include/configs/stm32mp15_st_common.h line 29
Quoted 10 lines
include/configs/stm32mp15_st_common.h +6
-0+ "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" \
Thanks
Patrice
Quoted 85 lines · Dario Binacchi
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
Kconfigoptions 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=ySigned-off-by Dario Binacchi <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 33 +++++++++++++++++++++++++++ include/configs/stm32mp15_st_common.h | 15 ++++++++++++ 2 files changed, 48 insertions(+)board/st/stm32mp1/stm32mp1.c +33
-0@@ -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 */ +include/configs/stm32mp15_st_common.h +9
-0@@ -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 \
include/configs/stm32mp15_st_common.h line 29
Quoted 10 lines
include/configs/stm32mp15_st_common.h +6
-0+ "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" \
Applied to u-boot-stm32/master
Thanks
Patrice