Skip to contentSkip to conversation

ARM: stm32: env: Enable scan and start for AB schema on STM32MP15 DHSOM

PATCH RESEND In review Pascal Zimmermann 2 participants 7 messages Mar 28, 2025 – May 5, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ARM: stm32: env: Enable scan and start for AB schema on STM32MP15 DHSOM

For the STM32MP15 DHSOM, change the default environment so an AB schema on a device can be detected.

The first patch makes possible to substitute the 'part list' command inside 'scan_dev_for_boot_part' with a custom board specific implementation.

The second patch uses the change of the first patch to plug the board specific code for booting from AB into the standard boot of all boot targets at the STM32MP15 DHSOM.

The detection works by looking for the partitions with specific lables. The name of those partitions are in the variables and its defaults:
* dh_ab_partname_primary=rootfs-a
* dh_ab_partname_secondary=rootfs-b

To prevent being hanging at bootcmd, enable "CONFIG_BOOT_RETRY" and "CONFIG_RESET_TO_RETRY", but the timer will only be activated, if the AB partitions are detected.

Pascal Zimmermann (2):
config_distro_bootcmd: make possible to substitute 'part list' in
distro_bootcmd
ARM: stm32: env: Enable scan and start for AB schema on STM32MP15
DHSOM

 configs/stm32mp15_dhsom.config       |  3 +++
 include/config_distro_bootcmd.h      |  7 +++++-
 include/configs/stm32mp15_dh_dhsom.h | 33 ++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 1 deletion(-)

---
Cc: Marek Vasut <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Signature · 1 line
2.30.2
#1 lore raw

PATCH RESEND 1/2 config_distro_bootcmd: make possible to substitute 'part list' in distro_bootcmd

Make it possible to substitute the 'part list' command inside 'scan_dev_for_boot_part' with a custom board specific implementation.

For this the new define 'SCAN_DEV_FOR_BOOT_PARTS' is introduced.

---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: [email protected]
Cc: Marek Vasut <[email protected]>
Cc: [email protected]

---
 include/config_distro_bootcmd.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
include/config_distro_bootcmd.h +6 -1
index 0a4e4b8ff85..df0dc8cfdee 100644
@@ -194,6 +194,11 @@
 #define SCAN_DEV_FOR_EFI
 #endif
 
+#ifndef SCAN_DEV_FOR_BOOT_PARTS
+#define SCAN_DEV_FOR_BOOT_PARTS \
+	"part list ${devtype} ${devnum} -bootable devplist; "
+#endif
+
 #ifdef CONFIG_SATA
 #define BOOTENV_SHARED_SATA	BOOTENV_SHARED_BLKDEV(sata)
 #define BOOTENV_DEV_SATA	BOOTENV_DEV_BLKDEV
@@ -538,7 +543,7 @@
 		"\0"                                                      \
 	\
 	"scan_dev_for_boot_part="                                         \
-		"part list ${devtype} ${devnum} -bootable devplist; "     \
+		SCAN_DEV_FOR_BOOT_PARTS                                   \
 		"env exists devplist || setenv devplist 1; "              \
 		"for distro_bootpart in ${devplist}; do "                 \
 			"if fstype ${devtype} "                           \
Signature · 1 line
2.30.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [RESEND PATCH 1/2] config_distro_bootcmd: make possible to substitute 'part list' in distro_bootcmd

Quoted 33 lines · Pascal Zimmermann

Make it possible to substitute the 'part list' command inside 'scan_dev_for_boot_part' with a custom board specific implementation.

For this the new define 'SCAN_DEV_FOR_BOOT_PARTS' is introduced.

---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: [email protected]
Cc: Marek Vasut <[email protected]>
Cc: [email protected]

---
 include/config_distro_bootcmd.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
include/config_distro_bootcmd.h +5 -0
index 0a4e4b8ff85..df0dc8cfdee 100644
@@ -194,6 +194,11 @@
 #define SCAN_DEV_FOR_EFI
 #endif
 
+#ifndef SCAN_DEV_FOR_BOOT_PARTS
+#define SCAN_DEV_FOR_BOOT_PARTS \
+	"part list ${devtype} ${devnum} -bootable devplist; "
+#endif
+
 #ifdef CONFIG_SATA
 #define BOOTENV_SHARED_SATA	BOOTENV_SHARED_BLKDEV(sata)
 #define BOOTENV_DEV_SATA	BOOTENV_DEV_BLKDEV

include/config_distro_bootcmd.h line 549

