Allow falcon boot from R5 SPL on TI's AM62 devices
Subsystems (3)
v9 cover Allow falcon boot from R5 SPL on TI's AM62 devices
Hi all,
This patch set adds support for falcon boot on AM62a, 62p and 62x by bypassing A53 SPL and U-boot.
Existing Boot flow:
R5 SPL -> ATF -> A53 SPL -> U-Boot -> Linux Kernel
Updated flow:
R5 SPL -> ATF -> Linux Kernel
U-Boot's falcon mode expects the jump from SPL to kernel to happen on the same core which is not directly applicable for our heterogeneous platforms since ATF, OPTEE and other non SPL binaries from tispl.bin should be loaded before the kernel by the R5 SPL.
So we have to use a different flow to bypass A53 SPL and U-Boot, we first load the newly added tispl_falcon.bin instead of tispl.bin which lacks u-boot-spl.bin (A53's SPL) and the corresponding fdt. This sets up dm, tifs, optee and atf. Once loaded, we load the kernel and the dtb (with fixups) at ATF's PRELOADED_BL33_BASE and K3_HW_CONFIG_BASE.
NOTE:
Since we're now using the SPL to load the kernel and kernel expects a 2MiB aligned load address, the existing PRELOADED_BL33_BASE has to be changed for ATF to 0x82000000 with K3_HW_CONFIG_BASE set to 0x88000000 for the DTB.
Depends on:
[PATCH v3 0/4] Allow falcon boot from A-core SPL on K3 devices
https://lore.kernel.org/u-boot/[email protected]/
---
Changes in v9:
* Update the boot flow diagram in documentation
* Refactor the documentation diagram into am62x_sk.rst
v8: https://lore.kernel.org/u-boot/[email protected]/
Changes in v8:
* Base the series on the recently added support for secure falcon mode
* Split the [8/10] patch of previous series to multiple commits
* Move R5 falcon mode logic from k3/common.c to k3/r5/common.c
* Load tifalcon.bin from rootfs even in raw eMMC boot to simplify usage
* Drop the section on 'SPI usage' in the documentation
v7: https://lore.kernel.org/u-boot/[email protected]/
Changes in v7:
* Replaced AM62a/p documentation with a hyperlink to AM62x's docs
* Made CMD_BOOTZ disabled for TI_SECURE_DEVICE
v6: https://lore.kernel.org/u-boot/[email protected]/
Changes in v6:
* Added A53 build steps in docs
* Had git add SVGs as text instead of blob
* Added memory map for standard boot flow
v5: https://lore.kernel.org/u-boot/[email protected]/
Changes in v5:
* Added documentation
* Moved address for kernel and dtb to 0x82000000 and 0x88000000 respectively
v4: https://lore.kernel.org/u-boot/[email protected]/
Changes in v4:
* Move emmc boot fixes to saperate patch
* Update load address for kernel to 0x82200000
* Add jump_stub config
v3: https://lore.kernel.org/u-boot/[email protected]/
Changes in v3:
* Make tifs load and entry address consistent with tispl for am62a and 62p
* Update loadables order to be same as tispl.bin
* Use rootfs for boot instead of boot partition
* Disable SPL_HAS_BOOTZ to save space
* Add default dtbs for each board in Kconfig
* Fix fdt totalsize in the header before applying fixups
* Update Makefile to clean tispl_falcon.bin on make clean
v2: https://lore.kernel.org/u-boot/[email protected]/
Changes in v2:
* Move to CONFIG_SYS_SPI_*
* Remove the need for CMD_BOOTI
v1: https://lore.kernel.org/u-boot/[email protected]/
---
Anshul Dalal (8):
arch: arm: k3-binman: add fit for falcon boot
configs: add falcon mode fragment for k3 devices
mach-k3: common: enable falcon mode from R5 SPL
mach-k3: common: support only MMC in R5 falcon mode
mach-k3: r5: common: add fdt fixups for falcon mode
mach-k3: r5: common: add bootargs to kernel's dtb
Makefile: add tifalcon.bin to CLEAN_FILES
doc: ti: document R5 falcon mode for AM62 platforms
Makefile | 2 +- arch/arm/dts/k3-am625-sk-binman.dtsi | 64 ++++ arch/arm/dts/k3-am62a-sk-binman.dtsi | 51 +++ arch/arm/dts/k3-am62p-sk-binman.dtsi | 51 +++ arch/arm/dts/k3-binman.dtsi | 54 +++ arch/arm/mach-k3/am62ax/am62a7_init.c | 3 + arch/arm/mach-k3/am62px/am62p5_init.c | 4 + arch/arm/mach-k3/am62x/am625_init.c | 3 + arch/arm/mach-k3/common.c | 8 + arch/arm/mach-k3/common.h | 5 + arch/arm/mach-k3/r5/common.c | 145 ++++++++ configs/k3_r5_falcon.config | 39 +++ doc/board/ti/am62ax_sk.rst | 31 ++ doc/board/ti/am62px_sk.rst | 31 ++ doc/board/ti/am62x_sk.rst | 319 ++++++++++++++++++ doc/board/ti/img/fitImage_falcon.svg | 180 ++++++++++ doc/board/ti/img/tifsstub_dm_tifalcon.bin.svg | 285 ++++++++++++++++ 17 files changed, 1274 insertions(+), 1 deletion(-) create mode 100644 configs/k3_r5_falcon.config create mode 100644 doc/board/ti/img/fitImage_falcon.svg create mode 100644 doc/board/ti/img/tifsstub_dm_tifalcon.bin.svg
Signature · 1 line
2.51.0
PATCH v9 1/8 arch: arm: k3-binman: add fit for falcon boot
This patch adds creation of tifalcon.bin for the AM62a, 62p and 62x.
The contents are the same as the existing tispl.bin but A53's SPL and the FDT have been removed as they are not needed in falcon boot.
This reduces boot time since the payload size is smaller compared to the regular tispl binary.
tispl.bin = TFA + TEE + TIFS-STUB + A53 SPL + FDT
tifalcon.bin = TFA + TEE + TIFS-STUB
--- arch/arm/dts/k3-am625-sk-binman.dtsi | 64 ++++++++++++++++++++++++++++ arch/arm/dts/k3-am62a-sk-binman.dtsi | 51 ++++++++++++++++++++++ arch/arm/dts/k3-am62p-sk-binman.dtsi | 51 ++++++++++++++++++++++ arch/arm/dts/k3-binman.dtsi | 54 +++++++++++++++++++++++ 4 files changed, 220 insertions(+)
arch/arm/dts/k3-am625-sk-binman.dtsi +64 -0
@@ -206,6 +206,70 @@ }; }; + ti-falcon { + insert-template = <&ti_falcon_template>; + + fit { + images { + tifsstub-hs { + description = "TIFSSTUB"; + type = "firmware"; + arch = "arm32"; + compression = "none"; + os = "tifsstub-hs"; + load = <0x9dc00000>; + entry = <0x9dc00000>; + blob-ext { + filename = "tifsstub.bin_hs"; + }; + }; + tifsstub-fs { + description = "TIFSSTUB"; + type = "firmware"; + arch = "arm32"; + compression = "none"; + os = "tifsstub-fs"; + load = <0x9dc00000>; + entry = <0x9dc00000>; + blob-ext { + filename = "tifsstub.bin_fs"; + }; + }; + tifsstub-gp { + description = "TIFSSTUB"; + type = "firmware"; + arch = "arm32"; + compression = "none"; + os = "tifsstub-gp"; + load = <0x9dc00000>; + entry = <0x9dc00000>; + blob-ext { + filename = "tifsstub.bin_gp"; + }; + }; + dm { + ti-secure { + content = <&dm_falcon>; + keyfile = "custMpk.pem"; + }; + dm_falcon: ti-dm { + filename = "ti-dm/am62xx/ipc_echo_testb_mcu1_0_release_strip.xer5f"; + }; + }; + }; + + configurations { + default = "conf-0"; + conf-0 { + description = "k3-am625-sk-falcon"; + firmware = "atf"; + loadables = "tee", "tifsstub-hs", "tifsstub-fs", + "tifsstub-gp", "dm"; + }; + }; + }; + }; + ti-spl { insert-template = <&ti_spl_template>;
arch/arm/dts/k3-am62a-sk-binman.dtsi +51 -0
57 lines not on this page · raw message
arch/arm/dts/k3-am62p-sk-binman.dtsi +51 -0
57 lines not on this page · raw message
arch/arm/dts/k3-binman.dtsi +54 -0
60 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH v9 2/8 configs: add falcon mode fragment for k3 devices
In reply to Anshul DalalThis fragment enables falcon boot for K3 platforms and modifies the memory map.
To have enough stack and heap space for loading kernel image as FIT the memory map was modified by expanding stack + heap size, the PRELOADED_BL33_BASE in TFA has to also be updated to 0x82000000 since the kernel requires to be loaded at 2MiB aligned address along with updating K3_HW_CONFIG_BASE to 0x88000000 for the DT passed to kernel.
Modified memory map for R5 SPL (modified addresses marked with *):
0x80000000 +-------------------------------+ Start of DDR
512KiB | TFA reserved memory space | CONFIG_K3_ATF_LOAD_ADDR*0x80080000 +-------------------------------+
31.5MiB | Unused |0x82000000 +-------------------------------+ PRELOADED_BL33_BASE* in TFA
| | CONFIG_SYS_LOAD_ADDR*
57MiB | Kernel + initramfs Image | CONFIG_SPL_LOAD_FIT_ADDRESS*
| |
0x85900000 +-------------------------------+
| |
| R5 U-Boot SPL Stack + Heap |
39MiB | (size defined by |
|SPL_STACK_R_MALLOC_SIMPLE_LEN*)|
| |
0x88000000 +-------------------------------+ CONFIG_SPL_STACK_R_ADDR*
| | K3_HW_CONFIG_BASE* in TFA
16MiB | Kernel DTB | CONFIG_SPL_PAYLOAD_ARGS_ADDR*
| |0x89000000 +-------------------------------+
331MiB | Device Manager (DM) Load Addr |0x9db00000 +-------------------------------+
12MiB | DM Reserved |0x9e700000 +-------------------------------+
1MiB | Unused |0x9e800000 +-------------------------------+ BL32_BASE in TFA
24MiB | OPTEE |0xa0000000 +-------------------------------+ End of DDR (512MiB)
--- configs/k3_r5_falcon.config | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 configs/k3_r5_falcon.config
configs/k3_r5_falcon.config new file +39 -0
@@ -0,0 +1,39 @@ +# Enable falcon mode +CONFIG_SPL_OS_BOOT=y +CONFIG_SPL_OS_BOOT_SECURE=y +CONFIG_SPL_LOAD_FIT=y + +# We use envs for setting bootargs +CONFIG_SPL_ENV_SUPPORT=y + +# Allows for the SPL to detect UUID for kernel's rootfs +CONFIG_SPL_PARTITION_UUIDS=y + +# Perform FDT fixups from SPL +CONFIG_OF_SYSTEM_SETUP=y + +# Disable all non MMC/SD FS boot media to save space +CONFIG_SPL_SYS_MMCSD_RAW_MODE=n +CONFIG_SPL_SPI_FLASH_SUPPORT=n +CONFIG_SPL_YMODEM_SUPPORT=n +CONFIG_SUPPORT_EMMC_BOOT=n +CONFIG_SPL_NAND_SUPPORT=n +CONFIG_SPL_NOR_SUPPORT=n +CONFIG_SPL_RAM_SUPPORT=n + +# Used as the 2MiB aligned load address for kernel +CONFIG_SYS_LOAD_ADDR=0x82000000 +CONFIG_SPL_STACK_R_ADDR=0x88000000 +CONFIG_SPL_LOAD_FIT_ADDRESS=0x82000000 +CONFIG_SPL_PAYLOAD_ARGS_ADDR=0x88000000 +CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2700000 + +# We use the rootfs (i.e partition 2) for booting which is ext4 not FAT +CONFIG_SYS_MMCSD_FS_BOOT=y +CONFIG_SYS_MMCSD_FS_BOOT_PARTITION=2 +CONFIG_SPL_FS_EXT4=y +CONFIG_SPL_FS_FAT=n + +# Loading tifalcon instead of tispl which has FDT and A53 SPL saves time +CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="boot/tifalcon.bin" +CONFIG_SPL_FS_LOAD_KERNEL_NAME="boot/fitImage"
Signature · 1 line
2.51.0
PATCH v9 3/8 mach-k3: common: enable falcon mode from R5 SPL
In reply to Anshul DalalWe use the spl_board_prepare_for_boot hook to call k3_r5_falcon_prep which is ran after tispl is loaded but before jump_to_image.
In k3_r5_falcon_prep, we find the boot media and load the kernel FIT just as standard secure falcon mode (since spl_start_uboot returns 0 now). Once the kernel and args are loaded.
Now when the flow goes to jump_to_image, we do the regular pre-jump procedure and jump to TFA which jumps to the kernel directly since we have already loaded the kernel and dtb at their respective addresses (PRELOADED_BL33_BASE and K3_HW_CONFIG_BASE).
--- arch/arm/mach-k3/common.c | 8 +++++++ arch/arm/mach-k3/common.h | 4 ++++ arch/arm/mach-k3/r5/common.c | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+)
arch/arm/mach-k3/common.c +8 -0
@@ -360,6 +360,14 @@ void spl_perform_arch_fixups(struct spl_image_info *spl_image)void spl_board_prepare_for_boot (void ) { +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int ret; + + ret =k3_r5_falcon_prep (); +if (ret) +panic ("%s: Failed to boot in falcon mode: %d\n" , __func__, ret); +#endif /* falcon mode on R5 SPL */ +#if !(defined(CONFIG_SYS_ICACHE_OFF ) && defined(CONFIG_SYS_DCACHE_OFF ))dcache_disable ();#endif
arch/arm/mach-k3/common.h +4 -0
@@ -52,6 +52,10 @@ void do_board_detect(void);void ti_secure_image_check_binary (void **p_image,size_t *p_size);int shutdown_mcu_r5_core1 (void ); +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int k3_r5_falcon_bootmode (void ); +#endif +#if (IS_ENABLED (CONFIG_K3_QOS ))void setup_qos (void );#else
arch/arm/mach-k3/r5/common.c +45 -0
48 lines not on this page · raw message
Signature · 1 line
2.51.0
Re: [PATCH v9 3/8] mach-k3: common: enable falcon mode from R5 SPL
Quoted 58 lines · Anshul Dalal
We use the
spl_board_prepare_for_boothook to callk3_r5_falcon_prepwhich is ran after tispl is loaded but beforejump_to_image.In
k3_r5_falcon_prep, we find the boot media and load the kernel FIT just as standard secure falcon mode (sincespl_start_ubootreturns 0 now). Once the kernel and args are loaded.Now when the flow goes to
jump_to_image, we do the regular pre-jump procedure and jump to TFA which jumps to the kernel directly since we have already loaded the kernel and dtb at their respective addresses (PRELOADED_BL33_BASEandK3_HW_CONFIG_BASE).Signed-off-by Anshul Dalal <[email protected]>--- arch/arm/mach-k3/common.c | 8 +++++++ arch/arm/mach-k3/common.h | 4 ++++ arch/arm/mach-k3/r5/common.c | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+)arch/arm/mach-k3/common.c +8
-0@@ -360,6 +360,14 @@ void spl_perform_arch_fixups(struct spl_image_info *spl_image)void spl_board_prepare_for_boot (void ) { +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int ret; + + ret =k3_r5_falcon_prep (); +if (ret) +panic ("%s: Failed to boot in falcon mode: %d\n" , __func__, ret); +#endif /* falcon mode on R5 SPL */ +#if !(defined(CONFIG_SYS_ICACHE_OFF ) && defined(CONFIG_SYS_DCACHE_OFF ))dcache_disable ();#endif arch/arm/mach-k3/common.h +4
-0@@ -52,6 +52,10 @@ void do_board_detect(void);void ti_secure_image_check_binary (void **p_image,size_t *p_size);int shutdown_mcu_r5_core1 (void ); +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int k3_r5_falcon_bootmode (void ); +#endif +#if (IS_ENABLED (CONFIG_K3_QOS ))void setup_qos (void );#else arch/arm/mach-k3/r5/common.c +0
-0
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 382
Quoted 7 lines
arch/arm/mach-k3/r5/common.c +4
-0@@ -376,3 +376,48 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image, } }#endif + +#ifdef CONFIG_SPL_OS_BOOT_SECURE + +static bool tifalcon_loaded;
Not strictly needed as statics will default to 0, assigning false here makes it more clear what the starting value should be,
static bool tifalcon_loaded = false;
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 391
Quoted 9 lines
arch/arm/mach-k3/r5/common.c +9
-0+ +int spl_start_uboot (void ) +{ +/* If tifalcon.bin is not loaded, proceed to regular boot */ +if (!tifalcon_loaded) +return 1 ; + +/* Boot to linux on R5 SPL with tifalcon.bin loaded */ +return 0 ;
Extra indent tab here.
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 401
Quoted 10 lines
arch/arm/mach-k3/r5/common.c +10
-0+} + +int k3_r5_falcon_prep (void ) +{ +struct spl_image_loader *loader, *drv; +struct spl_image_info kernel_image; +struct spl_boot_device bootdev; +int ret = -ENXIO , n_ents; + + tifalcon_loaded = true;
Should this be set down after we make sure loading doesn't fail?
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 410
Quoted 9 lines
arch/arm/mach-k3/r5/common.c +9
-0+memset (&kernel_image,'\0' ,sizeof (kernel_image)); + drv = ll_entry_start(struct spl_image_loader, spl_image_loader); + n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader); + bootdev.boot_device =spl_boot_device (); + +for (loader = drv; loader != drv + n_ents; loader++) { +if (bootdev.boot_device != loader->boot_device) +continue ; +if (loader) {
If loader is NULL, the if above containing loader->boot_device would have already null pointer deref crashed. You might want to move this check up into the if check above.
Andrew
Quoted 13 lines
arch/arm/mach-k3/r5/common.c +13
-0+printf ("Loading falcon payload from %s\n" , +spl_loader_name (loader)); + ret = loader->load_image (&kernel_image, &bootdev); +if (ret) +continue ; + + return 0; + } + } + +return ret; +} +#endif
Re: [PATCH v9 3/8] mach-k3: common: enable falcon mode from R5 SPL
Quoted 84 lines · Andrew Davis
Quoted 58 lines · Anshul Dalal
We use the
spl_board_prepare_for_boothook to callk3_r5_falcon_prepwhich is ran after tispl is loaded but beforejump_to_image.In
k3_r5_falcon_prep, we find the boot media and load the kernel FIT just as standard secure falcon mode (sincespl_start_ubootreturns 0 now). Once the kernel and args are loaded.Now when the flow goes to
jump_to_image, we do the regular pre-jump procedure and jump to TFA which jumps to the kernel directly since we have already loaded the kernel and dtb at their respective addresses (PRELOADED_BL33_BASEandK3_HW_CONFIG_BASE).Signed-off-by Anshul Dalal <[email protected]>--- arch/arm/mach-k3/common.c | 8 +++++++ arch/arm/mach-k3/common.h | 4 ++++ arch/arm/mach-k3/r5/common.c | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+)arch/arm/mach-k3/common.c +8
-0@@ -360,6 +360,14 @@ void spl_perform_arch_fixups(struct spl_image_info *spl_image)void spl_board_prepare_for_boot (void ) { +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int ret; + + ret =k3_r5_falcon_prep (); +if (ret) +panic ("%s: Failed to boot in falcon mode: %d\n" , __func__, ret); +#endif /* falcon mode on R5 SPL */ +#if !(defined(CONFIG_SYS_ICACHE_OFF ) && defined(CONFIG_SYS_DCACHE_OFF ))dcache_disable ();#endif arch/arm/mach-k3/common.h +4
-0@@ -52,6 +52,10 @@ void do_board_detect(void);void ti_secure_image_check_binary (void **p_image,size_t *p_size);int shutdown_mcu_r5_core1 (void ); +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int k3_r5_falcon_bootmode (void ); +#endif +#if (IS_ENABLED (CONFIG_K3_QOS ))void setup_qos (void );#else arch/arm/mach-k3/r5/common.c +0
-0arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 382
Quoted 7 lines
arch/arm/mach-k3/r5/common.c +4
-0@@ -376,3 +376,48 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image, } }#endif + +#ifdef CONFIG_SPL_OS_BOOT_SECURE + +static bool tifalcon_loaded;Not strictly needed as statics will default to 0, assigning false here makes it more clear what the starting value should be,
static bool
tifalcon_loaded= false;arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 391
Quoted 9 lines
arch/arm/mach-k3/r5/common.c +9
-0+ +int spl_start_uboot (void ) +{ +/* If tifalcon.bin is not loaded, proceed to regular boot */ +if (!tifalcon_loaded) +return 1 ; + +/* Boot to linux on R5 SPL with tifalcon.bin loaded */ +return 0 ;Extra indent tab here.
Quoted 13 lines
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 401
Quoted 10 lines
arch/arm/mach-k3/r5/common.c +10
-0+} + +int k3_r5_falcon_prep (void ) +{ +struct spl_image_loader *loader, *drv; +struct spl_image_info kernel_image; +struct spl_boot_device bootdev; +int ret = -ENXIO , n_ents; + + tifalcon_loaded = true;Should this be set down after we make sure loading doesn't fail?
That wouldn't work actually, tifalcon_loaded is used to detect if tifalcon.bin has been loaded or not. We then in-turn use this information in our two step boot process to decide whether or not to do falcon boot.
The call to load_image below will internally calls spl_start_uboot to check for falcon mode status, which will return 0 now allowing us to load fitImage.
So, the overall boot flow looks as follows:
board_init_r |-> boot_from_devices | +-> load_image (we load tifalcon.bin here since spl_start_uboot returns 1) | +-> spl_prepare_for_boot | +-> k3_falcon_prep | +-> load_image (we load fitImage here since spl_start_uboot returns 0 now) | +-> jump_to_image
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-k3/r5/common.c +5
-0+memset (&kernel_image,'\0' ,sizeof (kernel_image)); + drv = ll_entry_start(struct spl_image_loader, spl_image_loader); + n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader); + bootdev.boot_device =spl_boot_device (); +
Quoted 8 lines
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 410
Quoted 4 lines
arch/arm/mach-k3/r5/common.c +4
-0+for (loader = drv; loader != drv + n_ents; loader++) { +if (bootdev.boot_device != loader->boot_device) +continue ; +if (loader) {If loader is NULL, the if above containing
loader->boot_devicewould have already null pointer deref crashed. You might want to move this check up into the if check above.
You're right, this needs to be fixed. I was following a similar structure to boot_from_devices (common/spl/spl.c) which also seems to have the same issue.
Regards,
Anshul
Quoted 16 lines
Andrew
Quoted 13 lines
arch/arm/mach-k3/r5/common.c +13
-0+printf ("Loading falcon payload from %s\n" , +spl_loader_name (loader)); + ret = loader->load_image (&kernel_image, &bootdev); +if (ret) +continue ; + + return 0; + } + } + +return ret; +} +#endif
Re: [PATCH v9 3/8] mach-k3: common: enable falcon mode from R5 SPL
Quoted 134 lines · Anshul Dalal
Quoted 84 lines · Andrew Davis
Quoted 58 lines · Anshul Dalal
We use the
spl_board_prepare_for_boothook to callk3_r5_falcon_prepwhich is ran after tispl is loaded but beforejump_to_image.In
k3_r5_falcon_prep, we find the boot media and load the kernel FIT just as standard secure falcon mode (sincespl_start_ubootreturns 0 now). Once the kernel and args are loaded.Now when the flow goes to
jump_to_image, we do the regular pre-jump procedure and jump to TFA which jumps to the kernel directly since we have already loaded the kernel and dtb at their respective addresses (PRELOADED_BL33_BASEandK3_HW_CONFIG_BASE).Signed-off-by Anshul Dalal <[email protected]>--- arch/arm/mach-k3/common.c | 8 +++++++ arch/arm/mach-k3/common.h | 4 ++++ arch/arm/mach-k3/r5/common.c | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+)arch/arm/mach-k3/common.c +8
-0@@ -360,6 +360,14 @@ void spl_perform_arch_fixups(struct spl_image_info *spl_image)void spl_board_prepare_for_boot (void ) { +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int ret; + + ret =k3_r5_falcon_prep (); +if (ret) +panic ("%s: Failed to boot in falcon mode: %d\n" , __func__, ret); +#endif /* falcon mode on R5 SPL */ +#if !(defined(CONFIG_SYS_ICACHE_OFF ) && defined(CONFIG_SYS_DCACHE_OFF ))dcache_disable ();#endif arch/arm/mach-k3/common.h +4
-0@@ -52,6 +52,10 @@ void do_board_detect(void);void ti_secure_image_check_binary (void **p_image,size_t *p_size);int shutdown_mcu_r5_core1 (void ); +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int k3_r5_falcon_bootmode (void ); +#endif +#if (IS_ENABLED (CONFIG_K3_QOS ))void setup_qos (void );#else arch/arm/mach-k3/r5/common.c +0
-0arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 382
Quoted 7 lines
arch/arm/mach-k3/r5/common.c +4
-0@@ -376,3 +376,48 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image, } }#endif + +#ifdef CONFIG_SPL_OS_BOOT_SECURE + +static bool tifalcon_loaded;Not strictly needed as statics will default to 0, assigning false here makes it more clear what the starting value should be,
static bool
tifalcon_loaded= false;arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 391
Quoted 9 lines
arch/arm/mach-k3/r5/common.c +9
-0+ +int spl_start_uboot (void ) +{ +/* If tifalcon.bin is not loaded, proceed to regular boot */ +if (!tifalcon_loaded) +return 1 ; + +/* Boot to linux on R5 SPL with tifalcon.bin loaded */ +return 0 ;Extra indent tab here.
Quoted 13 lines
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 401
Quoted 10 lines
arch/arm/mach-k3/r5/common.c +10
-0+} + +int k3_r5_falcon_prep (void ) +{ +struct spl_image_loader *loader, *drv; +struct spl_image_info kernel_image; +struct spl_boot_device bootdev; +int ret = -ENXIO , n_ents; + + tifalcon_loaded = true;Should this be set down after we make sure loading doesn't fail?
That wouldn't work actually,
tifalcon_loadedis used to detect if tifalcon.bin has been loaded or not. We then in-turn use this information in our two step boot process to decide whether or not to do falcon boot.The call to
load_imagebelow will internally callsspl_start_ubootto check for falcon mode status, which will return 0 now allowing us to load fitImage.So, the overall boot flow looks as follows:
board_init_r |-> boot_from_devices | +-> load_image (we load tifalcon.bin here since spl_start_uboot returns 1) | +-> spl_prepare_for_boot | +-> k3_falcon_prep | +-> load_image (we load fitImage here since spl_start_uboot returns 0 now) | +-> jump_to_imageQuoted 5 lines
Quoted 5 lines
arch/arm/mach-k3/r5/common.c +5
-0+memset (&kernel_image,'\0' ,sizeof (kernel_image)); + drv = ll_entry_start(struct spl_image_loader, spl_image_loader); + n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader); + bootdev.boot_device =spl_boot_device (); +Quoted 8 lines
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 410
Quoted 4 lines
arch/arm/mach-k3/r5/common.c +4
-0+for (loader = drv; loader != drv + n_ents; loader++) { +if (bootdev.boot_device != loader->boot_device) +continue ; +if (loader) {If loader is NULL, the if above containing
loader->boot_devicewould have already null pointer deref crashed. You might want to move this check up into the if check above.
Quoted 3 lines
You're right, this needs to be fixed. I was following a similar structure to
boot_from_devices(common/spl/spl.c) which also seems to have the same issue.
common/spl/spl.c was fixed by ae409a84e7bff ("spl: NULL check variable before dereference")
Andrew
Quoted 20 lines
Regards,
AnshulQuoted 16 lines
Andrew
Quoted 13 lines
arch/arm/mach-k3/r5/common.c +13
-0+printf ("Loading falcon payload from %s\n" , +spl_loader_name (loader)); + ret = loader->load_image (&kernel_image, &bootdev); +if (ret) +continue ; + + return 0; + } + } + +return ret; +} +#endif
Re: [PATCH v9 3/8] mach-k3: common: enable falcon mode from R5 SPL
In reply to Anshul DalalQuoted 110 lines · Anshul Dalal
Quoted 84 lines · Andrew Davis
Quoted 58 lines · Anshul Dalal
We use the
spl_board_prepare_for_boothook to callk3_r5_falcon_prepwhich is ran after tispl is loaded but beforejump_to_image.In
k3_r5_falcon_prep, we find the boot media and load the kernel FIT just as standard secure falcon mode (sincespl_start_ubootreturns 0 now). Once the kernel and args are loaded.Now when the flow goes to
jump_to_image, we do the regular pre-jump procedure and jump to TFA which jumps to the kernel directly since we have already loaded the kernel and dtb at their respective addresses (PRELOADED_BL33_BASEandK3_HW_CONFIG_BASE).Signed-off-by Anshul Dalal <[email protected]>--- arch/arm/mach-k3/common.c | 8 +++++++ arch/arm/mach-k3/common.h | 4 ++++ arch/arm/mach-k3/r5/common.c | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+)arch/arm/mach-k3/common.c +8
-0@@ -360,6 +360,14 @@ void spl_perform_arch_fixups(struct spl_image_info *spl_image)void spl_board_prepare_for_boot (void ) { +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int ret; + + ret =k3_r5_falcon_prep (); +if (ret) +panic ("%s: Failed to boot in falcon mode: %d\n" , __func__, ret); +#endif /* falcon mode on R5 SPL */ +#if !(defined(CONFIG_SYS_ICACHE_OFF ) && defined(CONFIG_SYS_DCACHE_OFF ))dcache_disable ();#endif arch/arm/mach-k3/common.h +4
-0@@ -52,6 +52,10 @@ void do_board_detect(void);void ti_secure_image_check_binary (void **p_image,size_t *p_size);int shutdown_mcu_r5_core1 (void ); +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +int k3_r5_falcon_bootmode (void ); +#endif +#if (IS_ENABLED (CONFIG_K3_QOS ))void setup_qos (void );#else arch/arm/mach-k3/r5/common.c +0
-0arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 382
Quoted 7 lines
arch/arm/mach-k3/r5/common.c +4
-0@@ -376,3 +376,48 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image, } }#endif + +#ifdef CONFIG_SPL_OS_BOOT_SECURE + +static bool tifalcon_loaded;Not strictly needed as statics will default to 0, assigning false here makes it more clear what the starting value should be,
static bool
tifalcon_loaded= false;arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 391
Quoted 9 lines
arch/arm/mach-k3/r5/common.c +9
-0+ +int spl_start_uboot (void ) +{ +/* If tifalcon.bin is not loaded, proceed to regular boot */ +if (!tifalcon_loaded) +return 1 ; + +/* Boot to linux on R5 SPL with tifalcon.bin loaded */ +return 0 ;Extra indent tab here.
Quoted 13 lines
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 401
Quoted 10 lines
arch/arm/mach-k3/r5/common.c +10
-0+} + +int k3_r5_falcon_prep (void ) +{ +struct spl_image_loader *loader, *drv; +struct spl_image_info kernel_image; +struct spl_boot_device bootdev; +int ret = -ENXIO , n_ents; + + tifalcon_loaded = true;Should this be set down after we make sure loading doesn't fail?
That wouldn't work actually,
tifalcon_loadedis used to detect if tifalcon.bin has been loaded or not. We then in-turn use this information in our two step boot process to decide whether or not to do falcon boot.The call to
load_imagebelow will internally callsspl_start_ubootto check for falcon mode status, which will return 0 now allowing us to load fitImage.So, the overall boot flow looks as follows:
Quoted 10 lines
board_init_r |-> boot_from_devices | +-> load_image (we load tifalcon.bin here since spl_start_uboot returns 1) | +-> spl_prepare_for_boot | +-> k3_falcon_prep | +-> load_image (we load fitImage here since spl_start_uboot returns 0 now) | +-> jump_to_image
Okay, makes sense, thanks for explaining this out :)
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-k3/r5/common.c +5
-0+memset (&kernel_image,'\0' ,sizeof (kernel_image)); + drv = ll_entry_start(struct spl_image_loader, spl_image_loader); + n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader); + bootdev.boot_device =spl_boot_device (); +Quoted 8 lines
arch/arm/mach-k3/r5/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 410
Quoted 4 lines
arch/arm/mach-k3/r5/common.c +4
-0+for (loader = drv; loader != drv + n_ents; loader++) { +if (bootdev.boot_device != loader->boot_device) +continue ; +if (loader) {If loader is NULL, the if above containing
loader->boot_devicewould have already null pointer deref crashed. You might want to move this check up into the if check above.
Quoted 4 lines
You're right, this needs to be fixed. I was following a similar structure to
boot_from_devices(common/spl/spl.c) which also seems to have the same issue.
Looks like someone else found that also and just fixed it in spl.c:
https://github.com/u-boot/u-boot/commit/ae409a84e7bffb0c5a0d420d72806ac7b854f619
Andrew
Quoted 20 lines
Regards,
AnshulQuoted 16 lines
Andrew
Quoted 13 lines
arch/arm/mach-k3/r5/common.c +13
-0+printf ("Loading falcon payload from %s\n" , +spl_loader_name (loader)); + ret = loader->load_image (&kernel_image, &bootdev); +if (ret) +continue ; + + return 0; + } + } + +return ret; +} +#endif
PATCH v9 4/8 mach-k3: common: support only MMC in R5 falcon mode
In reply to Anshul DalalTo simplify the boot process and prevent the R5 SPL size from growing, this patch restricts the boot media to load the next stage payload (tifalcon.bin and kernel FIT) from MMC only.
--- arch/arm/mach-k3/am62ax/am62a7_init.c | 3 +++ arch/arm/mach-k3/am62px/am62p5_init.c | 4 ++++ arch/arm/mach-k3/am62x/am625_init.c | 3 +++ arch/arm/mach-k3/common.h | 1 + arch/arm/mach-k3/r5/common.c | 17 ++++++++++++++++- 5 files changed, 27 insertions(+), 1 deletion(-)
arch/arm/mach-k3/am62ax/am62a7_init.c +3 -0
@@ -240,5 +240,8 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 spl_boot_device (void ) { +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +return k3_r5_falcon_bootmode (); +#endif return get_boot_device (); }
arch/arm/mach-k3/am62px/am62p5_init.c +4 -0
@@ -375,6 +375,10 @@ u32 spl_boot_device(void)u32 devstat =readl (CTRLMMR_MAIN_DEVSTAT );u32 bootmedia; +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +return k3_r5_falcon_bootmode (); +#endif +if (bootindex ==K3_PRIMARY_BOOTMODE ) bootmedia =__get_primary_bootmedia (devstat);else
arch/arm/mach-k3/am62x/am625_init.c +3 -0
@@ -327,5 +327,8 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 spl_boot_device (void ) { +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +return k3_r5_falcon_bootmode (); +#endif return get_boot_device (); }
arch/arm/mach-k3/common.h +1 -0
@@ -54,6 +54,7 @@ int shutdown_mcu_r5_core1(void);#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 )int k3_r5_falcon_bootmode (void ); +int k3_r5_falcon_prep (void );#endif #if (IS_ENABLED (CONFIG_K3_QOS ))
arch/arm/mach-k3/r5/common.c +16 -1
@@ -391,6 +391,21 @@ int spl_start_uboot(void)return 0 ; } +int k3_r5_falcon_bootmode (void ) +{ +char *mmcdev =env_get ("mmcdev" ); + +if (!mmcdev) +return BOOT_DEVICE_NOBOOT ; + +if (strncmp (mmcdev,"0" ,sizeof ("0" )) ==0 ) +return BOOT_DEVICE_MMC1 ; +else if (strncmp (mmcdev,"1" ,sizeof ("1" )) ==0 ) +return BOOT_DEVICE_MMC2 ; +else +return BOOT_DEVICE_NOBOOT ; +} +int k3_r5_falcon_prep (void ) {struct spl_image_loader *loader, *drv;
@@ -402,7 +417,7 @@ int k3_r5_falcon_prep(void)memset (&kernel_image,'\0' ,sizeof (kernel_image)); drv = ll_entry_start(struct spl_image_loader, spl_image_loader); n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader); - bootdev.boot_device =spl_boot_device (); + bootdev.boot_device =k3_r5_falcon_bootmode ();for (loader = drv; loader != drv + n_ents; loader++) {if (bootdev.boot_device != loader->boot_device)
Signature · 1 line
2.51.0
Re: [PATCH v9 4/8] mach-k3: common: support only MMC in R5 falcon mode
Quoted 4 lines · Anshul Dalal
To simplify the boot process and prevent the R5 SPL size from growing, this patch restricts the boot media to load the next stage payload (tifalcon.bin and kernel FIT) from MMC only.
Is R5 SPL size the only reason? This seems rather restrictive to only support one boot mode with all this..
Quoted 14 lines
Signed-off-by Anshul Dalal <[email protected]>--- arch/arm/mach-k3/am62ax/am62a7_init.c | 3 +++ arch/arm/mach-k3/am62px/am62p5_init.c | 4 ++++ arch/arm/mach-k3/am62x/am625_init.c | 3 +++ arch/arm/mach-k3/common.h | 1 + arch/arm/mach-k3/r5/common.c | 17 ++++++++++++++++- 5 files changed, 27 insertions(+), 1 deletion(-)arch/arm/mach-k3/am62ax/am62a7_init.c +0
-0
arch/arm/mach-k3/am62ax/am62a7_init.c u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) · line 243
Quoted 4 lines
arch/arm/mach-k3/am62ax/am62a7_init.c +1
-0@@ -240,5 +240,8 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 spl_boot_device (void ) { +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 )
The check for CONFIG_ARM64 might not be needed, what if we want to falcon boot from A53 SPL right into Linux?
arch/arm/mach-k3/am62ax/am62a7_init.c u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) · line 245
Quoted 2 lines
arch/arm/mach-k3/am62ax/am62a7_init.c +2
-0+return k3_r5_falcon_bootmode (); +#endif
This should be an #else capturing the below return call, otherwise think about what the function looks like after the preprocessor step if the above is true:
u32 spl_boot_device(void)
{
return k3_r5_falcon_bootmode();
return get_boot_device();
}just seems odd.
Andrew
Quoted 77 lines
arch/arm/mach-k3/am62ax/am62a7_init.c +0
-0return get_boot_device (); }arch/arm/mach-k3/am62px/am62p5_init.c +4
-0@@ -375,6 +375,10 @@ u32 spl_boot_device(void)u32 devstat =readl (CTRLMMR_MAIN_DEVSTAT );u32 bootmedia; +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +return k3_r5_falcon_bootmode (); +#endif +if (bootindex ==K3_PRIMARY_BOOTMODE ) bootmedia =__get_primary_bootmedia (devstat);else arch/arm/mach-k3/am62x/am625_init.c +3
-0@@ -327,5 +327,8 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 spl_boot_device (void ) { +#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 ) +return k3_r5_falcon_bootmode (); +#endif return get_boot_device (); }arch/arm/mach-k3/common.h +1
-0@@ -54,6 +54,7 @@ int shutdown_mcu_r5_core1(void);#if IS_ENABLED (CONFIG_SPL_OS_BOOT_SECURE ) && !IS_ENABLED (CONFIG_ARM64 )int k3_r5_falcon_bootmode (void ); +int k3_r5_falcon_prep (void );#endif #if (IS_ENABLED (CONFIG_K3_QOS ))arch/arm/mach-k3/r5/common.c +16
-1@@ -391,6 +391,21 @@ int spl_start_uboot(void)return 0 ; } +int k3_r5_falcon_bootmode (void ) +{ +char *mmcdev =env_get ("mmcdev" ); + +if (!mmcdev) +return BOOT_DEVICE_NOBOOT ; + +if (strncmp (mmcdev,"0" ,sizeof ("0" )) ==0 ) +return BOOT_DEVICE_MMC1 ; +else if (strncmp (mmcdev,"1" ,sizeof ("1" )) ==0 ) +return BOOT_DEVICE_MMC2 ; +else +return BOOT_DEVICE_NOBOOT ; +} +int k3_r5_falcon_prep (void ) {struct spl_image_loader *loader, *drv;@@ -402,7 +417,7 @@ int k3_r5_falcon_prep(void)memset (&kernel_image,'\0' ,sizeof (kernel_image)); drv = ll_entry_start(struct spl_image_loader, spl_image_loader); n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader); - bootdev.boot_device =spl_boot_device (); + bootdev.boot_device =k3_r5_falcon_bootmode ();for (loader = drv; loader != drv + n_ents; loader++) {if (bootdev.boot_device != loader->boot_device)
Re: [PATCH v9 4/8] mach-k3: common: support only MMC in R5 falcon mode
Quoted 8 lines · Andrew Davis
Quoted 4 lines · Anshul Dalal
To simplify the boot process and prevent the R5 SPL size from growing, this patch restricts the boot media to load the next stage payload (tifalcon.bin and kernel FIT) from MMC only.
Is R5 SPL size the only reason? This seems rather restrictive to only support one boot mode with all this..
For most non MMC FS boot modes, the raw offsets that U-Boot uses are common in the non-falcon and falcon mode. And since we need both the boot flows to first load tifalcon.bin and then fitImage, we can't make use of the common spl boot flow with those boot media. For MMC FS however we have two separate configs namely SPL_FS_LOAD_PAYLOAD_NAME and SPL_FS_LOAD_KERNEL_NAME for each.
This also simplifies the usage where the tiboot3.bin as the intial stage bootloader can be loaded from any boot media with the catch being that tifalcon.bin and fitImage both are loaded from MMC FS. Specifically the boot directory in rootfs, which simplifies the yocto recipes as well.
Quoted 16 lines
Quoted 16 lines
Signed-off-by Anshul Dalal <[email protected]> ---arch/arm/mach-k3/am62ax/am62a7_init.c | 3 +++ arch/arm/mach-k3/am62px/am62p5_init.c | 4 ++++ arch/arm/mach-k3/am62x/am625_init.c | 3 +++ arch/arm/mach-k3/common.h | 1 + arch/arm/mach-k3/r5/common.c | 17 ++++++++++++++++- 5 fileschanged, 27 insertions(+), 1 deletion(-)
(quoted diff) +0
-0
b/arch/arm/mach-k3/am62ax/am62a7_init.cindex48d578e7d6f..1c8a5fd2a35100644 ---a/arch/arm/mach-k3/am62ax/am62a7_init.c+++b/arch/arm/mach-k3/am62ax/am62a7_init.c@@ -240,5 +240,8 @@ u32spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
Quoted 5 lines
Quoted 2 lines
u32 spl_boot_device(void) { +#if IS_ENABLED(CONFIG_SPL_OS_BOOT_SECURE) && !IS_ENABLED(CONFIG_ARM64)The check for
CONFIG_ARM64might not be needed, what if we want to falcon boot from A53 SPL right into Linux?
I have a separate series[1] adding support for A53 falcon mode and we can use all falcon supported boot media from the A53 SPL there so an k3_r5_falcon_bootmode equivalent is not necessary.
[1]: https://lore.kernel.org/u-boot/[email protected]/
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ return k3_r5_falcon_bootmode(); +#endifThis should be an #else capturing the below return call, otherwise think about what the function looks like after the preprocessor step if the above is true:
Quoted 5 lines
u32
spl_boot_device(void){ returnk3_r5_falcon_bootmode(); returnget_boot_device(); }just seems odd.
Will fix in the next revision, Thanks!
Regards,
Anshul
Quoted 54 lines
Andrew
Quoted 52 lines
return get_boot_device(); } diff --git a/arch/arm/mach-k3/am62px/am62p5_init.c b/arch/arm/mach-k3/am62px/am62p5_init.c index aebd5200b0d..4c215d5cebe 100644 --- a/arch/arm/mach-k3/am62px/am62p5_init.c +++ b/arch/arm/mach-k3/am62px/am62p5_init.c @@ -375,6 +375,10 @@ u32 spl_boot_device(void) u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT); u32 bootmedia;+#if
IS_ENABLED(CONFIG_SPL_OS_BOOT_SECURE)&&
!IS_ENABLED(CONFIG_ARM64) + returnk3_r5_falcon_bootmode(); +#endif
+ if (bootindex ==K3_PRIMARY_BOOTMODE) bootmedia =__get_primary_bootmedia(devstat); else diff --gita/arch/arm/mach-k3/am62x/am625_init.cb/arch/arm/mach-k3/am62x/am625_init.cindex14f93ac998f..44b8d2654b2100644 ---a/arch/arm/mach-k3/am62x/am625_init.c+++b/arch/arm/mach-k3/am62x/am625_init.c@@ -327,5 +327,8 @@ u32spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)u32 spl_boot_device(void) { +#if IS_ENABLED(CONFIG_SPL_OS_BOOT_SECURE) && !IS_ENABLED(CONFIG_ARM64) + return k3_r5_falcon_bootmode(); +#endif return get_boot_device(); } diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index 5807d358464..cd3e19374dc 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -54,6 +54,7 @@ int shutdown_mcu_r5_core1(void); #if IS_ENABLED(CONFIG_SPL_OS_BOOT_SECURE) && !IS_ENABLED(CONFIG_ARM64) int k3_r5_falcon_bootmode(void); +int k3_r5_falcon_prep(void); #endif #if (IS_ENABLED(CONFIG_K3_QOS)) diff --git a/arch/arm/mach-k3/r5/common.c b/arch/arm/mach-k3/r5/common.c index 439dd92ef54..aa94c0c1956 100644 --- a/arch/arm/mach-k3/r5/common.c +++ b/arch/arm/mach-k3/r5/common.c @@ -391,6 +391,21 @@ int spl_start_uboot(void) return 0; }+int
k3_r5_falcon_bootmode(void)+{ + char *mmcdev =env_get("mmcdev"); + + if (!mmcdev) + returnBOOT_DEVICE_NOBOOT; + + if (strncmp(mmcdev, "0", sizeof("0"))==
0) + returnBOOT_DEVICE_MMC1; + else if (strncmp(mmcdev,
"1",sizeof("1")) == 0) + returnBOOT_DEVICE_MMC2; + else(quoted diff) +1
-0+ return BOOT_DEVICE_NOBOOT; +} + int
k3_r5_falcon_prep(void){ structspl_image_loader*loader, *drv; @@ -402,7 +417,7 @@ intk3_r5_falcon_prep(void)memset(&kernel_image, '\0', sizeof(kernel_image)); drv =ll_entry_start(struct spl_image_loader, spl_image_loader);n_ents= ll_entry_count(structspl_image_loader,spl_image_loader); - bootdev.boot_device =spl_boot_device(); + bootdev.boot_device =k3_r5_falcon_bootmode();for (loader = drv; loader != drv +
n_ents; loader++) { if (bootdev.boot_device !=loader->boot_device)
PATCH v9 5/8 mach-k3: r5: common: add fdt fixups for falcon mode
In reply to Anshul DalalThis patch adds fdt fixups to the kernel device-tree in R5 falcon mode, these fixups include fixing up the core-count, reserved-memory etc.
The users can opt out by disabling the respective CONFIG_OF_*_SETUP config options.
--- arch/arm/mach-k3/r5/common.c | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
arch/arm/mach-k3/r5/common.c +38 -0
@@ -406,12 +406,43 @@ int k3_r5_falcon_bootmode(void)return BOOT_DEVICE_NOBOOT ; } +static int k3_falcon_fdt_fixup (void *fdt) +{ +int ret; + +if (!fdt) +return -EINVAL ; + +fdt_set_totalsize (fdt,fdt_totalsize (fdt) +CONFIG_SYS_FDT_PAD ); + +if (IS_ENABLED (CONFIG_OF_BOARD_SETUP )) { + ret =ft_board_setup (fdt, gd->bd); +if (ret) { +printf ("%s: Failed in board fdt fixups: %s\n" , __func__, +fdt_strerror (ret)); +return ret; + } + } + +if (IS_ENABLED (CONFIG_OF_SYSTEM_SETUP )) { + ret =ft_system_setup (fdt, gd->bd); +if (ret) { +printf ("%s: Failed in system fdt fixups: %s\n" , + __func__,fdt_strerror (ret)); +return ret; + } + } + +return 0 ; +} +int k3_r5_falcon_prep (void ) {struct spl_image_loader *loader, *drv;struct spl_image_info kernel_image;struct spl_boot_device bootdev;int ret = -ENXIO , n_ents; +void *fdt; tifalcon_loaded = true;memset (&kernel_image,'\0' ,sizeof (kernel_image));
@@ -429,6 +460,13 @@ int k3_r5_falcon_prep(void)if (ret)continue ; + fdt =spl_image_fdt_addr (&kernel_image); + ret =k3_falcon_fdt_fixup (fdt); +if (ret) { +printf ("%s: Failed performing fdt fixups in falcon flow: [%d]\n" , + __func__, ret); +return ret; + }return 0 ; } }
Signature · 1 line
2.51.0
PATCH v9 6/8 mach-k3: r5: common: add bootargs to kernel's dtb
In reply to Anshul DalalThe bootargs are passed to the kernel in the chosen node, this patch adds support for populating bootargs in the dtb if missing.
The values for kernel boot params is taken from the env with, 'boot' and 'bootpart' specifying the rootfs for the kernel.
--- arch/arm/mach-k3/r5/common.c | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
arch/arm/mach-k3/r5/common.c +47 -0
@@ -406,6 +406,46 @@ int k3_r5_falcon_bootmode(void)return BOOT_DEVICE_NOBOOT ; } +static int k3_falcon_fdt_add_bootargs (void *fdt) +{ +struct disk_partition info; +struct blk_desc *dev_desc; +char bootmedia[32 ]; +char bootpart[32 ]; +char str[256 ]; +int ret; + +strlcpy (bootmedia,env_get ("boot" ),sizeof (bootmedia)); +strlcpy (bootpart,env_get ("bootpart" ),sizeof (bootpart)); + ret =blk_get_device_part_str (bootmedia, bootpart, &dev_desc, &info,0 ); +if (ret <0 ) { +printf ("%s: Failed to get part details for %s %s [%d]\n" , + __func__, bootmedia, bootpart, ret); +return ret; + } + +if (!CONFIG_IS_ENABLED (PARTITION_UUIDS )) { +printf ("ERROR: Failed to find rootfs PARTUUID\n" ); +printf ("%s: CONFIG_SPL_PARTITION_UUIDS not enabled\n" , + __func__); +return -EOPNOTSUPP ; + } + +snprintf (str,sizeof (str),"console=%s root=PARTUUID=%s rootwait" , +env_get ("console" ),disk_partition_uuid (&info)); + + ret =fdt_find_and_setprop (fdt,"/chosen" ,"bootargs" , str, +strlen (str) +1 ,1 ); +if (ret) { +printf ("%s: Could not set bootargs: %s\n" , __func__, +fdt_strerror (ret)); +return ret; + } + +debug ("Set bootargs to: %s\n" , str); +return 0 ; +} +static int k3_falcon_fdt_fixup (void *fdt) {int ret;
@@ -415,6 +455,13 @@ static int k3_falcon_fdt_fixup(void *fdt)fdt_set_totalsize (fdt,fdt_totalsize (fdt) +CONFIG_SYS_FDT_PAD ); +if (fdt_path_offset (fdt,"/chosen/bootargs" ) <0 ) { + ret =k3_falcon_fdt_add_bootargs (fdt); + +if (ret) +return ret; + } +if (IS_ENABLED (CONFIG_OF_BOARD_SETUP )) { ret =ft_board_setup (fdt, gd->bd);if (ret) {
Signature · 1 line
2.51.0
PATCH v9 7/8 Makefile: add tifalcon.bin to CLEAN_FILES
In reply to Anshul DalalBuilds for A53 on AM62 platforms now generates tifalcon.bin alongside tispl.bin, add it to CLEAN_FILES to make sure the file gets deleted on make clean.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -2470,7 +2470,7 @@ CLEAN_FILES += include/autoconf.mk* include/bmp_logo.h include/bmp_logo_data.h \ idbloader-spi.img lib/efi_loader/helloworld_efi.S *.itb \ Test* capsule*.*.efi-capsule capsule*.map mkimage.imx-boot.spl \ mkimage.imx-boot.u-boot mkimage-out.imx-boot.spl mkimage-out.imx-boot.u-boot \ - imx9image* m33-oei-ddrfw* + imx9image* m33-oei-ddrfw* tifalcon.bin # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include/generated spl tpl vpl \
Signature · 1 line
2.51.0
PATCH v9 8/8 doc: ti: document R5 falcon mode for AM62 platforms
In reply to Anshul DalalThis patch adds user documentation for falcon boot for AM62 platforms. The main section is added to am62x_sk.rst and other documents just include the section. Steps to build falcon support, usage and the modified R5 memory map have been documented.
Two svg images have also been added for reference, one for the modified tifalcon.bin and other for the falcon specific fitImage format.
--- doc/board/ti/am62ax_sk.rst | 31 ++ doc/board/ti/am62px_sk.rst | 31 ++ doc/board/ti/am62x_sk.rst | 319 ++++++++++++++++++ doc/board/ti/img/fitImage_falcon.svg | 180 ++++++++++ doc/board/ti/img/tifsstub_dm_tifalcon.bin.svg | 285 ++++++++++++++++ 5 files changed, 846 insertions(+) create mode 100644 doc/board/ti/img/fitImage_falcon.svg create mode 100644 doc/board/ti/img/tifsstub_dm_tifalcon.bin.svg
doc/board/ti/am62ax_sk.rst +31 -0
@@ -187,6 +187,37 @@ https://www.ti.com/lit/pdf/spruj16 under the `Boot Mode Pins` section. For SW2 and SW1, the switch state in the "ON" position = 1. +Falcon Mode +----------- + +Falcon Mode on AM62ax platforms bypasses the A53 SPL and U-Boot with the overall +boot flow as below: + +.. include:: am62x_sk.rst + :start-after: .. am62x_evm_falcon_start_boot_flow + :end-before: .. am62x_evm_falcon_end_boot_flow + +Build Process +^^^^^^^^^^^^^ + +.. include:: am62x_sk.rst + :start-after: .. am62x_evm_falcon_start_build_process + :end-before: .. am62x_evm_falcon_end_build_process + +Usage +^^^^^ + +.. include:: am62x_sk.rst + :start-after: .. am62x_evm_falcon_start_usage + :end-before: .. am62x_evm_falcon_end_usage + +R5 SPL Memory Map +^^^^^^^^^^^^^^^^^ + +.. include:: am62x_sk.rst + :start-after: .. am62x_evm_falcon_start_r5_memory_map + :end-before: .. am62x_evm_falcon_end_r5_memory_map + Debugging U-Boot ----------------
doc/board/ti/am62px_sk.rst +31 -0
@@ -290,6 +290,37 @@ https://www.ti.com/lit/pdf/spruj83 under the `Boot Mode Pins` section. For SW2 and SW1, the switch state in the "ON" position = 1. +Falcon Mode +----------- + +Falcon Mode on AM62px platforms bypasses the A53 SPL and U-Boot with the overall +boot flow as below: + +.. include:: am62x_sk.rst + :start-after: .. am62x_evm_falcon_start_boot_flow + :end-before: .. am62x_evm_falcon_end_boot_flow + +Build Process +^^^^^^^^^^^^^ + +.. include:: am62x_sk.rst + :start-after: .. am62x_evm_falcon_start_build_process + :end-before: .. am62x_evm_falcon_end_build_process + +Usage +^^^^^ + +.. include:: am62x_sk.rst + :start-after: .. am62x_evm_falcon_start_usage + :end-before: .. am62x_evm_falcon_end_usage + +R5 SPL Memory Map +^^^^^^^^^^^^^^^^^ + +.. include:: am62x_sk.rst + :start-after: .. am62x_evm_falcon_start_r5_memory_map + :end-before: .. am62x_evm_falcon_end_r5_memory_map + Debugging U-Boot ----------------
doc/board/ti/am62x_sk.rst +319 -0
325 lines not on this page · raw message
doc/board/ti/img/fitImage_falcon.svg new file +180 -0
180 lines not on this page · raw message
doc/board/ti/img/tifsstub_dm_tifalcon.bin.svg new file +285 -0
285 lines not on this page · raw message
Signature · 1 line
2.51.0