[PATCH 7/8] stm32mp: stm32prog: handle U-Boot script in flashlayout alternate

Patrice CHOTARD patrice.chotard at foss.st.com
Fri Apr 22 09:43:03 CEST 2022


Hi Patrick

On 3/28/22 19:25, Patrick Delaunay wrote:
> Update the stm32prog command to allow the reception of U-Boot script in
> the FlashLayout alternate during the first USB enumeration.
> 
> This patch is aligned with the last TF-A behavior: the Flashlayout
> is now loaded by U-Boot; it is no more present at STM32_DDR_BASE when
> the stm32prog is launched after a serial boot, on UART or on USB.
> 
> The received script must be a U-Boot legacy image, no more need to add
> a stm32image header.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
> ---
> 
>  arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c | 9 ++-------
>  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c     | 9 +++++++++
>  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h     | 2 ++
>  3 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
> index 3957e06e5d..f59414e716 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
> @@ -76,13 +76,6 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,
>  		stm32prog_header_check(addr, &header);
>  		if (header.type == HEADER_STM32IMAGE) {
>  			size = header.image_length + header.length;
> -
> -#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
> -			/* uImage detected in STM32IMAGE, execute the script */
> -			if (IMAGE_FORMAT_LEGACY ==
> -			    genimg_get_format((void *)(addr + header.length)))
> -				return image_source_script(addr + header.length, "script at 1");
> -#endif
>  		}
>  	}
>  
> @@ -160,6 +153,8 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,
>  		else if (CONFIG_IS_ENABLED(CMD_BOOTZ))
>  			do_bootz(cmdtp, 0, 4, bootm_argv);
>  	}
> +	if (data->script)
> +		image_source_script(data->script, "script at stm32prog");
>  
>  	if (reset) {
>  		puts("Reset...\n");
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> index d3b3e1ed72..65655e25ca 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> @@ -6,6 +6,7 @@
>  #include <command.h>
>  #include <console.h>
>  #include <dfu.h>
> +#include <image.h>
>  #include <malloc.h>
>  #include <misc.h>
>  #include <mmc.h>
> @@ -1697,6 +1698,14 @@ error:
>  static void stm32prog_end_phase(struct stm32prog_data *data, u64 offset)
>  {
>  	if (data->phase == PHASE_FLASHLAYOUT) {
> +#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
> +		if (genimg_get_format((void *)STM32_DDR_BASE) == IMAGE_FORMAT_LEGACY) {
> +			data->script = STM32_DDR_BASE;
> +			data->phase = PHASE_END;
> +			log_notice("U-Boot script received\n");
> +			return;
> +		}
> +#endif
>  		if (parse_flash_layout(data, STM32_DDR_BASE, 0))
>  			stm32prog_err("Layout: invalid FlashLayout");
>  		return;
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
> index b3e5c74810..ac300768ca 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
> @@ -170,6 +170,8 @@ struct stm32prog_data {
>  	u32	initrd;
>  	u32	initrd_size;
>  
> +	u32	script;
> +
>  	/* OPTEE PTA NVMEM */
>  	struct udevice *tee;
>  	u32 tee_session;

Reviewed-by: Patrice Chotard <patrice.chotard at foss.st.com>
Thanks
Patrice


More information about the U-Boot mailing list