U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x
@ 2025-03-11  9:57 Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 1/8] spl: Kconfig: allow K3 devices to use falcon mode Anshul Dalal
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-03-11  9:57 UTC (permalink / raw)
  To: u-boot; +Cc: Anshul Dalal, vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

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 flow 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 non std 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 0x80200000.

This patch depends on:

 * [PATCH v3] spl: return header size to spl_load in os boot [1]
 * [PATCH v2] config: falcon: move CFG_SYS_SPI_* to Kconfig [2]
 * [PATCH v1] spl: remove usage of CMD_(BOOTI|BOOTZ) from image parsing [3]

[1]: https://lore.kernel.org/u-boot/20250311093546.3371193-1-anshuld@ti.com/
[2]: https://lore.kernel.org/u-boot/20250311044414.3155688-1-anshuld@ti.com/
[3]: https://lore.kernel.org/u-boot/20250311093709.3372104-1-anshuld@ti.com/

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
Changes in v2:
 * Move to CONFIG_SYS_SPI_* as per [2]
 * Remove the need for CMD_BOOTI as per [3]
v1: https://lore.kernel.org/u-boot/20250307075541.2571104-1-anshuld@ti.com/
---
Anshul Dalal (8):
  spl: Kconfig: allow K3 devices to use falcon mode
  mach-k3: fix reading size and addr from fdt on R5
  arm: dts: am62a: allow booting from eMMC
  arch: arm: k3-binman: add fit for falcon boot
  mach-k3: add eMMC FS boot support for am62[ap]
  mach-k3: sysfw-loader: update img_hdr for falcon
  config: add falcon boot config fragment for am62x
  mach-k3: common: add falcon support for 62[axp]

 arch/arm/dts/k3-am625-sk-binman.dtsi  |  64 ++++++++++++++++
 arch/arm/dts/k3-am62a-sk-binman.dtsi  |  64 ++++++++++++++++
 arch/arm/dts/k3-am62a7-sk-u-boot.dtsi |   4 +
 arch/arm/dts/k3-am62p-sk-binman.dtsi  |  51 +++++++++++++
 arch/arm/dts/k3-binman.dtsi           |  53 +++++++++++++
 arch/arm/mach-k3/am62ax/am62a7_init.c |   4 +
 arch/arm/mach-k3/am62px/am62p5_init.c |   4 +
 arch/arm/mach-k3/common.c             | 105 ++++++++++++++++++++++++++
 arch/arm/mach-k3/common_fdt.c         |   4 +-
 arch/arm/mach-k3/r5/sysfw-loader.c    |   6 +-
 common/spl/Kconfig                    |   3 +-
 configs/am62x_r5_falcon.config        |  36 +++++++++
 12 files changed, 395 insertions(+), 3 deletions(-)
 create mode 100644 configs/am62x_r5_falcon.config

-- 
2.43.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/8] spl: Kconfig: allow K3 devices to use falcon mode
  2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
