Skip to contentSkip to conversation

imx8mn_ddr4_evk: Add USB Mass Storage support

PATCH In review Fabio Estevam 5 participants 9 messages Apr 21, 2022 – May 20, 2022

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v3 1/2 imx8mn_ddr4_evk: Add USB Mass Storage support

From: Fabio Estevam <[email protected]>

Add USB Mass Storage support, which is a convenient way to flash the eMMC card, for example.

---
Changes since v2:
- None

 configs/imx8mn_ddr4_evk_defconfig | 12 ++++++++++++
 1 file changed, 12 insertions(+)
configs/imx8mn_ddr4_evk_defconfig +12 -0
index 917cdb5aa9d9..065f7392b706 100644
@@ -42,6 +42,8 @@ CONFIG_CMD_FUSE=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
@@ -82,4 +84,14 @@ CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_SYSRESET_WATCHDOG=y
 CONFIG_DM_THERMAL=y
+CONFIG_USB=y
+# CONFIG_SPL_DM_USB is not set
+CONFIG_USB_EHCI_HCD=y
+CONFIG_MXC_USB_OTG_HACTIVE=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_CI_UDC=y
+CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_IMX_WATCHDOG=y
Signature · 1 line
2.25.1
author reviewer
#1 lore raw

PATCH v3 2/2 imx8mn/8mp: Allow booting via USB

From: Fabio Estevam <[email protected]>

When trying to boot via USB on i.MX8MN it is necessary to specify the U-Boot environment location, otherwise the boot process simply hangs.

Specify the environment location when booting from USB.

Tested on a imx8mn-evk.

---
Changes since v2:
- Handle explicitly the CONFIG_ENV_IS_NOWHERE case and return ENVL_UNKNOWN as fallback (Marek).

 arch/arm/mach-imx/imx8m/soc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +10 -0
index 7059d87e336b..34a07b53e57a 100644
@@ -1536,6 +1536,16 @@ enum env_location arch_env_get_location(enum env_operation op, int prio)
 		return ENVL_UNKNOWN;
 
 	switch (dev) {
+	case USB_BOOT:
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
+			return ENVL_SPI_FLASH;
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND))
+			return ENVL_NAND;
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
+			return ENVL_MMC;
+		if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
+			return ENVL_NOWHERE;
+		return ENVL_UNKNOWN;
 	case QSPI_BOOT:
 	case SPI_NOR_BOOT:
 		if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB

Quoted 43 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

When trying to boot via USB on i.MX8MN it is necessary to specify the U-Boot environment location, otherwise the boot process simply hangs.

Specify the environment location when booting from USB.

Tested on a imx8mn-evk.

---
Changes since v2:
- Handle explicitly the CONFIG_ENV_IS_NOWHERE case and return ENVL_UNKNOWN as fallback (Marek).

 arch/arm/mach-imx/imx8m/soc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +10 -1
index 7059d87e336b..34a07b53e57a 100644
@@ -1536,6 +1536,16 @@ enum env_location arch_env_get_location(enum env_operation op, int prio)
                return ENVL_UNKNOWN;
 
        switch (dev) {
+       case USB_BOOT:
+               if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
+                       return ENVL_SPI_FLASH;
+               if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND))
+                       return ENVL_NAND;
+               if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
+                       return ENVL_MMC;
+               if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
+                       return ENVL_NOWHERE;
+               return ENVL_UNKNOWN;
        case QSPI_BOOT:
        case SPI_NOR_BOOT:
                if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
--
Quoted 2 lines

2.25.1

Fabio,

Thanks - this at least allows me to boot on imx8mp-venice-gw74xx without needing to enable CONFIG_ENV_IS_NOWHERE.

I do however notice when I do so env is attempted to load from MMC dev 0 (CONFIG_ENV_IS_IN_MMC=y) - what controls the device number in this case as for this board, the emmc is dev 2.

U-Boot SPL 2022.04-00073-g9d2b56e8338a (Apr 25 2022 - 12:35:37 -0700)
DRAM : LPDDR4 4 GiB
WDT: Started watchdog@30280000 with servicing (60s timeout)
Trying to boot from BOOTROM
Find img info 0x48025c00, size 1396
Need continue download 1024
DTB : imx8mp-venice-gw74xx
Download 873624, Total size 875672

NOTICE:  BL31: v2.4(release):f884ad7b0ba2
NOTICE:  BL31: Built : 14:00:19, Mar 17 2022

U-Boot 2022.04-00073-g9d2b56e8338a (Apr 25 2022 - 12:35:37 -0700)

CPU:   Freescale i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 46C
Reset cause: POR
Model: Gateworks Venice GW74xx i.MX8MP board
DRAM:  4 GiB
clk_register: failed to get osc_32k device (parent of usb_root_clk)
Core:  211 devices, 24 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing (60s timeout)
MMC:   FSL_SDHC: 2

Loading Environment from MMC... MMC Device 0 not found *** Warning - No MMC card found, using default environment

In:    serial@30890000
Out:   serial@30890000
Err:   serial@30890000
Net:   KSZ9897S: eth2: lan1, eth3: lan2, eth4: lan3, eth5: lan4, eth6:

lan5, eth1: ethernet@30be0000, eth0: ethernet@30bf0000

