Skip to contentSkip to conversation

sunxi: SPL FIT support for 32-bit sunxi SoCs

PATCH In review Samuel Holland 4 participants 15 messages Oct 31, 2023 – Jan 29, 2024

Subsystems (3)
lore
Share & tools
lore

Samuel Holland

author maintainer
#0 lore raw

v3 cover sunxi: SPL FIT support for 32-bit sunxi SoCs

This series makes the necessary changes so 32-bit sunxi SoCs can load additional device trees or firmware from SPL along with U-Boot proper. Crust (SCP firmware) has support for A33 and H3, and H3 also needs to load an eGon blob to support CPU 0 hotplug (a silicon bug workaround).

FIT unlocks more features (signatures, multiple DTBs, etc.), so enable it by default. A10 (sun4i) only has 24 KiB of SRAM A1, so it needs SPL_FIT_IMAGE_TINY. For consistency, enable that option everywhere.

After this series is applied, we can increase SPL_MAX_SIZE for H6 and newer SoCs, both 32-bit (e.g. A50, T113) and 64-bit. I did not do that yet because there is some discussion to be had about the correct value:
it must be adjusted to guarantee return-to-FEL functionality, and the exact adjustment depends on the sunxi-fel tool implementation.

Changes in v3:
- Rebased and collected tags

Changes in v2:
- Disable padding from SPL_PAD_TO
- Rely on binman min-size instead of using explicit offsets
- Use Kconfig for firmware addresses instead of an #ifdef staircase

Samuel Holland (4):
sunxi: spl: Disable padding from SPL_PAD_TO
sunxi: binman: Move BL31 and SCP firmware addresses to Kconfig
sunxi: binman: Support FIT generation for 32-bit SoCs
sunxi: Enable SPL FIT loading for 32-bit SoCs

 arch/arm/Kconfig               |  1 +
 arch/arm/dts/sunxi-u-boot.dtsi | 39 ++++++++++++++++++----------------
 arch/arm/mach-sunxi/Kconfig    | 17 +++++++++++++++
 common/spl/Kconfig             |  6 ++----
 4 files changed, 41 insertions(+), 22 deletions(-)
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH v3 1/4 sunxi: spl: Disable padding from SPL_PAD_TO

Starting with H6, Allwinner removed the artificial 32 KiB SPL size limit from the boot ROM. Now SPL size is only limited by the available SRAM. This limit ranges from 152 KiB on H6 to a whopping 2052 KiB on R329. To take advantage of this additional space, we must increase SPL_MAX_SIZE. Since we do not want to unnecessarily pad SPL out to these giant sizes, we must set SPL_PAD_TO to zero. This causes no problems because binman already takes care of appending the SPL payload at the right offset.

---

(no changes since v2)

Changes in v2:
- New patch for v2

 common/spl/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
common/spl/Kconfig +1 -2
index 25cd18afda7..a0968ff1065 100644
@@ -97,8 +97,7 @@ config SPL_PAD_TO
 	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
 	default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB)
 	default 0x10000 if ARCH_KEYSTONE
-	default 0x8000 if ARCH_SUNXI && !MACH_SUN50I_H616
-	default 0x0 if ARCH_MTMIPS
+	default 0x0 if ARCH_MTMIPS || ARCH_SUNXI
 	default TPL_MAX_SIZE if TPL_MAX_SIZE > SPL_MAX_SIZE
 	default SPL_MAX_SIZE
 	help
Signature · 1 line
2.41.0
Reviewed-by on v3 1/4
#2 lore raw

Re: [PATCH v3 1/4] sunxi: spl: Disable padding from SPL_PAD_TO

On Tue, 31 Oct 2023 00:17:38 -0500
Samuel Holland <[email protected]> wrote:

Hi Samuel,

Quoted 7 lines

Starting with H6, Allwinner removed the artificial 32 KiB SPL size limit from the boot ROM. Now SPL size is only limited by the available SRAM. This limit ranges from 152 KiB on H6 to a whopping 2052 KiB on R329. To take advantage of this additional space, we must increase SPL_MAX_SIZE. Since we do not want to unnecessarily pad SPL out to these giant sizes, we must set SPL_PAD_TO to zero. This causes no problems because binman already takes care of appending the SPL payload at the right offset.

That looks alright now, back in v2023.04 (at time of v2) this still broke compilation, but this was fixed with your patch 9a4aa31ad514. I actually cannot see any effect on sunxi builds anymore, apart from the check in config_fallbacks.h, which is appeased with the value being set to 0 here. So:

Quoted 1 line

Cheers,
Andre

Quoted 24 lines

---

(no changes since v2)

Changes in v2:
- New patch for v2

 common/spl/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