@ 2025-03-11  9:57 ` Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 2/8] mach-k3: fix reading size and addr from fdt on R5 Anshul Dalal
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-03-11  9:57 UTC (permalink / raw)
  To: u-boot; +Cc: Anshul Dalal, vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

Falcon mode was disabled for TI_SECURE_DEVICE at commit e95b9b4437bc
("ti_armv7_common: Disable Falcon Mode on HS devices") for older 32-bit
HS devices and can be enabled on K3 devices.

For secure boot, the kernel with x509 headers can be packaged in a fit
container (fitImage) signed with TIFS keys for authentication.

We also set the default SPL_PAYLOAD_ARGS_ADDR which holds the DTB to
match ATF's K3_HW_CONFIG_BASE.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
 common/spl/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 21a5cefee7a..caa6c50c176 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1148,7 +1148,7 @@ config SPL_ONENAND_SUPPORT
 
 config SPL_OS_BOOT
 	bool "Activate Falcon Mode"
-	depends on !TI_SECURE_DEVICE
+	depends on !TI_SECURE_DEVICE || ARCH_K3
 	help
 	  Enable booting directly to an OS from SPL.
 	  for more info read doc/README.falcon
@@ -1156,6 +1156,7 @@ config SPL_OS_BOOT
 config SPL_PAYLOAD_ARGS_ADDR
 	hex "Address in memory to load 'args' file for Falcon Mode to"
 	depends on SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT
+	default 0x82000000 if ARCH_K3
 	default 0x88000000 if ARCH_OMAP2PLUS
 	default 0x99000000 if ARCH_SC5XX && SC59X_64
 	default 0xA0000000 if ARCH_SC5XX && TARGET_SC594_SOM_EZKIT
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/8] mach-k3: fix reading size and addr from fdt on R5
  2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 1/8] spl: Kconfig: allow K3 devices to use falcon mode Anshul Dalal
@ 2025-03-11  9:57 ` Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 3/8] arm: dts: am62a: allow booting from eMMC Anshul Dalal
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-03-11  9:57 UTC (permalink / raw)
  To: u-boot; +Cc: Anshul Dalal, vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

fdtdec_get_addr_size uses architecture dependent datatypes which causes
the 32-bit R5 to fail when reading the 64-bit size and addr fields of
reg nodes from the fdt.

This changes it to a common api for both 64 and 32 bit platforms.
Now fdt fixups can be applied to the fdt from R5.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
 arch/arm/mach-k3/common_fdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-k3/common_fdt.c b/arch/arm/mach-k3/common_fdt.c
index 4a016711566..02a3e2c7748 100644
--- a/arch/arm/mach-k3/common_fdt.c
+++ b/arch/arm/mach-k3/common_fdt.c
@@ -139,7 +139,9 @@ int fdt_fixup_reserved(void *blob, const char *name,
 			return -EINVAL;
 		if (!strncmp(node_name, name, strlen(name))) {
 			/* Read out old size first */
-			addr = fdtdec_get_addr_size(blob, subnode, "reg", &size);
+			addr = fdtdec_get_addr_size_fixed(
+				blob, subnode, "reg", 0, 8 / sizeof(fdt32_t),
+				8 / sizeof(fdt32_t), &size, false);
 			if (addr == FDT_ADDR_T_NONE)
 				return -EINVAL;
 			new_size = size;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 3/8] arm: dts: am62a: allow booting from eMMC
  2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 1/8] spl: Kconfig: allow K3 devices to use falcon mode Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 2/8] mach-k3: fix reading size and addr from fdt on R5 Anshul Dalal
@ 2025-03-11  9:57 ` Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 4/8] arch: arm: k3-binman: add fit for falcon boot Anshul Dalal
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-03-11  9:57 UTC (permalink / raw)
  To: u-boot; +Cc: Anshul Dalal, vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

The bootph-all property in u-boot enables driver initialization prior to
relocation, this is necessary to use the device as boot media.

sdhci0 is the phandle for eMMC on am62a, so this change allows us to use
eMMC as a boot media.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
 arch/arm/dts/k3-am62a7-sk-u-boot.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/k3-am62a7-sk-u-boot.dtsi b/arch/arm/dts/k3-am62a7-sk-u-boot.dtsi
index 7dfbeb10c32..a70fc88317e 100644
--- a/arch/arm/dts/k3-am62a7-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am62a7-sk-u-boot.dtsi
@@ -100,6 +100,10 @@
 	bootph-all;
 };
 
+&sdhci0 {
+	bootph-all;
+};
+
 &sdhci1 {
 	bootph-all;
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 4/8] arch: arm: k3-binman: add fit for falcon boot
  2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
                   ` (2 preceding siblings ...)
  2025-03-11  9:57 ` [PATCH v2 3/8] arm: dts: am62a: allow booting from eMMC Anshul Dalal
@ 2025-03-11  9:57 ` Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 5/8] mach-k3: add eMMC FS boot support for am62[ap] Anshul Dalal
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-03-11  9:57 UTC (permalink / raw)
  To: u-boot; +Cc: Anshul Dalal, vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