Quoted 8 lines
include/config_distro_bootcmd.h +1 -1
@@ -538,7 +543,7 @@
 		"\0"                                                      \
 	\
 	"scan_dev_for_boot_part="                                         \
-		"part list ${devtype} ${devnum} -bootable devplist; "     \
+		SCAN_DEV_FOR_BOOT_PARTS                                   \
 		"env exists devplist || setenv devplist 1; "              \
 		"for distro_bootpart in ${devplist}; do "                 \
 			"if fstype ${devtype} "                           \

Thanks
Patrice

#3 lore raw

Re: [RESEND PATCH 1/2] config_distro_bootcmd: make possible to substitute 'part list' in distro_bootcmd

Quoted 38 lines · Patrice CHOTARD
Quoted 35 lines · Pascal Zimmermann

Make it possible to substitute the 'part list' command inside 'scan_dev_for_boot_part' with a custom board specific implementation.

For this the new define 'SCAN_DEV_FOR_BOOT_PARTS' is introduced.

---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: [email protected]
Cc: Marek Vasut <[email protected]>
Cc: [email protected]

---
 include/config_distro_bootcmd.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
include/config_distro_bootcmd.h +5 -0
index 0a4e4b8ff85..df0dc8cfdee 100644
@@ -194,6 +194,11 @@
 #define SCAN_DEV_FOR_EFI
 #endif
 
+#ifndef SCAN_DEV_FOR_BOOT_PARTS
+#define SCAN_DEV_FOR_BOOT_PARTS \
+	"part list ${devtype} ${devnum} -bootable devplist; "
+#endif
+
 #ifdef CONFIG_SATA
 #define BOOTENV_SHARED_SATA	BOOTENV_SHARED_BLKDEV(sata)
 #define BOOTENV_DEV_SATA	BOOTENV_DEV_BLKDEV
@@ -538,7 +543,7 @@
 		"\0"                                                      \
 	\
Quoted 8 lines

include/config_distro_bootcmd.h line 549

Quoted 6 lines
include/config_distro_bootcmd.h +1 -1
 	"scan_dev_for_boot_part="                                         \
-		"part list ${devtype} ${devnum} -bootable devplist; "     \
+		SCAN_DEV_FOR_BOOT_PARTS                                   \
 		"env exists devplist || setenv devplist 1; "              \
 		"for distro_bootpart in ${devplist}; do "                 \
 			"if fstype ${devtype} "                           \

Hi Pascal

Applied to u-boot-stm32/master

Thanks
Patrice

Quoted 3 lines

Thanks
Patrice

#4 lore raw

PATCH RESEND 2/2 ARM: stm32: env: Enable scan and start for AB schema on STM32MP15 DHSOM

In reply to Pascal Zimmermann

For the STM32MP15 DHSOM, change the default environment so an AB schema on a device can be detected.

For this the define "SCAN_DEV_FOR_BOOT_PARTS" is overwritten and appended.

The detection works by looking for the partitions with specific lables. The name of those partitions are in the variables and its defaults:
* dh_ab_partname_primary=rootfs-a
* dh_ab_partname_secondary=rootfs-b

To prevent being hanging at bootcmd, enable "CONFIG_BOOT_RETRY" and "CONFIG_RESET_TO_RETRY", but the timer will only be activated, if the AB partitions are detected.

---
Cc: Marek Vasut <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 configs/stm32mp15_dhsom.config       |  3 +++
 include/configs/stm32mp15_dh_dhsom.h | 33 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
configs/stm32mp15_dhsom.config +3 -0
index 7e5b5aa67ef..c84116482f6 100644
@@ -10,6 +10,9 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_BOARD_SIZE_LIMIT=1441792
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
 CONFIG_BOOTDELAY=1
+CONFIG_BOOTRETRY=y
+CONFIG_RESET_TO_RETRY=y
+CONFIG_BOOT_RETRY_TIME=-1
 CONFIG_CMD_ADC=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_STBOARD=y
include/configs/stm32mp15_dh_dhsom.h +33 -0
index c004a8cec82..267e3446779 100644
@@ -17,7 +17,40 @@
 			" 0x800000\0"
 #endif
 
+/* Add the search for AB partitons */
+#define SCAN_DEV_FOR_BOOT_PARTS						\
+	"run dh_check_if_ab; "						\
+	"if test -z \"${devplist}\"; "					\
+		"then "							\
+		"part list ${devtype} ${devnum} -bootable devplist; "	\
+	"fi; "
+
 #define STM32MP_BOARD_EXTRA_ENV						\
