sunxi: binman: Fix U-Boot offset when SPL is not 32 KiB
authorSamuel Holland <samuel@sholland.org>
Sat, 21 Jan 2023 23:25:17 +0000 (17:25 -0600)
committerAndre Przywara <andre.przywara@arm.com>
Fri, 28 Apr 2023 00:06:57 +0000 (01:06 +0100)
commit9a4aa31ad514a534e57b2607df327cb4f93b87bc
tree5a302db55d6a85ba142f7d97ea0d8b226b9f642d
parentc9c2c95d4cd27fe0cd41fe13a863899d268f973c
sunxi: binman: Fix U-Boot offset when SPL is not 32 KiB

On sunxi boards, SPL looks for U-Boot at a 32 KiB offset, unless SPL is
larger than 32 KiB, in which case U-Boot immediately follows SPL. See
the logic in spl_mmc_get_uboot_raw_sector() and spl_spi_load_image().

In two cases, the existing binman description mismatches the SPL code.
For 64-bit boards, binman would place U-Boot immediately following SPL,
even if SPL is smaller than 32 KiB. This can happen when SPL MMC support
is disabled (i.e. when booting from SPI flash).

In contrast, for 32-bit boards, binman would place U-Boot at 32 KiB,
even if SPL is larger than that. This happens because the 'offset'
property does not consider the size of previous entries.

Fix both issues by setting a minimum size for the SPL entry, which
exactly matches the logic in the SPL code. Unfortunately, this size must
be provided as a magic number, since none of the relevant config symbols
(SPL_PAD_TO, SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, and SYS_SPI_U_BOOT_OFFS)
are guaranteed to be defined in all cases.

Fixes: cfa3db602caf ("sunxi: Convert 64-bit boards to use binman")
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
arch/arm/dts/sunxi-u-boot.dtsi