This adds creation of tispl_falcon.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 and we also
aren't authenticating the spl and fdt in secure boot.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
 arch/arm/dts/k3-am625-sk-binman.dtsi | 64 ++++++++++++++++++++++++++++
 arch/arm/dts/k3-am62a-sk-binman.dtsi | 64 ++++++++++++++++++++++++++++
 arch/arm/dts/k3-am62p-sk-binman.dtsi | 51 ++++++++++++++++++++++
 arch/arm/dts/k3-binman.dtsi          | 53 +++++++++++++++++++++++
 4 files changed, 232 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-binman.dtsi b/arch/arm/dts/k3-am625-sk-binman.dtsi
index 534eb14795b..5ca1a4b28e8 100644
--- a/arch/arm/dts/k3-am625-sk-binman.dtsi
+++ b/arch/arm/dts/k3-am625-sk-binman.dtsi
@@ -219,6 +219,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.bin";
+					};
+				};
+			};
+
+			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>;
 
diff --git a/arch/arm/dts/k3-am62a-sk-binman.dtsi b/arch/arm/dts/k3-am62a-sk-binman.dtsi
index 2a8c260387b..4433f98801c 100644
--- a/arch/arm/dts/k3-am62a-sk-binman.dtsi
+++ b/arch/arm/dts/k3-am62a-sk-binman.dtsi
@@ -211,6 +211,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.bin";
+					};
+				};
+			};
+
+			configurations {
+				default = "conf-0";
+				conf-0 {
+					description = "k3-am62a7-sk-falcon";
+					firmware = "atf";
+					loadables = "tee", "tifsstub-hs", "tifsstub-fs",
+					"tifsstub-gp", "dm";
+				};
+			};
+		};
+	};
+
 	ti-spl {
 		insert-template = <&ti_spl_template>;
 
diff --git a/arch/arm/dts/k3-am62p-sk-binman.dtsi b/arch/arm/dts/k3-am62p-sk-binman.dtsi
index 797644a7e0d..17d49b050c0 100644
--- a/arch/arm/dts/k3-am62p-sk-binman.dtsi
+++ b/arch/arm/dts/k3-am62p-sk-binman.dtsi
@@ -173,6 +173,57 @@
 
 	};
 
+	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";
+					};
+				};
+				dm {
+					ti-secure {
+						content = <&dm_falcon>;
+						keyfile = "custMpk.pem";
+					};
+					dm_falcon: ti-dm {
+						filename = "ti-dm.bin";
+					};
+				};
+			};
+
+			configurations {
+				default = "conf-0";
+				conf-0 {
+					description = "k3-am62p5-sk-falcon";
+					firmware = "atf";
+					loadables = "tee", "tifsstub-hs", "tifsstub-fs", "dm";
+				};
+			};
+		};
+	};
+
 	ti-spl {
 		insert-template = <&ti_spl_template>;
 
diff --git a/arch/arm/dts/k3-binman.dtsi b/arch/arm/dts/k3-binman.dtsi
index 5163161b94d..4f935cd66ba 100644
--- a/arch/arm/dts/k3-binman.dtsi
+++ b/arch/arm/dts/k3-binman.dtsi
@@ -489,6 +489,59 @@
 		end_address = <0x0 0x9fffffff>;
 	};
 
