[PATCH 02/10] stm32mp1: Add support for falcon mode boot from SD card

Patrick DELAUNAY patrick.delaunay at foss.st.com
Tue Aug 31 18:30:07 CEST 2021


Hi,

Add in CC the MAINTAINERS

On 8/26/21 11:42 PM, Alexandru Gagniuc wrote:
> Falcon mode requires a board-specific mechanism to select between
> fast and normal boot. This is done via spl_start_uboot()
>
> Use the B2 button as the selection mechanism. This is connected to
> GPIO PA13. Incidentally, this GPIO is already accessible via the
> "st,fastboot-gpios" devicetree node.
>
> Offsets for raw MMC loading are defined. These point to the partition
> after "ssbl".
>
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me at gmail.com>
> ---
>   board/st/stm32mp1/spl.c    | 39 ++++++++++++++++++++++++++++++++++++++
>   include/configs/stm32mp1.h | 13 +++++++++++++
>   2 files changed, 52 insertions(+)
>
> diff --git a/board/st/stm32mp1/spl.c b/board/st/stm32mp1/spl.c
> index 8e4549a1b3..bb210d7727 100644
> --- a/board/st/stm32mp1/spl.c
> +++ b/board/st/stm32mp1/spl.c
> @@ -8,6 +8,7 @@
>   #include <init.h>
>   #include <asm/io.h>
>   #include <asm/arch/sys_proto.h>
> +#include <asm/gpio.h>
>   #include <linux/bitops.h>
>   #include <linux/delay.h>
>   #include "../common/stpmic1.h"
> @@ -29,6 +30,44 @@ int board_early_init_f(void)
>   	return 0;
>   }
>   
> +#if IS_ENABLED(CONFIG_SPL_OS_BOOT)
> +int spl_start_uboot(void)
> +{
> +	ofnode node;
> +	struct gpio_desc gpio;
> +	int boot_uboot = 1;
> +
> +	node = ofnode_path("/config");
> +	if (!ofnode_valid(node)) {
> +		pr_warn("%s: no /config node?\n", __func__);
> +		return 0;
> +	}
> +
> +	if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0, &gpio,
> +				       GPIOD_IS_IN)) {
> +		pr_warn("%s: could not find a /config/st,fastboot-gpios\n",
> +			__func__);
> +		return 1;
> +	}

The node "st,fastboot-gpios" is used in STMicroelectronics devicetree / board
to select the KEY to launch the ANDROID command fastboot in board_key_check()

=> it can't be re-used to other purpose else you will have conflict when the key
    is pressed:
    
    what append when key pressed in basic boot mode when KEY is pressed ?
    => falcon mode selected in SPL or FASTBOOT mode selected ....

"st,fastboot-gpios" meaning is defined in:

https://wiki.st.com/stm32mpu/wiki/How_to_configure_U-Boot_for_your_board#Config_node

you should use a other config ?
=> "mrnuke,falcon-gpios" managed in your board .c file / dts file

or hardcoded in your board.c ?

or use environment....
if (env_get_yesno("boot_os") != 0)

> +
> +	boot_uboot = dm_gpio_get_value(&gpio);
> +	dm_gpio_free(NULL, &gpio);
> +
> +	return boot_uboot;
> +}
> +
> +#if IS_ENABLED(CONFIG_ARMV7_NONSEC)
> +/*
> + * A bit of a hack, but armv7_boot_nonsec() is provided by bootm.c. This is not
> + * available in SPL, so we have to provide an implementation.
> + */
> +bool armv7_boot_nonsec(void)
> +{
> +	return 0;
> +}
> +#endif /* CONFIG_ARMV7_NONSEC */
> +#endif /* CONFIG_SPL_OS_BOOT */
> +
>   #ifdef CONFIG_DEBUG_UART_BOARD_INIT
>   void board_debug_uart_init(void)
>   {
> diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
> index 9fcd60285a..0849a1bddb 100644
> --- a/include/configs/stm32mp1.h
> +++ b/include/configs/stm32mp1.h
> @@ -10,6 +10,19 @@
>   #include <linux/sizes.h>
>   #include <asm/arch/stm32.h>
>   
> +/*
> + * Arguments if falcon mode is used
> + * CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR is the partition after "ssbl"
> + * CONFIG_SYS_SPL_ARGS_ADDR is not used, but needs to point to valid RAM.
> + */
> +#define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR 5154

The offset of kernel is hardcoded

=> it is not acceptable here (generic stm32mp1 file)

> +#define CONFIG_SYS_SPL_ARGS_ADDR 0xc4000000
> +
> +/* Falcon mode from SPI is not supported, but the defines are needed */
> +#define CONFIG_SYS_SPI_KERNEL_OFFS	(~0)
> +#define CONFIG_SYS_SPI_ARGS_OFFS	(~0)
> +#define CONFIG_SYS_SPI_ARGS_SIZE	0
> +

Falcon mode is not supported by ST Microelectronics
and this file is expected to support the ST boards (board/st/stm32mp1)

=> these defines should be in your configuration not in the GENERIC stm32mp1 files

for example in

include/configs/stm32mp15_falcon.h

#include "stm32mp1.h"

....

with CONFIG_SYS_CONFIG_NAME =  "stm32mp15_falcon" in your Kconfig


>   #ifndef CONFIG_TFABOOT
>   /* PSCI support */
>   #define CONFIG_ARMV7_SECURE_BASE		STM32_SYSRAM_BASE


Patrick



More information about the U-Boot mailing list