Skip to contentSkip to conversation

AM64: Add support for booting to kernel from USB MSC device

PATCH In review Aswath Govindraju 2 participants 7 messages Aug 4, 2021 – Sep 11, 2021

lore
Share & tools
lore
#0 lore raw

cover AM64: Add support for booting to kernel from USB MSC device

The following series of patches add support for booting to kernel using USB MSC device as the boot media, in AM64

Aswath Govindraju (3):
board: ti: am64x: Add support for fixing dr_mode while booting from
USB
environment: ti: mmc.h: Make the finduuid generic for usage across
different device types
include: configs: am64x_evm: Add env variables for booting to kernel
using USB MSC device

 board/ti/am64x/evm.c         | 32 ++++++++++++++++++++++++++++++++
 include/configs/am64x_evm.h  | 31 ++++++++++++++++++++++++++++++-
 include/environment/ti/mmc.h |  2 +-
 3 files changed, 63 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 board: ti: am64x: Add support for fixing dr_mode while booting from USB

Fix the dr_mode in the U-Boot device tree blob, by reading the mode field from the USB Boot Configuration fields. The dr_mode will only be fixed when booting from USB.

---
 board/ti/am64x/evm.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
board/ti/am64x/evm.c +32 -0
index 21c58c76d67a..1a9f69c6cf1b 100644
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <spl.h>
+#include <fdt_support.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/sys_proto.h>
 #include <env.h>
@@ -60,6 +61,37 @@ int board_fit_config_name_match(const char *name)
 }
 #endif
 
+#if defined(CONFIG_SPL_BUILD) && CONFIG_IS_ENABLED(USB_STORAGE)
+static int fixup_usb_boot(const void *fdt_blob)
+{
+	int ret = 0;
+
+	switch (spl_boot_device()) {
+	case BOOT_DEVICE_USB:
+		/*
+		 * If the boot mode is host, fixup the dr_mode to host
+		 * before cdns3 bind takes place
+		 */
+		ret = fdt_find_and_setprop((void *)fdt_blob,
+					   "/bus@f4000/cdns-usb@f900000/usb@f400000",
+					   "dr_mode", "host", 5, 0);
+		if (ret)
+			printf("%s: fdt_find_and_setprop() failed:%d\n",
+			       __func__, ret);
+		fallthrough;
+	default:
+		break;
+	}
+
+	return ret;
+}
+
+void spl_perform_fixups(struct spl_image_info *spl_image)
+{
+	fixup_usb_boot(spl_image->fdt_addr);
+}
+#endif
+
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
 int do_board_detect(void)
 {
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/3] board: ti: am64x: Add support for fixing dr_mode while booting from USB

Quoted 5 lines · Aswath Govindraju

Fix the dr_mode in the U-Boot device tree blob, by reading the mode field from the USB Boot Configuration fields. The dr_mode will only be fixed when booting from USB.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#3 lore raw

PATCH 2/3 environment: ti: mmc.h: Make the finduuid generic for usage across different device types

In reply to Aswath Govindraju

Make finduuid generic by making it dependent on the boot variable. For example, this can now be used for finding the uuid of partitions in usb device too.

---
 include/environment/ti/mmc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/environment/ti/mmc.h +1 -1
index b86c8dc7a4f3..769ea9d5ef70 100644
@@ -11,7 +11,7 @@
 #define DEFAULT_MMC_TI_ARGS \
 	"mmcdev=0\0" \
 	"mmcrootfstype=ext4 rootwait\0" \
-	"finduuid=part uuid mmc ${bootpart} uuid\0" \
+	"finduuid=part uuid ${boot} ${bootpart} uuid\0" \
 	"args_mmc=run finduuid;setenv bootargs console=${console} " \
 		"${optargs} " \
 		"root=PARTUUID=${uuid} rw " \
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH 2/3] environment: ti: mmc.h: Make the finduuid generic for usage across different device types

Quoted 5 lines · Aswath Govindraju

Make finduuid generic by making it dependent on the boot variable. For example, this can now be used for finding the uuid of partitions in usb device too.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#5 lore raw

PATCH 3/3 include: configs: am64x_evm: Add env variables for booting to kernel using USB MSC device

In reply to Aswath Govindraju

Add env variables for booting to kernel from USB MSC device. The second partition in the USB MSC device needs to formatted as ext4 file system with kernel and dtb images, present in the /boot folder.

---
 include/configs/am64x_evm.h | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
include/configs/am64x_evm.h +30 -1
index 7c520f4395b5..f3d46449011a 100644
@@ -96,6 +96,34 @@
 		"${bootdir}/${name_fit}\0"				\
 	"partitions=" PARTS_DEFAULT
 
+#define EXTRA_ENV_AM642_BOARD_SETTING_USBMSC				\
+	"args_usb=run finduuid;setenv bootargs console=${console} "	\
+		"${optargs} "						\
+		"root=PARTUUID=${uuid} rw "				\
+		"rootfstype=${mmcrootfstype}\0"				\
+	"init_usb=run args_all args_usb\0"				\
+	"get_fdt_usb=load usb ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
+	"get_overlay_usb="						\
+		"fdt address ${fdtaddr};"				\
+		"fdt resize 0x100000;"					\
+		"for overlay in $name_overlays;"			\
+		"do;"							\
+		"load usb ${bootpart} ${dtboaddr} ${bootdir}/${overlay} && "	\
+		"fdt apply ${dtboaddr};"				\
+		"done;\0"						\
+	"get_kern_usb=load usb ${bootpart} ${loadaddr} "		\
+		"${bootdir}/${name_kern}\0"				\
+	"get_fit_usb=load usb ${bootpart} ${addr_fit} "			\
+		"${bootdir}/${name_fit}\0"				\
+	"usbboot=setenv boot usb;"					\
+		"setenv bootpart 0:2;"					\
+		"usb start;"						\
+		"run findfdt;"						\
+		"run init_usb;"						\
+		"run get_kern_usb;"					\
+		"run get_fdt_usb;"					\
+		"run run_kern\0"
+
 #define EXTRA_ENV_DFUARGS \
 	DFU_ALT_INFO_MMC \
 	DFU_ALT_INFO_EMMC \
@@ -108,7 +136,8 @@
 	DEFAULT_MMC_TI_ARGS						\
 	EXTRA_ENV_AM642_BOARD_SETTINGS					\
 	EXTRA_ENV_AM642_BOARD_SETTINGS_MMC				\
-	EXTRA_ENV_DFUARGS
+	EXTRA_ENV_DFUARGS						\
+	EXTRA_ENV_AM642_BOARD_SETTING_USBMSC
 
 /* Now for the remaining common defines */
 #include <configs/ti_armv7_common.h>
Signature · 1 line
2.17.1
#6 lore raw

Re: [PATCH 3/3] include: configs: am64x_evm: Add env variables for booting to kernel using USB MSC device

Quoted 5 lines · Aswath Govindraju

Add env variables for booting to kernel from USB MSC device. The second partition in the USB MSC device needs to formatted as ext4 file system with kernel and dtb images, present in the /boot folder.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom