Skip to contentSkip to conversation

sunxi: SPL FIT support for 32-bit sunxi SoCs

PATCH In review Samuel Holland 2 participants 5 messages Oct 13, 2021

Subsystems (2)
lore
Share & tools
lore

Samuel Holland

author maintainer
#0 lore raw

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.

There was no existing binman entry property that put the FIT at the right offset. The minimum offset is 32k, but this matches neither the SPL size (which is no more than 24k on some SoCs) nor the FIT alignment (which is 512 bytes in practice due to SPL size constraints). So instead of adding a new property, I fixed what is arguably a bug in the offset property -- though this strategy will not work if someone is intentionally creating overlapping entries.

Samuel Holland (3):
Kconfig: Remove an impossible condition
binman: Prevent entries in a section from overlapping
sunxi: binman: Enable SPL FIT loading for 32-bit SoCs

 Kconfig                        |  2 +-
 arch/arm/Kconfig               |  1 +
 arch/arm/dts/sunxi-u-boot.dtsi | 46 ++++++++++++++++++++++------------
 common/spl/Kconfig             |  3 +--
 tools/binman/entry.py          |  4 ++-
 5 files changed, 36 insertions(+), 20 deletions(-)
Signature · 1 line
2.32.0
author maintainer
#1 lore raw

PATCH 1/3 Kconfig: Remove an impossible condition

ARCH_SUNXI selects BINMAN, so the condition "!BINMAN && ARCH_SUNXI" is impossible to satisfy.

---

 Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Kconfig +1 -1
index 931a22806e..ede20d74c9 100644
@@ -359,7 +359,7 @@ config BUILD_TARGET
 	default "u-boot-spl.kwb" if ARCH_MVEBU && SPL
 	default "u-boot-elf.srec" if RCAR_GEN3
 	default "u-boot.itb" if !BINMAN && SPL_LOAD_FIT && (ARCH_ROCKCHIP || \
-				ARCH_SUNXI || RISCV || ARCH_ZYNQMP)
+				RISCV || ARCH_ZYNQMP)
 	default "u-boot.kwb" if ARCH_KIRKWOOD
 	default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT
 	default "u-boot-with-spl.imx" if ARCH_MX6 && SPL
Signature · 1 line
2.32.0
author maintainer
#2 lore raw

PATCH 2/3 binman: Prevent entries in a section from overlapping

In reply to Samuel Holland

Currently, if the "offset" property is given for an entry, the section's running offset is completely ignored. This causes entries to overlap if the provided offset is less than the size of the entries earlier in the section. Avoid the overlap by only using the provided offset when it is greater than the running offset.

The motivation for this change is the rule used by SPL to find U-Boot on sunxi boards: U-Boot starts 32 KiB after the start of SPL, unless SPL is larger than 32 KiB, in which case U-Boot immediately follows SPL.

---

 tools/binman/entry.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/binman/entry.py +3 -1
index 70222718ea..61822eb5e4 100644
@@ -404,7 +404,9 @@ class Entry(object):
             if self.offset_unset:
                 self.Raise('No offset set with offset-unset: should another '
                            'entry provide this correct offset?')
-            self.offset = tools.Align(offset, self.align)
+        elif self.offset > offset:
+            offset = self.offset
+        self.offset = tools.Align(offset, self.align)
         needed = self.pad_before + self.contents_size + self.pad_after
         needed = tools.Align(needed, self.align_size)
         size = self.size
Signature · 1 line
2.32.0
#3 lore raw

Re: [PATCH 2/3] binman: Prevent entries in a section from overlapping

Hi Samuel,

Quoted 33 lines · Samuel Holland

Currently, if the "offset" property is given for an entry, the section's running offset is completely ignored. This causes entries to overlap if the provided offset is less than the size of the entries earlier in the section. Avoid the overlap by only using the provided offset when it is greater than the running offset.

The motivation for this change is the rule used by SPL to find U-Boot on sunxi boards: U-Boot starts 32 KiB after the start of SPL, unless SPL is larger than 32 KiB, in which case U-Boot immediately follows SPL.

---

 tools/binman/entry.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/binman/entry.py +3 -2
index 70222718ea..61822eb5e4 100644
@@ -404,7 +404,9 @@ class Entry(object):
             if self.offset_unset:
                 self.Raise('No offset set with offset-unset: should another '
                            'entry provide this correct offset?')
-            self.offset = tools.Align(offset, self.align)
+        elif self.offset > offset:
+            offset = self.offset
+        self.offset = tools.Align(offset, self.align)
         needed = self.pad_before + self.contents_size + self.pad_after
         needed = tools.Align(needed, self.align_size)
         size = self.size
--
Quoted 2 lines

2.32.0

The behaviour needs to be deterministic, here. You have two cases, as I understand it

- you want the offset to be set to the running offset, if the previous section is >=32KB
- you want the offset to be set to the 'offset' property otherwise

I see a few options:

- Add a new 'sunxi-spl-pad' etype between SPL and U-Boot for the padding. It can decide its own size
- Add a new 'min-size' property to entries, update the packer, use it in the SPL node, set to 32KB

There are probably others. No need to worry about it if you are just putting out ideas, but we do need a test for any new behaivour:

binman test -T

needs to pass with 100% code coverage.

Regards,
Simon

author maintainer
#4 lore raw

PATCH 3/3 sunxi: binman: Enable SPL FIT loading for 32-bit SoCs

In reply to Samuel Holland

Now that Crust (SCP firmware) has support for H3, we need a FIT image to load it. H3 also needs to load a SoC-specific eGon blob to support CPU 0 hotplug. Let's first enable FIT support before adding extra firmware.

Update the binman description to work on either 32-bit or 64-bit SoCs:
- Make BL31 optional, since it is not used on 32-bit SoCs (though BL32 may be used in the future).
- Explicitly set the minimum offset of the FIT to 32 KiB, since SPL on some boards is still only 24 KiB large even with FIT support enabled. CONFIG_SPL_PAD_TO cannot be used because it is not defined for H616.

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 simplicity, enable that option everywhere.

---

 arch/arm/Kconfig               |  1 +
 arch/arm/dts/sunxi-u-boot.dtsi | 46 ++++++++++++++++++++++------------
 common/spl/Kconfig             |  3 +--
 3 files changed, 32 insertions(+), 18 deletions(-)
arch/arm/Kconfig +1 -0
index d8c041a877..f80f237f7e 100644
@@ -1062,6 +1062,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
arch/arm/dts/sunxi-u-boot.dtsi +30 -16

98 lines not on this page · raw message

common/spl/Kconfig +1 -2
index 17ce2f6b61..cad8125c4b 100644
@@ -443,8 +443,7 @@ config SPL_MD5
 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
+	default y if ARCH_IMX8M || 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.32.0