[PATCH 3/5] sunxi: Simplify eMMC boot partition booting

Andre Przywara andre.przywara at arm.com
Sun Nov 8 14:14:07 CET 2020


The Allwinner BROM also supports loading the SPL from the eMMC boot
partition, for this we have to set the CONFIG_SUPPORT_EMMC_BOOT Kconfig
symbol. But on top of that a user has to manually adjust the raw sector
to load U-Boot proper from: CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR.

To simplify this, we adjust the sector offset dynamically, whenever we
find CONFIG_SUPPORT_EMMC_BOOT enabled and are booting from the eMMC.

Unfortunately the BROM sets the same boot source code as for the boot
from the normal eMMC user data partition, so we can't tell those two
cases apart easily (yet).

Signed-off-by: Andre Przywara <andre.przywara at arm.com>
---
 arch/arm/mach-sunxi/board.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index f40fccd8f8b..586af24535d 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -279,21 +279,29 @@ uint32_t sunxi_get_boot_device(void)
 #ifdef CONFIG_SPL_BUILD
 /*
  * The eGON SPL image can be located at 8KB or at 128KB into an SD card or
- * an eMMC device. The boot source has bit 4 set in the latter case.
+ * an eMMC user partition. The boot source has bit 4 set in the latter case.
  * By adding 120KB to the normal offset when booting from a "high" location
  * we can support both cases.
+ * In an eMMC boot partition the SPL is located at offset 0, so we subtract
+ * the usual 8K offset.
  */
 unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
 {
 	unsigned long sector = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR;
 
 	switch (sunxi_get_boot_source()) {
+	case SUNXI_BOOTED_FROM_MMC2:
+		if (IS_ENABLED(CONFIG_SUPPORT_EMMC_BOOT))
+			sector -= 8 * 2;
+		break;
 	case SUNXI_BOOTED_FROM_MMC0_HIGH:
 	case SUNXI_BOOTED_FROM_MMC2_HIGH:
 		sector += (128 - 8) * 2;
 		break;
 	}
 
+	debug("loading U-Boot proper from sector 0x%lx\n", sector);
+
 	return sector;
 }
 
-- 
2.17.5



More information about the U-Boot mailing list