+	ti_falcon_template: template-9 {
+		filename = "tispl_falcon.bin";
+		pad-byte = <0xff>;
+
+		fit {
+			description = "Configuration without SPL and FDT";
+			#address-cells = <1>;
+
+			images {
+				atf {
+					description = "ARM Trusted Firmware";
+					type = "firmware";
+					arch = "arm64";
+					compression = "none";
+					os = "arm-trusted-firmware";
+					load = <CONFIG_K3_ATF_LOAD_ADDR>;
+					entry = <CONFIG_K3_ATF_LOAD_ADDR>;
+					ti-secure {
+						content = <&atf_falcon>;
+						keyfile = "custMpk.pem";
+					};
+					atf_falcon: atf-bl31 {
+					};
+				};
+				tee {
+					description = "OP-TEE";
+					type = "tee";
+					arch = "arm64";
+					compression = "none";
+					os = "tee";
+					load = <CONFIG_K3_OPTEE_LOAD_ADDR>;
+					entry = <CONFIG_K3_OPTEE_LOAD_ADDR>;
+					ti-secure {
+						content = <&tee_falcon>;
+						keyfile = "custMpk.pem";
+					};
+					tee_falcon: tee-os {
+						optional;
+					};
+				};
+				dm {
+					description = "DM binary";
+					type = "firmware";
+					arch = "arm32";
+					compression = "none";
+					os = "DM";
+					load = <0x89000000>;
+					entry = <0x89000000>;
+				};
+			};
+		};
+	};
+
 };
 
 #endif
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 5/8] mach-k3: add eMMC FS boot support for am62[ap]
  2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
                   ` (3 preceding siblings ...)
  2025-03-11  9:57 ` [PATCH v2 4/8] arch: arm: k3-binman: add fit for falcon boot Anshul Dalal
@ 2025-03-11  9:57 ` Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 6/8] mach-k3: sysfw-loader: update img_hdr for falcon Anshul Dalal
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-03-11  9:57 UTC (permalink / raw)
  To: u-boot; +Cc: Anshul Dalal, vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

This makes spl_mmc_boot_mode consistent across am62x, 62a and 62p.

If MMCSD_MODE_EMMCBOOT is returned, FS boot fails since it checks for FS
on the hardware partitions, not the UDA. So to allow FS boot from EMMC,
the function should return MMCSD_MODE_FS instead which allows us to read
from FS on the UDA.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
 arch/arm/mach-k3/am62ax/am62a7_init.c | 4 ++++
 arch/arm/mach-k3/am62px/am62p5_init.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/mach-k3/am62ax/am62a7_init.c b/arch/arm/mach-k3/am62ax/am62a7_init.c
index 698e6d5c587..47280da2f83 100644
--- a/arch/arm/mach-k3/am62ax/am62a7_init.c
+++ b/arch/arm/mach-k3/am62ax/am62a7_init.c
@@ -207,6 +207,10 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 
 	switch (bootmode) {
 	case BOOT_DEVICE_EMMC:
+		if (IS_ENABLED(CONFIG_SUPPORT_EMMC_BOOT))
+			return MMCSD_MODE_EMMCBOOT;
+		if (IS_ENABLED(CONFIG_SPL_FS_FAT) || IS_ENABLED(CONFIG_SPL_FS_EXT4))
+			return MMCSD_MODE_FS;
 		return MMCSD_MODE_EMMCBOOT;
 	case BOOT_DEVICE_MMC:
 		if (bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK)
diff --git a/arch/arm/mach-k3/am62px/am62p5_init.c b/arch/arm/mach-k3/am62px/am62p5_init.c
index 14a46fa28d2..ec705b9d284 100644
--- a/arch/arm/mach-k3/am62px/am62p5_init.c
+++ b/arch/arm/mach-k3/am62px/am62p5_init.c
@@ -262,6 +262,10 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 
 	switch (bootmode) {
 	case BOOT_DEVICE_EMMC:
+		if (IS_ENABLED(CONFIG_SUPPORT_EMMC_BOOT))
+			return MMCSD_MODE_EMMCBOOT;
+		if (IS_ENABLED(CONFIG_SPL_FS_FAT) || IS_ENABLED(CONFIG_SPL_FS_EXT4))
+			return MMCSD_MODE_FS;
 		return MMCSD_MODE_EMMCBOOT;
 	case BOOT_DEVICE_MMC:
 		if (bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 6/8] mach-k3: sysfw-loader: update img_hdr for falcon
  2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
                   ` (4 preceding siblings ...)
  2025-03-11  9:57 ` [PATCH v2 5/8] mach-k3: add eMMC FS boot support for am62[ap] Anshul Dalal
@ 2025-03-11  9:57 ` Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 7/8] config: add falcon boot config fragment for am62x Anshul Dalal
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-03-11  9:57 UTC (permalink / raw)
  To: u-boot; +Cc: Anshul Dalal, vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