+	"altbootcmd= "							\
+	"setenv dh_ab_get_partnames "					\
+		"'setenv dh_ab_partnames ${dh_ab_partname_secondary} "	\
+			"${dh_ab_partname_primary}' && "		\
+		"run bootcmd\0"						\
+	"dh_check_if_ab= " /* Sets devplist if AB partitions*/		\
+		"echo test for AB on ${devtype} ${devnum} && "		\
+		"run dh_ab_get_partnames && "				\
+		"setenv devplist && "					\
+		"for partname in ${dh_ab_partnames}; do "		\
+			"setenv partnum && "				\
+			"if part number ${devtype} ${devnum} ${partname} partnum; "\
+				"then "					\
+				"setenv devplist \"${devplist} ${partnum}\" && "\
+				"setenv bootretry 60 ;"			\
+			"fi; "						\
+		"done ; "						\
+		"if test -n \"${devplist}\"; "				\
+			"then echo AB partitions found! ; "		\
+		"fi\0"							\
+	"dh_ab_get_partnames= " /* Sets dh_ab_partnames */		\
+		"setenv dh_ab_partnames ${dh_ab_partname_primary} "	\
+			"${dh_ab_partname_secondary}\0"			\
+	"dh_ab_partname_primary=rootfs-a\0" /* Names of AB partitions */\
+	"dh_ab_partname_secondary=rootfs-b\0"				\
 	"dh_preboot="							\
 		"run dh_testbench_backward_compat\0"			\
 	"dh_update_sd_to_emmc=" /* Install U-Boot from SD to eMMC */	\
Signature · 1 line
2.30.2
Reviewed-by on v1 2/2
#5 lore raw
Quoted 79 lines · Pascal Zimmermann

For the STM32MP15 DHSOM, change the default environment so an AB schema on a device can be detected.

For this the define "SCAN_DEV_FOR_BOOT_PARTS" is overwritten and appended.

The detection works by looking for the partitions with specific lables. The name of those partitions are in the variables and its defaults:
* dh_ab_partname_primary=rootfs-a
* dh_ab_partname_secondary=rootfs-b

To prevent being hanging at bootcmd, enable "CONFIG_BOOT_RETRY" and "CONFIG_RESET_TO_RETRY", but the timer will only be activated, if the AB partitions are detected.

---
Cc: Marek Vasut <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 configs/stm32mp15_dhsom.config       |  3 +++
 include/configs/stm32mp15_dh_dhsom.h | 33 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
configs/stm32mp15_dhsom.config +3 -0
index 7e5b5aa67ef..c84116482f6 100644
@@ -10,6 +10,9 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_BOARD_SIZE_LIMIT=1441792
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
 CONFIG_BOOTDELAY=1
+CONFIG_BOOTRETRY=y
+CONFIG_RESET_TO_RETRY=y
+CONFIG_BOOT_RETRY_TIME=-1
 CONFIG_CMD_ADC=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_STBOARD=y
include/configs/stm32mp15_dh_dhsom.h +26 -0
index c004a8cec82..267e3446779 100644
@@ -17,7 +17,40 @@
 			" 0x800000\0"
 #endif
 
+/* Add the search for AB partitons */
+#define SCAN_DEV_FOR_BOOT_PARTS						\
+	"run dh_check_if_ab; "						\
+	"if test -z \"${devplist}\"; "					\
+		"then "							\
+		"part list ${devtype} ${devnum} -bootable devplist; "	\
+	"fi; "
+
 #define STM32MP_BOARD_EXTRA_ENV						\
+	"altbootcmd= "							\
+	"setenv dh_ab_get_partnames "					\
+		"'setenv dh_ab_partnames ${dh_ab_partname_secondary} "	\
+			"${dh_ab_partname_primary}' && "		\
+		"run bootcmd\0"						\
+	"dh_check_if_ab= " /* Sets devplist if AB partitions*/		\
+		"echo test for AB on ${devtype} ${devnum} && "		\
+		"run dh_ab_get_partnames && "				\
+		"setenv devplist && "					\
+		"for partname in ${dh_ab_partnames}; do "		\
+			"setenv partnum && "				\
+			"if part number ${devtype} ${devnum} ${partname} partnum; "\
+				"then "					\
+				"setenv devplist \"${devplist} ${partnum}\" && "\
+				"setenv bootretry 60 ;"			\
+			"fi; "						\
+		"done ; "						\
+		"if test -n \"${devplist}\"; "				\

include/configs/stm32mp15_dh_dhsom.h line 56