Best Regards,

Tim

#3 lore raw

Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB

Hi Tim,

Quoted 4 lines · Tim Harvey

Fabio,

Thanks - this at least allows me to boot on imx8mp-venice-gw74xx without needing to enable CONFIG_ENV_IS_NOWHERE.

Care to reply with your Tested-by?

Quoted 4 lines

I do however notice when I do so env is attempted to load from MMC dev 0 (CONFIG_ENV_IS_IN_MMC=y) - what controls the device number in this case as for this board, the emmc is dev 2.

That's a separate issue.

I see that you replied to Peng's patch:
"imx: dynamic setting mmcdev and mmcroot" and this is likely the cause for your env numbering problem.

Tested-by
#4 lore raw

Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB

Quoted 11 lines · Fabio Estevam

Hi Tim,

Quoted 4 lines · Tim Harvey

Fabio,

Thanks - this at least allows me to boot on imx8mp-venice-gw74xx without needing to enable CONFIG_ENV_IS_NOWHERE.

Care to reply with your Tested-by?

Sure,

Quoted 7 lines
Quoted 5 lines

I do however notice when I do so env is attempted to load from MMC dev 0 (CONFIG_ENV_IS_IN_MMC=y) - what controls the device number in this case as for this board, the emmc is dev 2.

That's a separate issue.

agreed it would be a separate issue... just curious if you knew where that was coming from. It certainly isn't a common behavior to boot via USB then expect 'saveenv' to save to a specific eMMC device.

Quoted 4 lines

I see that you replied to Peng's patch:
"imx: dynamic setting mmcdev and mmcroot" and this is likely the cause for your env numbering problem.

That has nothing to do with the mmc device used for U-Boot env. Commit f342c9e381c0 ("imx: dynamic setting mmcdev and mmcroot") adds setting 'mmcroot=' if mmcautodetect=yes which seems to me like a completely inappropriate hack that assumes U-Boot's mmc device numbering matches the kernels device numbering (which has changed over time and is not a stable ABI). I believe you have been involved in discussions about that in the past as well regarding how to best tell the kernel what the root device is. Every discussion I have seen (and there have been many over the years) end up with the recommendation of using UUID.

Best regards,

Tim

author reviewer
#5 lore raw

Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB

Hi Tim,

Quoted 1 line · Tim Harvey

Thanks.

Quoted 5 lines

agreed it would be a separate issue... just curious if you knew where that was coming from. It certainly isn't a common behavior to boot via USB then expect 'saveenv' to save to a specific eMMC device.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

I see that you replied to Peng's patch:
"imx: dynamic setting mmcdev and mmcroot" and this is likely the cause for your env numbering problem.

That has nothing to do with the mmc device used for U-Boot env. Commit f342c9e381c0 ("imx: dynamic setting mmcdev and mmcroot") adds setting 'mmcroot=' if mmcautodetect=yes which seems to me like a completely inappropriate hack that assumes U-Boot's mmc device numbering matches

Agreed.

Quoted 5 lines

the kernels device numbering (which has changed over time and is not a stable ABI). I believe you have been involved in discussions about that in the past as well regarding how to best tell the kernel what the root device is. Every discussion I have seen (and there have been many over the years) end up with the recommendation of using UUID.

Yes, using UUID is good solution for that.

mmc alias also works in kernels > 5.10 too.

#6 lore raw

Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB

Hi Fabio

Quoted 31 lines · Fabio Estevam

Hi Tim,

Quoted 1 line · Tim Harvey

Thanks.

Quoted 5 lines

agreed it would be a separate issue... just curious if you knew where that was coming from. It certainly isn't a common behavior to boot via USB then expect 'saveenv' to save to a specific eMMC device.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

I see that you replied to Peng's patch:
"imx: dynamic setting mmcdev and mmcroot" and this is likely the cause for your env numbering problem.

That has nothing to do with the mmc device used for U-Boot env. Commit f342c9e381c0 ("imx: dynamic setting mmcdev and mmcroot") adds setting 'mmcroot=' if mmcautodetect=yes which seems to me like a completely inappropriate hack that assumes U-Boot's mmc device numbering matches

Agreed.

Quoted 5 lines

the kernels device numbering (which has changed over time and is not a stable ABI). I believe you have been involved in discussions about that in the past as well regarding how to best tell the kernel what the root device is. Every discussion I have seen (and there have been many over the years) end up with the recommendation of using UUID.

Quoted 3 lines

Yes, using UUID is good solution for that.

mmc alias also works in kernels > 5.10 too.

What changes if we drop? Does the board boot anyway?

Michael

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#7 lore raw

PATCH v3 2/2 imx8mn/8mp: Allow booting via USB

In reply to Fabio Estevam
Quoted 9 lines

From: Fabio Estevam <[email protected]>
When trying to boot via USB on i.MX8MN it is necessary to specify the U-Boot environment location, otherwise the boot process simply hangs.
Specify the environment location when booting from USB. Tested on a imx8mn-evk.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#8 lore raw

PATCH v3 1/2 imx8mn_ddr4_evk: Add USB Mass Storage support

In reply to Fabio Estevam
Quoted 4 lines

From: Fabio Estevam <[email protected]>
Add USB Mass Storage support, which is a convenient way to flash the eMMC card, for example.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================