The returned legacy_img_hdr is used by booti_setup to compute the load
address for the kernel image.

This change ensures the kernel load address is CONFIG_SYS_LOAD_ADDR in
falcon boot.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
 arch/arm/mach-k3/r5/sysfw-loader.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-k3/r5/sysfw-loader.c b/arch/arm/mach-k3/r5/sysfw-loader.c
index 188731e673d..19607606965 100644
--- a/arch/arm/mach-k3/r5/sysfw-loader.c
+++ b/arch/arm/mach-k3/r5/sysfw-loader.c
@@ -89,7 +89,11 @@ static void *sysfw_load_address;
 struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
 {
 	if (sysfw_loaded)
-		return (struct legacy_img_hdr *)(CONFIG_TEXT_BASE + offset);
+		if (IS_ENABLED(CONFIG_SPL_OS_BOOT))
+			return (struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR;
+		else
+			return (struct legacy_img_hdr *)(CONFIG_TEXT_BASE +
+							 offset);
 	else if (sysfw_load_address)
 		return sysfw_load_address;
 	else
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 7/8] config: add falcon boot config fragment for am62x
  2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
                   ` (5 preceding siblings ...)
  2025-03-11  9:57 ` [PATCH v2 6/8] mach-k3: sysfw-loader: update img_hdr for falcon Anshul Dalal
@ 2025-03-11  9:57 ` Anshul Dalal
  2025-03-11  9:57 ` [PATCH v2 8/8] mach-k3: common: add falcon support for 62[axp] Anshul Dalal
  2025-04-03 22:08 ` [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
  8 siblings, 0 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-03-11  9:57 UTC (permalink / raw)
  To: u-boot; +Cc: Anshul Dalal, vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

This fragment enables falcon boot for the am62x, 62a and 62p.

To have enough stack and heap space for loading kernel image as FIT, the
memory map was modified as shown below, the PRELOADED_BL33_BASE in ATF
has to also be updated to 0x80200000 since the kernel requires to be
loaded at 2MiB aligned address.

Memory Map (changed addresses marked with *):

0x80000000 +-------------------------------+ Start of DDR
  512KiB   |   ATF reserved memory space   | CONFIG_K3_ATF_LOAD_ADDR
0x80080000 +-------------------------------+
  1.5MiB   |            Unused             |
0x80200000 +-------------------------------+ PRELOADED_BL33_BASE* in ATF
           |                               | CONFIG_SYS_LOAD_ADDR* (load
   30MiB   |   Kernel + initramfs Image    | address for kernel)
           |                               |
0x82000000 +-------------------------------+ K3_HW_CONFIG_BASE in ATF
           |                               | CONFIG_SPL_PAYLOAD_ARGS_ADDR*
    1MiB   |          Kernel DTB           |
           |                               |
0x82100000 +-------------------------------+ CONFIG_SPL_LOAD_FIT_ADDRESS*
           |                               |
   55MiB   |Initial Download Region for FIT|
           |                               |
0x85800000 +-------------------------------+
           |                               |
           |  R5 U-Boot SPL Stack + Heap   |
   56MiB   |       (size defined by        |
           | SPL_STACK_R_MALLOC_SIMPLE_LEN)|
           |                               |
0x89000000 +-------------------------------+ CONFIG_SPL_STACK_R_ADDR*
  344MiB   |       Device Manager (DM)     |
0x9e800000 +-------------------------------+ BL32_BASE in ATF
   24MiB   |             OPTEE             |
0xa0000000 +-------------------------------+ End of DDR (512MiB)

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
 configs/am62x_r5_falcon.config | 36 ++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 configs/am62x_r5_falcon.config

diff --git a/configs/am62x_r5_falcon.config b/configs/am62x_r5_falcon.config
new file mode 100644
index 00000000000..6c2f1e08f3b
--- /dev/null
+++ b/configs/am62x_r5_falcon.config
@@ -0,0 +1,36 @@
+# Enable falcon mode
+CONFIG_SPL_OS_BOOT=y
+
+# We use envs for setting bootargs and optionally for `falcon_(image|args)_file`
+CONFIG_SPL_ENV_SUPPORT=y
+
+# Perform FDT fixups from SPL
+CONFIG_OF_SYSTEM_SETUP=y
+
+# Enabling this causes issues with EMMC FS boot,
+# When enabled the SPL tries to detect FS on boot[01] hw partition which fails
+# since we need the raw tiboot3.bin there for the board to boot instead
+CONFIG_SUPPORT_EMMC_BOOT=n
+
+# Used as the 2MiB aligned load address for kernel
+CONFIG_SYS_LOAD_ADDR=0x80200000
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x82100000
+CONFIG_SPL_STACK_R_ADDR=0x89000000
+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x3800000
+CONFIG_SYS_BOOTM_LEN=0x1e00000
+
+# Loading tispl_falcon instead of tispl which has fdt and A53 spl saves time
+CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="tispl_falcon.bin"
+CONFIG_SPL_FS_LOAD_KERNEL_NAME="Image"
+# We don't use the args file when loading fitImage since it has dtb pre-packaged
+# this is only useful while reading the raw kernel image from FS
+CONFIG_SPL_FS_LOAD_ARGS_NAME="falcon.dtb"
+
+# Disabled to save space on the spl
+CONFIG_SPL_YMODEM_SUPPORT=n
+
+# During SPI boot, kernel and args are loaded from the eMMC or SD and not SPI,
+# therefore we don't actually make use of these config values.
+CONFIG_SYS_SPI_KERNEL_OFFS=0
+CONFIG_SYS_SPI_ARGS_OFFS=0
+CONFIG_SYS_SPI_ARGS_SIZE=0
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 8/8] mach-k3: common: add falcon support for 62[axp]
  2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
                   ` (6 preceding siblings ...)
  2025-03-11  9:57 ` [PATCH v2 7/8] config: add falcon boot config fragment for am62x Anshul Dalal
@ 2025-03-11  9:57 ` Anshul Dalal
  2025-04-03 22:08 ` [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
  8 siblings, 0 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-03-11  9:57 UTC (permalink / raw)
  To: u-boot; +Cc: Anshul Dalal, vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

We use the spl_board_prepare_for_boot hook to call k3_falcon_prep which
is ran after tispl is loaded but before jump_to_image.

In here, we find the boot media and load the image just as std falcon
flow (since spl_start_uboot returns 0 now). Once the kernel and args are
loaded, we perform fdt fixups on the fdt accompanying the kernel (if
loaded as FIT) or the loaded up args and return.

Now when the flow goes to jump_to_image, we do the regular pre-jump
procedure and jump to ATF 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).

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
 arch/arm/mach-k3/common.c | 105 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index fa8cd93d664..6e41aa8318b 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -263,8 +263,113 @@ static __maybe_unused void k3_dma_remove(void)
 		pr_warn("DMA Device not found (err=%d)\n", rc);
 }
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT) && !IS_ENABLED(CONFIG_ARM64)
+static bool tispl_loaded;
+
+int spl_start_uboot(void)
+{
+	if (!tispl_loaded)
+		return 1;
+	return 0;
+}
+
+static int k3_falcon_fdt_fixup(void *fdt)
+{
+	struct disk_partition info;
+	struct blk_desc *dev_desc;
+	char bootmedia[32];
+	char bootpart[32];
+	char str[256];
+	int ret;
+
+	strcpy(bootmedia, env_get("boot"));
+	strcpy(bootpart, env_get("bootpart"));
+	ret = blk_get_device_part_str(bootmedia, bootpart, &dev_desc, &info, 0);
+	if (ret < 0)
+		printf("Failed to get part details for %s %s [%d]\n", bootmedia,
+		       bootpart, ret);
+	sprintf(str, "console=%s root=PARTUUID=%s rootwait", env_get("console"),
+		info.uuid);
+	ret = fdt_find_and_setprop(fdt, "/chosen", "bootargs", str,
+				   strlen(str) + 1, 1);
+	if (ret) {
+		printf("Could not set bootargs: %s\n", fdt_strerror(ret));
+		return ret;
+	}
+	debug("Set bootargs to: %s\n", str);
+
+#ifdef CONFIG_OF_BOARD_SETUP
+	ret = ft_board_setup(fdt, gd->bd);
+	if (ret) {
+		printf("Failed in board fdt fixups: %s\n", fdt_strerror(ret));
+		return ret;
+	}
+#endif
+
+#ifdef CONFIG_OF_SYSTEM_SETUP
+	ret = ft_system_setup(fdt, gd->bd);
+	if (ret) {
+		printf("Failed in system fdt fixups: %s\n", fdt_strerror(ret));
+		return ret;
+	}
+#endif
+
+	return 0;
+}
+
+static int k3_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;
+
+	tispl_loaded = true;
+	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();
+	if (bootdev.boot_device == BOOT_DEVICE_SPI) {
+		if (strcmp(env_get("mmcdev"), "1") == 0)
+			bootdev.boot_device = BOOT_DEVICE_MMC;
+		else
+			bootdev.boot_device = BOOT_DEVICE_EMMC;
+	}
+	bootdev.boot_device_name = NULL;
+
+	for (loader = drv; loader != drv + n_ents; loader++) {
+		if (bootdev.boot_device != loader->boot_device)
+			continue;
+		if (loader) {
+			printf("Loading falcon payload from %s\n",
+			       spl_loader_name(loader));
+			ret = loader->load_image(&kernel_image, &bootdev);
+			if (ret)
+				continue;
+
+			fdt = spl_image_fdt_addr(&kernel_image);
+			if (!fdt)
+				fdt = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR;
+			ret = k3_falcon_fdt_fixup(fdt);
+			if (ret) {
+				printf("Failed performing fdt fixups in falcon flow: [%d]\n",
+				       ret);
+				return ret;
+			}
+			return 0;
+		}
+	}
+
+	return ret;
+}
+#endif
+
 void spl_board_prepare_for_boot(void)
 {
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT) && !IS_ENABLED(CONFIG_ARM64)
+	k3_falcon_prep();
+#endif
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
 	dcache_disable();
 #endif
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x
  2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
                   ` (7 preceding siblings ...)
  2025-03-11  9:57 ` [PATCH v2 8/8] mach-k3: common: add falcon support for 62[axp] Anshul Dalal
@ 2025-04-03 22:08 ` Anshul Dalal
  8 siblings, 0 replies; 10+ messages in thread
From: Anshul Dalal @ 2025-04-03 22:08 UTC (permalink / raw)
  To: Anshul Dalal, u-boot; +Cc: vigneshr, trini, afd, m-chawdhry, n-francis, b-liu

On Tue Mar 11, 2025 at 3:27 PM IST, Anshul Dalal wrote:
> 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 flow 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 non std 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 0x80200000.
>
> This patch depends on:
>
>  * [PATCH v3] spl: return header size to spl_load in os boot [1]
>  * [PATCH v2] config: falcon: move CFG_SYS_SPI_* to Kconfig [2]
>  * [PATCH v1] spl: remove usage of CMD_(BOOTI|BOOTZ) from image parsing [3]
>
> [1]: https://lore.kernel.org/u-boot/20250311093546.3371193-1-anshuld@ti.com/
> [2]: https://lore.kernel.org/u-boot/20250311044414.3155688-1-anshuld@ti.com/
> [3]: https://lore.kernel.org/u-boot/20250311093709.3372104-1-anshuld@ti.com/
>
> Signed-off-by: Anshul Dalal <anshuld@ti.com>
> ---
> Changes in v2:
>  * Move to CONFIG_SYS_SPI_* as per [2]
>  * Remove the need for CMD_BOOTI as per [3]
> v1: https://lore.kernel.org/u-boot/20250307075541.2571104-1-anshuld@ti.com/
> ---
> Anshul Dalal (8):
>   spl: Kconfig: allow K3 devices to use falcon mode
>   mach-k3: fix reading size and addr from fdt on R5
>   arm: dts: am62a: allow booting from eMMC
>   arch: arm: k3-binman: add fit for falcon boot
>   mach-k3: add eMMC FS boot support for am62[ap]
>   mach-k3: sysfw-loader: update img_hdr for falcon
>   config: add falcon boot config fragment for am62x
>   mach-k3: common: add falcon support for 62[axp]
>
>  arch/arm/dts/k3-am625-sk-binman.dtsi  |  64 ++++++++++++++++
>  arch/arm/dts/k3-am62a-sk-binman.dtsi  |  64 ++++++++++++++++
>  arch/arm/dts/k3-am62a7-sk-u-boot.dtsi |   4 +
>  arch/arm/dts/k3-am62p-sk-binman.dtsi  |  51 +++++++++++++
>  arch/arm/dts/k3-binman.dtsi           |  53 +++++++++++++
>  arch/arm/mach-k3/am62ax/am62a7_init.c |   4 +
>  arch/arm/mach-k3/am62px/am62p5_init.c |   4 +
>  arch/arm/mach-k3/common.c             | 105 ++++++++++++++++++++++++++
>  arch/arm/mach-k3/common_fdt.c         |   4 +-
>  arch/arm/mach-k3/r5/sysfw-loader.c    |   6 +-
>  common/spl/Kconfig                    |   3 +-
>  configs/am62x_r5_falcon.config        |  36 +++++++++
>  12 files changed, 395 insertions(+), 3 deletions(-)
>  create mode 100644 configs/am62x_r5_falcon.config

Superseded by v3:
https://lore.kernel.org/u-boot/20250403215910.1292922-1-anshuld@ti.com/

Anshul

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-04-03 22:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11  9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
2025-03-11  9:57 ` [PATCH v2 1/8] spl: Kconfig: allow K3 devices to use falcon mode Anshul Dalal
2025-03-11  9:57 ` [PATCH v2 2/8] mach-k3: fix reading size and addr from fdt on R5 Anshul Dalal
2025-03-11  9:57 ` [PATCH v2 3/8] arm: dts: am62a: allow booting from eMMC Anshul Dalal
2025-03-11  9:57 ` [PATCH v2 4/8] arch: arm: k3-binman: add fit for falcon boot Anshul Dalal
2025-03-11  9:57 ` [PATCH v2 5/8] mach-k3: add eMMC FS boot support for am62[ap] Anshul Dalal
2025-03-11  9:57 ` [PATCH v2 6/8] mach-k3: sysfw-loader: update img_hdr for falcon Anshul Dalal
2025-03-11  9:57 ` [PATCH v2 7/8] config: add falcon boot config fragment for am62x Anshul Dalal
2025-03-11  9:57 ` [PATCH v2 8/8] mach-k3: common: add falcon support for 62[axp] Anshul Dalal
2025-04-03 22:08 ` [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox