Skip to contentSkip to conversation

Enable distroboot as a boot option for am62x

PATCH In review Martyn Welch 3 participants 6 messages Dec 20, 2022 – Jan 11, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Enable distroboot as a boot option for am62x

The am62x config currently doesn't enable distroboot as an option for booting. Add this as a further option after the existing mechanisms have failed.

Whilst working on this it was found that boot detection was failing on the am625-sk when attempting to boot from raw offsets on an SD card. Boot mode is updated to correctly detect the boot mode from the SoC boot config.

Martyn Welch (2):
arm64:mach-k3 am625_init: Correct boot mode detection
configs: Enable distroboot on am625

 arch/arm/mach-k3/am625_init.c   | 19 +++++++++----------
 configs/am62x_evm_a53_defconfig |  2 +-
 include/configs/am62x_evm.h     | 26 +++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 12 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/2 arm64:mach-k3 am625_init: Correct boot mode detection

The boot mode detection assumes that BOOT_DEVICE_MMC2 should always result in MMCSD_MODE_FS, but MMCSD_MODE_RAW is also a valid option for this port.

The current logic also avoids looking at the bootmode pin strapping, which should be the primary means of determining whether a device is being booted in MMCSD_MODE_EMMCBOOT mode.

Switch around the logic to check the boot mode to determine whether the eMMC boot mode is expected or MMC/SD boot mode. From there we can look at the boot mode config if in MMC/SD boot mode to determine whether to attempt RAW or FS based booting.

This change allows U-Boot to also be successfully booted from RAW offsets in addition to from a filesystem.

---
 arch/arm/mach-k3/am625_init.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
arch/arm/mach-k3/am625_init.c +9 -10
index da2229d0bf..a91c15ca4e 100644
@@ -173,21 +173,20 @@ void board_init_f(ulong dummy)
 u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 	u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT);
+	u32 bootmode = (devstat & MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK) >>
+				MAIN_DEVSTAT_PRIMARY_BOOTMODE_SHIFT;
 	u32 bootmode_cfg = (devstat & MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK) >>
 			    MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT;
 
-	switch (boot_device) {
-	case BOOT_DEVICE_MMC1:
-		if ((bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK) >>
-		     MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_SHIFT)
-			return MMCSD_MODE_EMMCBOOT;
-		return MMCSD_MODE_FS;
-
-	case BOOT_DEVICE_MMC2:
-		return MMCSD_MODE_FS;
 
+	switch (bootmode) {
+	case BOOT_DEVICE_EMMC:
+		return MMCSD_MODE_EMMCBOOT;
+	case BOOT_DEVICE_MMC:
+		if (bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK)
+			return MMCSD_MODE_RAW;
 	default:
-		return MMCSD_MODE_RAW;
+		return MMCSD_MODE_FS;
 	}
 }
 
Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH 1/2] arm64:mach-k3 am625_init: Correct boot mode detection

Quoted 13 lines · Martyn Welch

The boot mode detection assumes that BOOT_DEVICE_MMC2 should always result in MMCSD_MODE_FS, but MMCSD_MODE_RAW is also a valid option for this port.

The current logic also avoids looking at the bootmode pin strapping, which should be the primary means of determining whether a device is being booted in MMCSD_MODE_EMMCBOOT mode.

Switch around the logic to check the boot mode to determine whether the eMMC boot mode is expected or MMC/SD boot mode. From there we can look at the boot mode config if in MMC/SD boot mode to determine whether to attempt RAW or FS based booting.

Quoted 4 lines

This change allows U-Boot to also be successfully booted from RAW offsets in addition to from a filesystem.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#3 lore raw

PATCH 2/2 configs: Enable distroboot on am625

In reply to Martyn Welch

TI boards use a custom (though faily common to TI boards) mechanism for booting Linux. We would like to use the "distroboot" approach.

Enable distroboot as a further option to use for booting on am625 should the existing options fail.

---
 configs/am62x_evm_a53_defconfig |  2 +-
 include/configs/am62x_evm.h     | 26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)
configs/am62x_evm_a53_defconfig +1 -1
index ff258bcbc1..ea248090e4 100644
@@ -20,7 +20,7 @@ CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80480000
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000
-CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern"
+CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern; setenv fdtfile ti/${name_fdt}; run distro_bootcmd"
 CONFIG_SPL_MAX_SIZE=0x58000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x80a00000
include/configs/am62x_evm.h +25 -1
index 78201adc07..335c27c5cb 100644
@@ -15,6 +15,29 @@
 /* DDR Configuration */
 #define CONFIG_SYS_SDRAM_BASE1		0x880000000
 
+#ifdef CONFIG_CMD_MMC
+#define DISTRO_BOOT_DEV_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1)
+#else
+#define DISTRO_BOOT_DEV_MMC(func)
+#endif
+
+#ifdef CONFIG_CMD_PXE
+#define DISTRO_BOOT_DEV_PXE(func) func(PXE, pxe, na)
+#else
+#define DISTRO_BOOT_DEV_PXE(func)
+#endif
+
+#ifdef CONFIG_CMD_DHCP
+#define DISTRO_BOOT_DEV_DHCP(func) func(DHCP, dhcp, na)
+#else
+#define DISTRO_BOOT_DEV_DHCP(func)
+#endif
+
+#define BOOT_TARGET_DEVICES(func) \
+	DISTRO_BOOT_DEV_MMC(func) \
+	DISTRO_BOOT_DEV_PXE(func) \
+	DISTRO_BOOT_DEV_DHCP(func)
+
 #define PARTS_DEFAULT \
 	/* Linux partitions */ \
 	"name=rootfs,start=0,size=-,uuid=${uuid_gpt_rootfs}\0"
@@ -59,7 +82,8 @@
 	DEFAULT_LINUX_BOOT_ENV						\
 	DEFAULT_MMC_TI_ARGS						\
 	EXTRA_ENV_AM625_BOARD_SETTINGS					\
-	EXTRA_ENV_AM625_BOARD_SETTINGS_MMC
+	EXTRA_ENV_AM625_BOARD_SETTINGS_MMC				\
+	BOOTENV
 
 /* Now for the remaining common defines */
 #include <configs/ti_armv7_common.h>
Signature · 1 line
2.35.1
#4 lore raw

Re: [PATCH 2/2] configs: Enable distroboot on am625

Quoted 7 lines · Martyn Welch

TI boards use a custom (though faily common to TI boards) mechanism for booting Linux. We would like to use the "distroboot" approach.

Enable distroboot as a further option to use for booting on am625 should the existing options fail.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
Reviewed-by on the v1 series
#5 lore raw
In reply to Martyn Welch

Hi Martyn!

On December 20, 2022 thus sayeth Martyn Welch:

Quoted 4 lines

The am62x config currently doesn't enable distroboot as an option for booting. Add this as a further option after the existing mechanisms have failed.

Quoted 8 lines

Whilst working on this it was found that boot detection was failing on the am625-sk when attempting to boot from raw offsets on an SD card. Boot mode is updated to correctly detect the boot mode from the SoC boot config.

Martyn Welch (2):
arm64:mach-k3 am625_init: Correct boot mode detection
configs: Enable distroboot on am625

I'm excited to start getting rid of these custom boot scripts

I was looking at 'Standard Boot'[0] as my solution :)

~Bryan

[0] https://u-boot.readthedocs.io/en/latest/develop/bootstd.html