common/spl/Kconfig +1 -2
index 25cd18afda7..a0968ff1065 100644
@@ -97,8 +97,7 @@ config SPL_PAD_TO
 	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
 	default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB)
 	default 0x10000 if ARCH_KEYSTONE
-	default 0x8000 if ARCH_SUNXI && !MACH_SUN50I_H616
-	default 0x0 if ARCH_MTMIPS
+	default 0x0 if ARCH_MTMIPS || ARCH_SUNXI
 	default TPL_MAX_SIZE if TPL_MAX_SIZE > SPL_MAX_SIZE
 	default SPL_MAX_SIZE
 	help
author maintainer
#3 lore raw

PATCH v3 2/4 sunxi: binman: Move BL31 and SCP firmware addresses to Kconfig

In reply to Samuel Holland

This is easier to read than the #ifdef staircase, provides better visibility into the memory map (alongside the other Kconfig definitions), and allows these addresses to be reused from code.

---

(no changes since v2)

Changes in v2:
- New patch for v2, split from the .dtsi changes

 arch/arm/dts/sunxi-u-boot.dtsi | 24 +++++++-----------------
 arch/arm/mach-sunxi/Kconfig    | 17 +++++++++++++++++
 2 files changed, 24 insertions(+), 17 deletions(-)
arch/arm/dts/sunxi-u-boot.dtsi +7 -17
index a0c8abb7033..7a8764e463b 100644
@@ -1,15 +1,5 @@
 #include <config.h>
 
