ARM: stm32: env: Enable scan and start for AB schema on STM32MP15 DHSOM
authorPascal Zimmermann <pzimmermann@dh-electronics.com>
Thu, 27 Mar 2025 14:38:43 +0000 (15:38 +0100)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Mon, 5 May 2025 13:51:46 +0000 (15:51 +0200)
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.

Signed-off-by: Pascal Zimmermann <pzimmermann@dh-electronics.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
configs/stm32mp15_dhsom.config
include/configs/stm32mp15_dh_dhsom.h

index 7e5b5aa..c841164 100644 (file)
@@ -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
index c004a8c..267e344 100644 (file)
                        " 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 */    \