On 4/25/25 15:15, Patrice Chotard wrote:
> Add support of UBI boot and activate the needed
> configuration for U-Boot environment in UBI volume for
> NAND or in a MTD partition for NOR device, SPI Flash:
> ENV_OFFSET, ENV_OFFSET_REDUND, ENV_SECT_SIZE is
> aligned with the default MTD partition on NOR device
> of the STMicroelectronics boards.
>
> Signed-off-by: Patrick Delaunay <patrick.delau...@foss.st.com>
> Signed-off-by: Patrice Chotard <patrice.chot...@foss.st.com>
> ---
>
> (no changes since v1)
>
> board/st/stm32mp2/stm32mp2.c | 13 +++++++++++++
> configs/stm32mp25_defconfig | 13 +++++++++++++
> include/configs/stm32mp25_common.h | 11 +++++++++++
> 3 files changed, 37 insertions(+)
>
> diff --git a/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c
> index 6e4f19b1664..2547f2e4bb7 100644
> --- a/board/st/stm32mp2/stm32mp2.c
> +++ b/board/st/stm32mp2/stm32mp2.c
> @@ -138,6 +138,19 @@ enum env_location env_get_location(enum env_operation
> op, int prio)
> return ENVL_MMC;
> else
> return ENVL_NOWHERE;
> +
> + case BOOT_FLASH_NAND:
> + case BOOT_FLASH_SPINAND:
> + if (CONFIG_IS_ENABLED(ENV_IS_IN_UBI))
> + return ENVL_UBI;
> + else
> + return ENVL_NOWHERE;
> +
> + case BOOT_FLASH_NOR:
> + if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
> + return ENVL_SPI_FLASH;
> + else
> + return ENVL_NOWHERE;
> default:
> return ENVL_NOWHERE;
> }
> diff --git a/configs/stm32mp25_defconfig b/configs/stm32mp25_defconfig
> index 3f765346904..0e515e4af65 100644
> --- a/configs/stm32mp25_defconfig
> +++ b/configs/stm32mp25_defconfig
> @@ -3,11 +3,13 @@ CONFIG_ARCH_STM32MP=y
> CONFIG_SYS_MALLOC_F_LEN=0x400000
> CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x90000000
> CONFIG_ENV_OFFSET=0x900000
> +CONFIG_ENV_SECT_SIZE=0x40000
> CONFIG_DEFAULT_DEVICE_TREE="st/stm32mp257f-ev1"
> CONFIG_SYS_BOOTM_LEN=0x2000000
> CONFIG_SYS_LOAD_ADDR=0x84000000
> CONFIG_STM32MP25X=y
> CONFIG_DDR_CACHEABLE_SIZE=0x10000000
> +CONFIG_ENV_OFFSET_REDUND=0x940000
> CONFIG_TARGET_ST_STM32MP25X=y
> CONFIG_SYS_MEMTEST_START=0x84000000
> CONFIG_SYS_MEMTEST_END=0x88000000
> @@ -33,9 +35,16 @@ CONFIG_CMD_RNG=y
> CONFIG_CMD_TIMER=y
> CONFIG_CMD_REGULATOR=y
> CONFIG_CMD_LOG=y
> +CONFIG_CMD_UBI=y
> CONFIG_OF_LIVE=y
> CONFIG_ENV_IS_NOWHERE=y
> CONFIG_ENV_IS_IN_MMC=y
> +CONFIG_ENV_IS_IN_SPI_FLASH=y
> +CONFIG_ENV_IS_IN_UBI=y
> +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
> +CONFIG_ENV_UBI_PART="UBI"
> +CONFIG_ENV_UBI_VOLUME="uboot_config"
> +CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
> CONFIG_SYS_MMC_ENV_DEV=-1
> CONFIG_NO_NET=y
> CONFIG_SYS_64BIT_LBA=y
> @@ -50,6 +59,7 @@ CONFIG_SUPPORT_EMMC_BOOT=y
> CONFIG_STM32_SDMMC2=y
> CONFIG_MTD=y
> CONFIG_USE_SYS_MAX_FLASH_BANKS=y
> +CONFIG_SPI_FLASH=y
> CONFIG_PINCONF=y
> CONFIG_DM_REGULATOR_FIXED=y
> CONFIG_DM_REGULATOR_GPIO=y
> @@ -57,8 +67,11 @@ CONFIG_RAM=y
> # CONFIG_STM32MP1_DDR is not set
> CONFIG_DM_RNG=y
> CONFIG_SERIAL_RX_BUFFER=y
> +CONFIG_SPI=y
> +CONFIG_DM_SPI=y
> # CONFIG_OPTEE_TA_AVB is not set
> CONFIG_WDT=y
> CONFIG_WDT_STM32MP=y
> CONFIG_WDT_ARM_SMC=y
> +# CONFIG_UBIFS_SILENCE_DEBUG_DUMP is not set
> CONFIG_ERRNO_STR=y
> diff --git a/include/configs/stm32mp25_common.h
> b/include/configs/stm32mp25_common.h
> index 542de8f068d..1c28ce1c1e9 100644
> --- a/include/configs/stm32mp25_common.h
> +++ b/include/configs/stm32mp25_common.h
> @@ -35,8 +35,15 @@
> #define BOOT_TARGET_MMC2(func)
> #endif
>
> +#ifdef CONFIG_CMD_UBIFS
> +#define BOOT_TARGET_UBIFS(func) func(UBIFS, ubifs, 0, UBI, boot)
> +#else
> +#define BOOT_TARGET_UBIFS(func)
> +#endif
> +
> #define BOOT_TARGET_DEVICES(func) \
> BOOT_TARGET_MMC1(func) \
> + BOOT_TARGET_UBIFS(func) \
> BOOT_TARGET_MMC0(func) \
> BOOT_TARGET_MMC2(func)
>
> @@ -44,6 +51,7 @@
> * default bootcmd for stm32mp25:
> * for serial/usb: execute the stm32prog command
> * for mmc boot (eMMC, SD card), distro boot on the same mmc device
> + * for NAND or SPI-NAND boot, distro boot with UBIFS on UBI partition
> * for other boot, use the default distro order in ${boot_targets}
> */
> #define STM32MP_BOOTCMD "bootcmd_stm32mp=" \
> @@ -54,6 +62,9 @@
> "run env_check;" \
> "if test ${boot_device} = mmc;" \
> "then env set boot_targets \"mmc${boot_instance}\"; fi;" \
> + "if test ${boot_device} = nand ||" \
> + " test ${boot_device} = spi-nand ;" \
> + "then env set boot_targets ubifs0; fi;" \
> "run distro_bootcmd;" \
> "fi;\0"
>
Applied to u-boot-stm32/master
Thanks
Patrice