-#ifdef CONFIG_MACH_SUN50I_H6
-#define BL31_ADDR 0x104000
-#define  SCP_ADDR 0x114000
-#elif defined(CONFIG_MACH_SUN50I_H616)
-#define BL31_ADDR 0x40000000
-#else
-#define BL31_ADDR  0x44000
-#define  SCP_ADDR  0x50000
-#endif
-
 / {
 	aliases {
 		mmc0 = &mmc0;
@@ -69,8 +59,8 @@
 					os = "arm-trusted-firmware";
 					arch = "arm64";
 					compression = "none";
-					load = <BL31_ADDR>;
-					entry = <BL31_ADDR>;
+					load = <CONFIG_SUNXI_BL31_BASE>;
+					entry = <CONFIG_SUNXI_BL31_BASE>;
 
 					atf-bl31 {
 						filename = "bl31.bin";
@@ -78,13 +68,13 @@
 					};
 				};
 
-#ifdef SCP_ADDR
+#if CONFIG_SUNXI_SCP_BASE
 				scp {
 					description = "SCP firmware";
 					type = "firmware";
 					arch = "or1k";
 					compression = "none";
-					load = <SCP_ADDR>;
+					load = <CONFIG_SUNXI_SCP_BASE>;
 
 					scp {
 						filename = "scp.bin";
@@ -106,10 +96,10 @@
 				@config-SEQ {
 					description = "NAME";
 					firmware = "atf";
-#ifndef SCP_ADDR
-					loadables = "uboot";
-#else
+#if CONFIG_SUNXI_SCP_BASE
 					loadables = "scp", "uboot";
+#else
+					loadables = "uboot";
 #endif
 					fdt = "fdt-SEQ";
 				};
arch/arm/mach-sunxi/Kconfig +17 -0
index a10e4c06b6a..b0fbda0aa09 100644
@@ -155,6 +155,23 @@ config SUNXI_RVBAR_ALTERNATIVE
 	for all other SoCs, so the content of the SRAM_VER_REG becomes
 	irrelevant there, and we can use the same code.
 
+config SUNXI_BL31_BASE
+	hex
+	default 0x00044000 if MACH_SUN50I || MACH_SUN50I_H5
+	default 0x00104000 if MACH_SUN50I_H6
+	default 0x40000000 if MACH_SUN50I_H616
+	default 0x0
+	help
+	  Address where BL31 (TF-A) is loaded, or zero if BL31 is not used.
+
+config SUNXI_SCP_BASE
+	hex
+	default 0x00050000 if MACH_SUN50I || MACH_SUN50I_H5
+	default 0x00114000 if MACH_SUN50I_H6
+	default 0x0
+	help
+	  Address where SCP firmware is loaded, or zero if it is not used.
+
 config SUNXI_A64_TIMER_ERRATUM
 	bool
 
Signature · 1 line
2.41.0
Reviewed-by on v3 2/4
#4 lore raw

Re: [PATCH v3 2/4] sunxi: binman: Move BL31 and SCP firmware addresses to Kconfig

On Tue, 31 Oct 2023 00:17:39 -0500
Samuel Holland <[email protected]> wrote:

Hi Samuel,

Quoted 3 lines

This is easier to read than the #ifdef staircase, provides better visibility into the memory map (alongside the other Kconfig definitions), and allows these addresses to be reused from code.

This is indeed much nicer, and simplifies adding more SoCs. I checked that the addresses are the same:

Quoted 2 lines

Cheers,
Andre

Quoted 100 lines

---

(no changes since v2)

Changes in v2:
- New patch for v2, split from the .dtsi changes

 arch/arm/dts/sunxi-u-boot.dtsi | 24 +++++++-----------------
 arch/arm/mach-sunxi/Kconfig    | 17 +++++++++++++++++
 2 files changed, 24 insertions(+), 17 deletions(-)
arch/arm/dts/sunxi-u-boot.dtsi +7 -17
index a0c8abb7033..7a8764e463b 100644
@@ -1,15 +1,5 @@
 #include <config.h>
 
-#ifdef CONFIG_MACH_SUN50I_H6
-#define BL31_ADDR 0x104000
-#define  SCP_ADDR 0x114000
-#elif defined(CONFIG_MACH_SUN50I_H616)
-#define BL31_ADDR 0x40000000
-#else
-#define BL31_ADDR  0x44000
-#define  SCP_ADDR  0x50000
-#endif
-
 / {
 	aliases {
 		mmc0 = &mmc0;
@@ -69,8 +59,8 @@
 					os = "arm-trusted-firmware";
 					arch = "arm64";
 					compression = "none";
-					load = <BL31_ADDR>;
-					entry = <BL31_ADDR>;
+					load = <CONFIG_SUNXI_BL31_BASE>;
+					entry = <CONFIG_SUNXI_BL31_BASE>;
 
 					atf-bl31 {
 						filename = "bl31.bin";
@@ -78,13 +68,13 @@
 					};
 				};
 
-#ifdef SCP_ADDR
+#if CONFIG_SUNXI_SCP_BASE
 				scp {
 					description = "SCP firmware";
 					type = "firmware";
 					arch = "or1k";
 					compression = "none";
-					load = <SCP_ADDR>;
+					load = <CONFIG_SUNXI_SCP_BASE>;
 
 					scp {
 						filename = "scp.bin";
@@ -106,10 +96,10 @@
 				@config-SEQ {
 					description = "NAME";
 					firmware = "atf";
-#ifndef SCP_ADDR
-					loadables = "uboot";
-#else
+#if CONFIG_SUNXI_SCP_BASE
 					loadables = "scp", "uboot";
+#else
+					loadables = "uboot";
 #endif
 					fdt = "fdt-SEQ";
 				};
arch/arm/mach-sunxi/Kconfig +17 -0
index a10e4c06b6a..b0fbda0aa09 100644
@@ -155,6 +155,23 @@ config SUNXI_RVBAR_ALTERNATIVE
 	for all other SoCs, so the content of the SRAM_VER_REG becomes
 	irrelevant there, and we can use the same code.
 
+config SUNXI_BL31_BASE
+	hex
+	default 0x00044000 if MACH_SUN50I || MACH_SUN50I_H5
+	default 0x00104000 if MACH_SUN50I_H6
+	default 0x40000000 if MACH_SUN50I_H616
+	default 0x0
+	help
+	  Address where BL31 (TF-A) is loaded, or zero if BL31 is not used.
+
+config SUNXI_SCP_BASE
+	hex
+	default 0x00050000 if MACH_SUN50I || MACH_SUN50I_H5
+	default 0x00114000 if MACH_SUN50I_H6
+	default 0x0
+	help
+	  Address where SCP firmware is loaded, or zero if it is not used.
+
 config SUNXI_A64_TIMER_ERRATUM
 	bool
 
author maintainer
#5 lore raw

PATCH v3 3/4 sunxi: binman: Support FIT generation for 32-bit SoCs

In reply to Samuel Holland

Some 32-bit SoCs can use SCP firmware to implement additional PSCI functionality, such as system suspend. In order to load this firmware from SPL, we need to generate and use a FIT instead of a legacy image.

Adjust the binman FIT definition so it does not rely on TF-A BL31, as this is not used on 32-bit SoCs. Instead, after loading the firmware, U-Boot proper is executed directly.

---

(no changes since v2)

Changes in v2:
- Rely on binman min-size instead of using explicit offsets
- Use Kconfig for firmware addresses instead of an #ifdef staircase

 arch/arm/dts/sunxi-u-boot.dtsi | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
arch/arm/dts/sunxi-u-boot.dtsi +18 -5
index 7a8764e463b..ed1cb91eeb5 100644
@@ -1,5 +1,11 @@
 #include <config.h>
 
+#ifdef CONFIG_ARM64
+#define ARCH "arm64"
+#else
+#define ARCH "arm"
+#endif
+
 / {
 	aliases {
 		mmc0 = &mmc0;
@@ -34,30 +40,32 @@
 			filename = "spl/sunxi-spl.bin";
 		};
 
-#ifdef CONFIG_ARM64
+#ifdef CONFIG_SPL_LOAD_FIT
 		fit {
-			description = "Configuration to load ATF before U-Boot";
+			description = "Configuration to load U-Boot and firmware";
 			#address-cells = <1>;
 			fit,fdt-list = "of-list";
 
 			images {
 				uboot {
-					description = "U-Boot (64-bit)";
+					description = "U-Boot";
 					type = "standalone";
 					os = "u-boot";
-					arch = "arm64";
+					arch = ARCH;
 					compression = "none";
 					load = <CONFIG_TEXT_BASE>;
+					entry = <CONFIG_TEXT_BASE>;
 
 					u-boot-nodtb {
 					};
 				};
 
+#if CONFIG_SUNXI_BL31_BASE
 				atf {
 					description = "ARM Trusted Firmware";
 					type = "firmware";
 					os = "arm-trusted-firmware";
-					arch = "arm64";
+					arch = ARCH;
 					compression = "none";
 					load = <CONFIG_SUNXI_BL31_BASE>;
 					entry = <CONFIG_SUNXI_BL31_BASE>;
@@ -67,6 +75,7 @@
 						missing-msg = "atf-bl31-sunxi";
 					};
 				};
+#endif
 
 #if CONFIG_SUNXI_SCP_BASE
 				scp {
@@ -95,7 +104,11 @@
 
 				@config-SEQ {
 					description = "NAME";
+#if CONFIG_SUNXI_BL31_BASE
 					firmware = "atf";
+#else
+					firmware = "uboot";
+#endif
 #if CONFIG_SUNXI_SCP_BASE
 					loadables = "scp", "uboot";
 #else
Signature · 1 line
2.41.0
Reviewed-by on v3 3/4
#6 lore raw

Re: [PATCH v3 3/4] sunxi: binman: Support FIT generation for 32-bit SoCs

Quoted 12 lines · Samuel Holland

Some 32-bit SoCs can use SCP firmware to implement additional PSCI functionality, such as system suspend. In order to load this firmware from SPL, we need to generate and use a FIT instead of a legacy image.

Adjust the binman FIT definition so it does not rely on TF-A BL31, as this is not used on 32-bit SoCs. Instead, after loading the firmware, U-Boot proper is executed directly.

---

Quoted 8 lines

(no changes since v2)

Changes in v2:
- Rely on binman min-size instead of using explicit offsets
- Use Kconfig for firmware addresses instead of an #ifdef staircase

 arch/arm/dts/sunxi-u-boot.dtsi | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
Reviewed-by on v3 3/4
#7 lore raw

Re: [PATCH v3 3/4] sunxi: binman: Support FIT generation for 32-bit SoCs

In reply to Samuel Holland

On Tue, 31 Oct 2023 00:17:40 -0500
Samuel Holland <[email protected]> wrote:

Hi,

Quoted 7 lines

Some 32-bit SoCs can use SCP firmware to implement additional PSCI functionality, such as system suspend. In order to load this firmware from SPL, we need to generate and use a FIT instead of a legacy image.

Adjust the binman FIT definition so it does not rely on TF-A BL31, as this is not used on 32-bit SoCs. Instead, after loading the firmware, U-Boot proper is executed directly.

I like that it removes the artificial restriction to use a FIT image only on arm64 builds, and indeed hinges that on the relevant CONFIG_SPL_LOAD_FIT variable.
The changes look alright, even "uboot" being mentioned twice (once as firmware, once as loadable): the SPL code can cope with that.

Quoted 1 line

Cheers,
Andre

Quoted 85 lines

---

(no changes since v2)

Changes in v2:
- Rely on binman min-size instead of using explicit offsets
- Use Kconfig for firmware addresses instead of an #ifdef staircase

 arch/arm/dts/sunxi-u-boot.dtsi | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
arch/arm/dts/sunxi-u-boot.dtsi +18 -5
index 7a8764e463b..ed1cb91eeb5 100644
@@ -1,5 +1,11 @@
 #include <config.h>
 
+#ifdef CONFIG_ARM64
+#define ARCH "arm64"
+#else
+#define ARCH "arm"
+#endif
+
 / {
 	aliases {
 		mmc0 = &mmc0;
@@ -34,30 +40,32 @@
 			filename = "spl/sunxi-spl.bin";
 		};
 
-#ifdef CONFIG_ARM64
+#ifdef CONFIG_SPL_LOAD_FIT
 		fit {
-			description = "Configuration to load ATF before U-Boot";
+			description = "Configuration to load U-Boot and firmware";
 			#address-cells = <1>;
 			fit,fdt-list = "of-list";
 
 			images {
 				uboot {
-					description = "U-Boot (64-bit)";
+					description = "U-Boot";
 					type = "standalone";
 					os = "u-boot";
-					arch = "arm64";
+					arch = ARCH;
 					compression = "none";
 					load = <CONFIG_TEXT_BASE>;
+					entry = <CONFIG_TEXT_BASE>;
 
 					u-boot-nodtb {
 					};
 				};
 
+#if CONFIG_SUNXI_BL31_BASE
 				atf {
 					description = "ARM Trusted Firmware";
 					type = "firmware";
 					os = "arm-trusted-firmware";
-					arch = "arm64";
+					arch = ARCH;
 					compression = "none";
 					load = <CONFIG_SUNXI_BL31_BASE>;
 					entry = <CONFIG_SUNXI_BL31_BASE>;
@@ -67,6 +75,7 @@
 						missing-msg = "atf-bl31-sunxi";
 					};
 				};
+#endif
 
 #if CONFIG_SUNXI_SCP_BASE
 				scp {
@@ -95,7 +104,11 @@
 
 				@config-SEQ {
 					description = "NAME";
+#if CONFIG_SUNXI_BL31_BASE
 					firmware = "atf";
+#else
+					firmware = "uboot";
+#endif
 #if CONFIG_SUNXI_SCP_BASE
 					loadables = "scp", "uboot";
 #else
#8 lore raw

Re: [PATCH v3 3/4] sunxi: binman: Support FIT generation for 32-bit SoCs

In reply to Samuel Holland

On Tue, 31 Oct 2023 00:17:40 -0500
Samuel Holland <[email protected]> wrote:

Hi,

Quoted 9 lines

Some 32-bit SoCs can use SCP firmware to implement additional PSCI functionality, such as system suspend. In order to load this firmware from SPL, we need to generate and use a FIT instead of a legacy image.

Adjust the binman FIT definition so it does not rely on TF-A BL31, as this is not used on 32-bit SoCs. Instead, after loading the firmware, U-Boot proper is executed directly.

So I merged this patch (along with the others), but with one change below:

Quoted 40 lines

---

(no changes since v2)

Changes in v2:
- Rely on binman min-size instead of using explicit offsets
- Use Kconfig for firmware addresses instead of an #ifdef staircase

 arch/arm/dts/sunxi-u-boot.dtsi | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
arch/arm/dts/sunxi-u-boot.dtsi +8 -2
index 7a8764e463b..ed1cb91eeb5 100644
@@ -1,5 +1,11 @@
 #include <config.h>
 
+#ifdef CONFIG_ARM64
+#define ARCH "arm64"
+#else
+#define ARCH "arm"
+#endif
+
 / {
 	aliases {
 		mmc0 = &mmc0;
@@ -34,30 +40,32 @@
 			filename = "spl/sunxi-spl.bin";
 		};
 
-#ifdef CONFIG_ARM64
+#ifdef CONFIG_SPL_LOAD_FIT
 		fit {
-			description = "Configuration to load ATF before U-Boot";
+			description = "Configuration to load U-Boot and firmware";
 			#address-cells = <1>;
 			fit,fdt-list = "of-list";
 
 			images {

arch/arm/dts/sunxi-u-boot.dtsi line 57

Quoted 10 lines
arch/arm/dts/sunxi-u-boot.dtsi +3 -2
 				uboot {
-					description = "U-Boot (64-bit)";
+					description = "U-Boot";
 					type = "standalone";
 					os = "u-boot";
-					arch = "arm64";
+					arch = ARCH;
 					compression = "none";
 					load = <CONFIG_TEXT_BASE>;
+					entry = <CONFIG_TEXT_BASE>;

This line for some odd reason broke the Debian arm64 Grub execution for
me: U-Boot would run fine, it would load grub.efi, but then I see U-Boot's exception handler, with an ESR 0x20000000 ("unknown reason"), and a reset.

It also confuses sunxi-fel's FIT loader, which expects exactly one image with an "entry" property, and thus refuses to load such an image. This is admittedly a limitation of sunxi-fel, but nevertheless would mean we cannot FEL boot those images at the moment.
I will look into fixing this there, but together with the first problem, I decided to make this line conditional, by bracketing it with a check for CONFIG_SUNXI_BL31_BASE being 0.
This means we never get two "entry" properties:
- for arm64, BL31_BASE is never 0, so we skip it here, but get it below, for the "atf" node.
- for arm, BL31_BASE is always 0, so we get it here, but skip the entire "atf" node below.

Happy to revisit this problem with a proper fix, but to not hold this series back any longer, because it's a nice series and cleans up some mess, I merged it with this modification, plus the removal of the unconditional enablement in the last patch.

Cheers,
Andre.

Quoted 35 lines
arch/arm/dts/sunxi-u-boot.dtsi +7 -1
 					u-boot-nodtb {
 					};
 				};
 
+#if CONFIG_SUNXI_BL31_BASE
 				atf {
 					description = "ARM Trusted Firmware";
 					type = "firmware";
 					os = "arm-trusted-firmware";
-					arch = "arm64";
+					arch = ARCH;
 					compression = "none";
 					load = <CONFIG_SUNXI_BL31_BASE>;
 					entry = <CONFIG_SUNXI_BL31_BASE>;
@@ -67,6 +75,7 @@
 						missing-msg = "atf-bl31-sunxi";
 					};
 				};
+#endif
 
 #if CONFIG_SUNXI_SCP_BASE
 				scp {
@@ -95,7 +104,11 @@
 
 				@config-SEQ {
 					description = "NAME";
+#if CONFIG_SUNXI_BL31_BASE
 					firmware = "atf";
+#else
+					firmware = "uboot";
+#endif
 #if CONFIG_SUNXI_SCP_BASE
 					loadables = "scp", "uboot";
 #else
author maintainer
#9 lore raw

PATCH v3 4/4 sunxi: Enable SPL FIT loading for 32-bit SoCs

In reply to Samuel Holland

Now that 32-bit SoCs can load U-Boot proper (and possibly other firmware) from a FIT, use this method by default. SPL_FIT_IMAGE_TINY is required to stay within the 24 or 32 KiB SPL size limit on early SoCs; for consistency, enable it everywhere.

---

(no changes since v2)

Changes in v2:
- New patch for v2, split from the .dtsi changes

 arch/arm/Kconfig   | 1 +
 common/spl/Kconfig | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +1 -0
index d812685c984..42781d02f0f 100644
@@ -1167,6 +1167,7 @@ config ARCH_SUNXI
 	imply SPL_GPIO
 	imply SPL_LIBCOMMON_SUPPORT
 	imply SPL_LIBGENERIC_SUPPORT
+	imply SPL_LOAD_FIT
 	imply SPL_MMC if MMC
 	imply SPL_POWER
 	imply SPL_SERIAL
common/spl/Kconfig +1 -2
index a0968ff1065..aebbfbf99d2 100644
@@ -567,8 +567,7 @@ config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
 config SPL_FIT_IMAGE_TINY
 	bool "Remove functionality from SPL FIT loading to reduce size"
 	depends on SPL_FIT
-	default y if MACH_SUN50I || MACH_SUN50I_H5 || SUN50I_GEN_H6
-	default y if ARCH_IMX8M || ARCH_IMX9
+	default y if ARCH_IMX8M || ARCH_IMX9 || ARCH_SUNXI
 	help
 	  Enable this to reduce the size of the FIT image loading code
 	  in SPL, if space for the SPL binary is very tight.
Signature · 1 line
2.41.0
Reviewed-by on v3 4/4
#10 lore raw

Re: [PATCH v3 4/4] sunxi: Enable SPL FIT loading for 32-bit SoCs

Quoted 9 lines · Samuel Holland

Now that 32-bit SoCs can load U-Boot proper (and possibly other firmware) from a FIT, use this method by default. SPL_FIT_IMAGE_TINY is required to stay within the 24 or 32 KiB SPL size limit on early SoCs; for consistency, enable it everywhere.

---

Quoted 8 lines

(no changes since v2)

Changes in v2:
- New patch for v2, split from the .dtsi changes

 arch/arm/Kconfig   | 1 +
 common/spl/Kconfig | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
#11 lore raw

Re: [PATCH v3 4/4] sunxi: Enable SPL FIT loading for 32-bit SoCs

In reply to Samuel Holland

On Tue, 31 Oct 2023 00:17:41 -0500
Samuel Holland <[email protected]> wrote:

Hi,

Quoted 4 lines

Now that 32-bit SoCs can load U-Boot proper (and possibly other firmware) from a FIT, use this method by default. SPL_FIT_IMAGE_TINY is required to stay within the 24 or 32 KiB SPL size limit on early SoCs; for consistency, enable it everywhere.

Mmh, so that changes the build for an awful lot of boards, especially old ones that no one can be bothered to test anymore. I am bit scared of that change there, especially with the limited SRAM size there.

I think the main motivation stems from crust on H3, and since H3 boards are still in good use and get tested, I'd prefer to enable it just for H3 boards, at least for now.
If we don't hear anything bad for a while, we could try to enable it (by default) on the other SoCs as well.

What do you think?

Cheers,
Andre

Quoted 39 lines

---

(no changes since v2)

Changes in v2:
- New patch for v2, split from the .dtsi changes

 arch/arm/Kconfig   | 1 +
 common/spl/Kconfig | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +1 -0
index d812685c984..42781d02f0f 100644
@@ -1167,6 +1167,7 @@ config ARCH_SUNXI
 	imply SPL_GPIO
 	imply SPL_LIBCOMMON_SUPPORT
 	imply SPL_LIBGENERIC_SUPPORT
+	imply SPL_LOAD_FIT
 	imply SPL_MMC if MMC
 	imply SPL_POWER
 	imply SPL_SERIAL
common/spl/Kconfig +1 -2
index a0968ff1065..aebbfbf99d2 100644
@@ -567,8 +567,7 @@ config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
 config SPL_FIT_IMAGE_TINY
 	bool "Remove functionality from SPL FIT loading to reduce size"
 	depends on SPL_FIT
-	default y if MACH_SUN50I || MACH_SUN50I_H5 || SUN50I_GEN_H6
-	default y if ARCH_IMX8M || ARCH_IMX9
+	default y if ARCH_IMX8M || ARCH_IMX9 || ARCH_SUNXI
 	help
 	  Enable this to reduce the size of the FIT image loading code
 	  in SPL, if space for the SPL binary is very tight.
#12 lore raw

Re: [PATCH v3 4/4] sunxi: Enable SPL FIT loading for 32-bit SoCs

On Fri, 8 Dec 2023 01:39:45 +0000
Andre Przywara <[email protected]> wrote:

Hi Samuel,

Quoted 14 lines

On Tue, 31 Oct 2023 00:17:41 -0500
Samuel Holland <[email protected]> wrote:

Hi,

Quoted 4 lines

Now that 32-bit SoCs can load U-Boot proper (and possibly other firmware) from a FIT, use this method by default. SPL_FIT_IMAGE_TINY is required to stay within the 24 or 32 KiB SPL size limit on early SoCs; for consistency, enable it everywhere.

Mmh, so that changes the build for an awful lot of boards, especially old ones that no one can be bothered to test anymore. I am bit scared of that change there, especially with the limited SRAM size there.

Quoted 7 lines

I think the main motivation stems from crust on H3, and since H3 boards are still in good use and get tested, I'd prefer to enable it just for H3 boards, at least for now.
If we don't hear anything bad for a while, we could try to enable it (by default) on the other SoCs as well.

What do you think?

Any ideas here? I plan to take the other three patches, which would already allow people to enable FIT in their (def)config. I can just leave this one off for now, and we can merge a changed version later?

Cheers,
Andre

Quoted 40 lines
Quoted 39 lines

---

(no changes since v2)

Changes in v2:
- New patch for v2, split from the .dtsi changes

 arch/arm/Kconfig   | 1 +
 common/spl/Kconfig | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +1 -0
index d812685c984..42781d02f0f 100644
@@ -1167,6 +1167,7 @@ config ARCH_SUNXI
 	imply SPL_GPIO
 	imply SPL_LIBCOMMON_SUPPORT
 	imply SPL_LIBGENERIC_SUPPORT
+	imply SPL_LOAD_FIT
 	imply SPL_MMC if MMC
 	imply SPL_POWER
 	imply SPL_SERIAL
common/spl/Kconfig +1 -2
index a0968ff1065..aebbfbf99d2 100644
@@ -567,8 +567,7 @@ config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
 config SPL_FIT_IMAGE_TINY
 	bool "Remove functionality from SPL FIT loading to reduce size"
 	depends on SPL_FIT
-	default y if MACH_SUN50I || MACH_SUN50I_H5 || SUN50I_GEN_H6
-	default y if ARCH_IMX8M || ARCH_IMX9
+	default y if ARCH_IMX8M || ARCH_IMX9 || ARCH_SUNXI
 	help
 	  Enable this to reduce the size of the FIT image loading code
 	  in SPL, if space for the SPL binary is very tight.  
#13 lore raw

Re: [PATCH v3 4/4] sunxi: Enable SPL FIT loading for 32-bit SoCs

On Wed, 17 Jan 2024 00:19:05 +0000
Andre Przywara <[email protected]> wrote:

Hi,

Quoted 25 lines

On Fri, 8 Dec 2023 01:39:45 +0000
Andre Przywara <[email protected]> wrote:

Hi Samuel,

Quoted 20 lines

On Tue, 31 Oct 2023 00:17:41 -0500
Samuel Holland <[email protected]> wrote:

Hi,

Quoted 4 lines

Now that 32-bit SoCs can load U-Boot proper (and possibly other firmware) from a FIT, use this method by default. SPL_FIT_IMAGE_TINY is required to stay within the 24 or 32 KiB SPL size limit on early SoCs; for consistency, enable it everywhere.

Mmh, so that changes the build for an awful lot of boards, especially old ones that no one can be bothered to test anymore. I am bit scared of that change there, especially with the limited SRAM size there.

I think the main motivation stems from crust on H3, and since H3 boards are still in good use and get tested, I'd prefer to enable it just for H3 boards, at least for now.
If we don't hear anything bad for a while, we could try to enable it (by default) on the other SoCs as well.

Quoted 6 lines
Quoted 1 line

What do you think?

Any ideas here? I plan to take the other three patches, which would already allow people to enable FIT in their (def)config. I can just leave this one off for now, and we can merge a changed version later?

So I took this patch as well, but removed the hunk with "imply SPL_LOAD_FIT" below. This means we still allow people to enable FIT images individually, but no defconfig or Kconfig option would default to it. Happy to discuss this decision and maybe take a later patch to rectify the situation.

Cheers,
Andre

Quoted 41 lines
Quoted 40 lines
Quoted 39 lines

---

(no changes since v2)

Changes in v2:
- New patch for v2, split from the .dtsi changes

 arch/arm/Kconfig   | 1 +
 common/spl/Kconfig | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +1 -0
index d812685c984..42781d02f0f 100644
@@ -1167,6 +1167,7 @@ config ARCH_SUNXI
 	imply SPL_GPIO
 	imply SPL_LIBCOMMON_SUPPORT
 	imply SPL_LIBGENERIC_SUPPORT
+	imply SPL_LOAD_FIT
 	imply SPL_MMC if MMC
 	imply SPL_POWER
 	imply SPL_SERIAL
common/spl/Kconfig +1 -2
index a0968ff1065..aebbfbf99d2 100644
@@ -567,8 +567,7 @@ config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
 config SPL_FIT_IMAGE_TINY
 	bool "Remove functionality from SPL FIT loading to reduce size"
 	depends on SPL_FIT
-	default y if MACH_SUN50I || MACH_SUN50I_H5 || SUN50I_GEN_H6
-	default y if ARCH_IMX8M || ARCH_IMX9
+	default y if ARCH_IMX8M || ARCH_IMX9 || ARCH_SUNXI
 	help
 	  Enable this to reduce the size of the FIT image loading code
 	  in SPL, if space for the SPL binary is very tight.    
Acked-by on the v3 series
#14 lore raw
In reply to Samuel Holland
Quoted 30 lines · Samuel Holland

This series makes the necessary changes so 32-bit sunxi SoCs can load additional device trees or firmware from SPL along with U-Boot proper. Crust (SCP firmware) has support for A33 and H3, and H3 also needs to load an eGon blob to support CPU 0 hotplug (a silicon bug workaround).

FIT unlocks more features (signatures, multiple DTBs, etc.), so enable it by default. A10 (sun4i) only has 24 KiB of SRAM A1, so it needs SPL_FIT_IMAGE_TINY. For consistency, enable that option everywhere.

After this series is applied, we can increase SPL_MAX_SIZE for H6 and newer SoCs, both 32-bit (e.g. A50, T113) and 64-bit. I did not do that yet because there is some discussion to be had about the correct value:
it must be adjusted to guarantee return-to-FEL functionality, and the exact adjustment depends on the sunxi-fel tool implementation.

Changes in v3:
- Rebased and collected tags

Changes in v2:
- Disable padding from SPL_PAD_TO
- Rely on binman min-size instead of using explicit offsets
- Use Kconfig for firmware addresses instead of an #ifdef staircase

Samuel Holland (4):
sunxi: spl: Disable padding from SPL_PAD_TO
sunxi: binman: Move BL31 and SCP firmware addresses to Kconfig
sunxi: binman: Support FIT generation for 32-bit SoCs
sunxi: Enable SPL FIT loading for 32-bit SoCs

Quoted 9 lines
 arch/arm/Kconfig               |  1 +
 arch/arm/dts/sunxi-u-boot.dtsi | 39 ++++++++++++++++++----------------
 arch/arm/mach-sunxi/Kconfig    | 17 +++++++++++++++
 common/spl/Kconfig             |  6 ++----
 4 files changed, 41 insertions(+), 22 deletions(-)

--
2.41.0

Looks good!