Quoted 10 lines
include/configs/stm32mp15_dh_dhsom.h +7 -0
+			"then echo AB partitions found! ; "		\
+		"fi\0"							\
+	"dh_ab_get_partnames= " /* Sets dh_ab_partnames */		\
+		"setenv dh_ab_partnames ${dh_ab_partname_primary} "	\
+			"${dh_ab_partname_secondary}\0"			\
+	"dh_ab_partname_primary=rootfs-a\0" /* Names of AB partitions */\
+	"dh_ab_partname_secondary=rootfs-b\0"				\
 	"dh_preboot="							\
 		"run dh_testbench_backward_compat\0"			\
 	"dh_update_sd_to_emmc=" /* Install U-Boot from SD to eMMC */	\

Thanks
Patrice

#6 lore raw
Quoted 86 lines · Patrice CHOTARD
Quoted 83 lines · Pascal Zimmermann

For the STM32MP15 DHSOM, change the default environment so an AB schema on a device can be detected.

For this the define "SCAN_DEV_FOR_BOOT_PARTS" is overwritten and appended.

The detection works by looking for the partitions with specific lables. The name of those partitions are in the variables and its defaults:
* dh_ab_partname_primary=rootfs-a
* dh_ab_partname_secondary=rootfs-b

To prevent being hanging at bootcmd, enable "CONFIG_BOOT_RETRY" and "CONFIG_RESET_TO_RETRY", but the timer will only be activated, if the AB partitions are detected.

---
Cc: Marek Vasut <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 configs/stm32mp15_dhsom.config       |  3 +++
 include/configs/stm32mp15_dh_dhsom.h | 33 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
configs/stm32mp15_dhsom.config +3 -0
index 7e5b5aa67ef..c84116482f6 100644
@@ -10,6 +10,9 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_BOARD_SIZE_LIMIT=1441792
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
 CONFIG_BOOTDELAY=1
+CONFIG_BOOTRETRY=y
+CONFIG_RESET_TO_RETRY=y
+CONFIG_BOOT_RETRY_TIME=-1
 CONFIG_CMD_ADC=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_STBOARD=y
include/configs/stm32mp15_dh_dhsom.h +30 -0
index c004a8cec82..267e3446779 100644
@@ -17,7 +17,40 @@
 			" 0x800000\0"
 #endif
 
+/* Add the search for AB partitons */
+#define SCAN_DEV_FOR_BOOT_PARTS						\
+	"run dh_check_if_ab; "						\
+	"if test -z \"${devplist}\"; "					\
+		"then "							\
+		"part list ${devtype} ${devnum} -bootable devplist; "	\
+	"fi; "
+
 #define STM32MP_BOARD_EXTRA_ENV						\
+	"altbootcmd= "							\
+	"setenv dh_ab_get_partnames "					\
+		"'setenv dh_ab_partnames ${dh_ab_partname_secondary} "	\
+			"${dh_ab_partname_primary}' && "		\
+		"run bootcmd\0"						\
+	"dh_check_if_ab= " /* Sets devplist if AB partitions*/		\
+		"echo test for AB on ${devtype} ${devnum} && "		\
+		"run dh_ab_get_partnames && "				\
+		"setenv devplist && "					\
+		"for partname in ${dh_ab_partnames}; do "		\
+			"setenv partnum && "				\
+			"if part number ${devtype} ${devnum} ${partname} partnum; "\
+				"then "					\
+				"setenv devplist \"${devplist} ${partnum}\" && "\
+				"setenv bootretry 60 ;"			\
+			"fi; "						\
+		"done ; "						\
+		"if test -n \"${devplist}\"; "				\
+			"then echo AB partitions found! ; "		\
+		"fi\0"							\
+	"dh_ab_get_partnames= " /* Sets dh_ab_partnames */		\
+		"setenv dh_ab_partnames ${dh_ab_partname_primary} "	\
Quoted 8 lines

include/configs/stm32mp15_dh_dhsom.h line 56

Quoted 6 lines
include/configs/stm32mp15_dh_dhsom.h +3 -0
+			"${dh_ab_partname_secondary}\0"			\
+	"dh_ab_partname_primary=rootfs-a\0" /* Names of AB partitions */\
+	"dh_ab_partname_secondary=rootfs-b\0"				\
 	"dh_preboot="							\
 		"run dh_testbench_backward_compat\0"			\
 	"dh_update_sd_to_emmc=" /* Install U-Boot from SD to eMMC */	\

Applied to u-boot-stm32/master

Thanks
Patrice

Quoted 3 lines

Thanks
Patrice