[PATCH 0/3] 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(-)

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.
Signed-off-by: Aswath Govindraju a-govindraju@ti.com --- board/ti/am64x/evm.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/board/ti/am64x/evm.c b/board/ti/am64x/evm.c index 21c58c76d67a..1a9f69c6cf1b 100644 --- a/board/ti/am64x/evm.c +++ b/board/ti/am64x/evm.c @@ -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) {

On Wed, Aug 04, 2021 at 06:42:44PM +0530, Aswath Govindraju wrote:
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.
Signed-off-by: Aswath Govindraju a-govindraju@ti.com
Applied to u-boot/master, thanks!

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.
Signed-off-by: Aswath Govindraju a-govindraju@ti.com --- include/environment/ti/mmc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/environment/ti/mmc.h b/include/environment/ti/mmc.h index b86c8dc7a4f3..769ea9d5ef70 100644 --- a/include/environment/ti/mmc.h +++ b/include/environment/ti/mmc.h @@ -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 " \

On Wed, Aug 04, 2021 at 06:42:45PM +0530, Aswath Govindraju wrote:
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.
Signed-off-by: Aswath Govindraju a-govindraju@ti.com
Applied to u-boot/master, thanks!

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.
Signed-off-by: Aswath Govindraju a-govindraju@ti.com --- include/configs/am64x_evm.h | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/include/configs/am64x_evm.h b/include/configs/am64x_evm.h index 7c520f4395b5..f3d46449011a 100644 --- a/include/configs/am64x_evm.h +++ b/include/configs/am64x_evm.h @@ -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>

On Wed, Aug 04, 2021 at 06:42:46PM +0530, Aswath Govindraju wrote:
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.
Signed-off-by: Aswath Govindraju a-govindraju@ti.com
Applied to u-boot/master, thanks!
participants (2)
-
Aswath Govindraju
-
Tom Rini