public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v3 1/2] imx8mn_ddr4_evk: Add USB Mass Storage support
@ 2022-04-21 18:05 Fabio Estevam
  2022-04-21 18:05 ` [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB Fabio Estevam
  2022-05-20 13:41 ` [PATCH v3 1/2] imx8mn_ddr4_evk: Add USB Mass Storage support sbabic
  0 siblings, 2 replies; 9+ messages in thread
From: Fabio Estevam @ 2022-04-21 18:05 UTC (permalink / raw)
  To: sbabic; +Cc: peng.fan, u-boot, aford173, michael, marex, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

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

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
Changes since v2:
- None

 configs/imx8mn_ddr4_evk_defconfig | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/configs/imx8mn_ddr4_evk_defconfig b/configs/imx8mn_ddr4_evk_defconfig
index 917cdb5aa9d9..065f7392b706 100644
--- a/configs/imx8mn_ddr4_evk_defconfig
+++ b/configs/imx8mn_ddr4_evk_defconfig
@@ -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
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB
  2022-04-21 18:05 [PATCH v3 1/2] imx8mn_ddr4_evk: Add USB Mass Storage support Fabio Estevam
@ 2022-04-21 18:05 ` Fabio Estevam
  2022-04-25 19:41   ` Tim Harvey
  2022-05-20 13:44   ` sbabic
  2022-05-20 13:41 ` [PATCH v3 1/2] imx8mn_ddr4_evk: Add USB Mass Storage support sbabic
  1 sibling, 2 replies; 9+ messages in thread
From: Fabio Estevam @ 2022-04-21 18:05 UTC (permalink / raw)
  To: sbabic; +Cc: peng.fan, u-boot, aford173, michael, marex, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

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.

Suggested-by: Michael Nazzareno Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
---
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(+)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index 7059d87e336b..34a07b53e57a 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -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))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB
  2022-04-21 18:05 ` [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB Fabio Estevam
@ 2022-04-25 19:41   ` Tim Harvey
  2022-04-25 22:47     ` Fabio Estevam
  2022-05-20 13:44   ` sbabic
  1 sibling, 1 reply; 9+ messages in thread
From: Tim Harvey @ 2022-04-25 19:41 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Stefano Babic, Peng Fan, u-boot, Adam Ford,
	Michael Nazzareno Trimarchi, Marek Vasut, Fabio Estevam

On Thu, Apr 21, 2022 at 11:06 AM Fabio Estevam <festevam@gmail.com> wrote:
>
> From: Fabio Estevam <festevam@denx.de>
>
> 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.
>
> Suggested-by: Michael Nazzareno Trimarchi <michael@amarulasolutions.com>
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> ---
> 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(+)
>
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> index 7059d87e336b..34a07b53e57a 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -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))
> --
> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB
  2022-04-25 19:41   ` Tim Harvey
@ 2022-04-25 22:47     ` Fabio Estevam
  2022-04-25 23:15       ` Tim Harvey
  0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2022-04-25 22:47 UTC (permalink / raw)
  To: Tim Harvey
  Cc: Fabio Estevam, Stefano Babic, Peng Fan, u-boot, Adam Ford,
	Michael Nazzareno Trimarchi, Marek Vasut

Hi Tim,

On 25/04/2022 16:41, Tim Harvey wrote:

> 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?

> 
> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB
  2022-04-25 22:47     ` Fabio Estevam
@ 2022-04-25 23:15       ` Tim Harvey
  2022-04-26  1:57         ` Fabio Estevam
  0 siblings, 1 reply; 9+ messages in thread
From: Tim Harvey @ 2022-04-25 23:15 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Fabio Estevam, Stefano Babic, Peng Fan, u-boot, Adam Ford,
	Michael Nazzareno Trimarchi, Marek Vasut

On Mon, Apr 25, 2022 at 3:47 PM Fabio Estevam <festevam@denx.de> wrote:
>
> Hi Tim,
>
> On 25/04/2022 16:41, Tim Harvey wrote:
>
> > 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,

Tested-By: Tim Harvey <tharvey@gateworks.com>

>
> >
> > 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.

>
> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB
  2022-04-25 23:15       ` Tim Harvey
@ 2022-04-26  1:57         ` Fabio Estevam
  2022-04-26  5:40           ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2022-04-26  1:57 UTC (permalink / raw)
  To: Tim Harvey
  Cc: Fabio Estevam, Stefano Babic, Peng Fan, u-boot, Adam Ford,
	Michael Nazzareno Trimarchi, Marek Vasut

Hi Tim,

On Mon, Apr 25, 2022 at 8:15 PM Tim Harvey <tharvey@gateworks.com> wrote:

> Tested-By: Tim Harvey <tharvey@gateworks.com>

Thanks.

> 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.
>
> >
> > 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.

> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB
  2022-04-26  1:57         ` Fabio Estevam
@ 2022-04-26  5:40           ` Michael Nazzareno Trimarchi
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Nazzareno Trimarchi @ 2022-04-26  5:40 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Tim Harvey, Fabio Estevam, Stefano Babic, Peng Fan, u-boot,
	Adam Ford, Marek Vasut

Hi Fabio

On Tue, Apr 26, 2022 at 3:57 AM Fabio Estevam <festevam@gmail.com> wrote:
>
> Hi Tim,
>
> On Mon, Apr 25, 2022 at 8:15 PM Tim Harvey <tharvey@gateworks.com> wrote:
>
> > Tested-By: Tim Harvey <tharvey@gateworks.com>
>
> Thanks.
>
> > 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.
> >
> > >
> > > 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.
>
> > 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.

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

Michael

-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/2] imx8mn_ddr4_evk: Add USB Mass Storage support
  2022-04-21 18:05 [PATCH v3 1/2] imx8mn_ddr4_evk: Add USB Mass Storage support Fabio Estevam
  2022-04-21 18:05 ` [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB Fabio Estevam
@ 2022-05-20 13:41 ` sbabic
  1 sibling, 0 replies; 9+ messages in thread
From: sbabic @ 2022-05-20 13:41 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> From: Fabio Estevam <festevam@denx.de>
> Add USB Mass Storage support, which is a convenient way to flash
> the eMMC card, for example.
> Signed-off-by: Fabio Estevam <festevam@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
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: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB
  2022-04-21 18:05 ` [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB Fabio Estevam
  2022-04-25 19:41   ` Tim Harvey
@ 2022-05-20 13:44   ` sbabic
  1 sibling, 0 replies; 9+ messages in thread
From: sbabic @ 2022-05-20 13:44 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> From: Fabio Estevam <festevam@denx.de>
> 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.
> Suggested-by: Michael Nazzareno Trimarchi <michael@amarulasolutions.com>
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> Tested-By: Tim Harvey <tharvey@gateworks.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
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: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-20 13:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-21 18:05 [PATCH v3 1/2] imx8mn_ddr4_evk: Add USB Mass Storage support Fabio Estevam
2022-04-21 18:05 ` [PATCH v3 2/2] imx8mn/8mp: Allow booting via USB Fabio Estevam
2022-04-25 19:41   ` Tim Harvey
2022-04-25 22:47     ` Fabio Estevam
2022-04-25 23:15       ` Tim Harvey
2022-04-26  1:57         ` Fabio Estevam
2022-04-26  5:40           ` Michael Nazzareno Trimarchi
2022-05-20 13:44   ` sbabic
2022-05-20 13:41 ` [PATCH v3 1/2] imx8mn_ddr4_evk: Add USB Mass Storage support sbabic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox