All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm: imx: imx9: scmi: Fix booting from USB
@ 2025-07-22 14:04 João Paulo Gonçalves
  2025-07-24  3:38 ` Peng Fan
  0 siblings, 1 reply; 13+ messages in thread
From: João Paulo Gonçalves @ 2025-07-22 14:04 UTC (permalink / raw)
  To: Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team, Tom Rini
  Cc: u-boot, Alice Guo, Ye Li, Peng Fan,
	João Paulo Gonçalves

From: João Paulo Gonçalves <joao.goncalves@toradex.com>

On i.MX95, when booting from USB, the U-Boot environment is always
assumed to be in RAM. However, this causes the boot to hang when
`CONFIG_ENV_IS_NOWHERE` is not enabled. The boot also hangs even if the
environment is present in another storage media (for example, eMMC). Fix
the issue by correctly handling the U-Boot environment's location when
booting from USB. Also, set the environment location based on the ENV
config and not solely based on the boot device type.

---
Hello all,

The change was not tested on mainline, but with downstream
`toradex_imx_lf_v2024.04` U-Boot branch. In the past, i.MX8M had the
same problem and the solution was similar.

Best Regards,
João Paulo Gonçalves
---
 arch/arm/mach-imx/imx9/scmi/soc.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
index 13f13ca7d1056ac5a9f1b529b13e0d8dbe2462f1..2c052c38521793e1f6ab2dc5125afa3b5ca63d0f 100644
--- a/arch/arm/mach-imx/imx9/scmi/soc.c
+++ b/arch/arm/mach-imx/imx9/scmi/soc.c
@@ -633,9 +633,13 @@ enum env_location env_get_location(enum env_operation op, int prio)
 	if (prio)
 		return env_loc;
 
+	if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
+		env_loc = ENVL_NOWHERE;
+
 	switch (dev) {
 	case QSPI_BOOT:
-		env_loc = ENVL_SPI_FLASH;
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
+			env_loc = ENVL_SPI_FLASH;
 		break;
 	case SD1_BOOT:
 	case SD2_BOOT:
@@ -643,10 +647,14 @@ enum env_location env_get_location(enum env_operation op, int prio)
 	case MMC1_BOOT:
 	case MMC2_BOOT:
 	case MMC3_BOOT:
-		env_loc =  ENVL_MMC;
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
+			env_loc =  ENVL_MMC;
 		break;
 	default:
-		env_loc = ENVL_NOWHERE;
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
+			env_loc = ENVL_SPI_FLASH;
+		else if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
+			env_loc = ENVL_MMC;
 		break;
 	}
 

---
base-commit: bd0ade7d090a334b3986936d63a34001d99722ad
change-id: 20250722-v1-fix-imx95-usb-boot-9e6d760be10e

Best regards,
-- 
João Paulo Gonçalves <joao.goncalves@toradex.com>


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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-07-22 14:04 [PATCH] arm: imx: imx9: scmi: Fix booting from USB João Paulo Gonçalves
@ 2025-07-24  3:38 ` Peng Fan
  2025-07-24 11:28   ` João Paulo Gonçalves
  0 siblings, 1 reply; 13+ messages in thread
From: Peng Fan @ 2025-07-24  3:38 UTC (permalink / raw)
  To: João Paulo Gonçalves
  Cc: Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team, Tom Rini,
	u-boot, Alice Guo, Ye Li, Peng Fan,
	João Paulo Gonçalves

On Tue, Jul 22, 2025 at 11:04:45AM -0300, João Paulo Gonçalves wrote:
>From: João Paulo Gonçalves <joao.goncalves@toradex.com>
>
>On i.MX95, when booting from USB, the U-Boot environment is always
>assumed to be in RAM. However, this causes the boot to hang when
>`CONFIG_ENV_IS_NOWHERE` is not enabled. The boot also hangs even if the
>environment is present in another storage media (for example, eMMC). Fix
>the issue by correctly handling the U-Boot environment's location when
>booting from USB. Also, set the environment location based on the ENV
>config and not solely based on the boot device type.
>
>---
>Hello all,
>
>The change was not tested on mainline, but with downstream
>`toradex_imx_lf_v2024.04` U-Boot branch. In the past, i.MX8M had the
>same problem and the solution was similar.
>
>Best Regards,
>João Paulo Gonçalves
>---
> arch/arm/mach-imx/imx9/scmi/soc.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
>diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
>index 13f13ca7d1056ac5a9f1b529b13e0d8dbe2462f1..2c052c38521793e1f6ab2dc5125afa3b5ca63d0f 100644
>--- a/arch/arm/mach-imx/imx9/scmi/soc.c
>+++ b/arch/arm/mach-imx/imx9/scmi/soc.c
>@@ -633,9 +633,13 @@ enum env_location env_get_location(enum env_operation op, int prio)
> 	if (prio)
> 		return env_loc;
> 
>+	if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
>+		env_loc = ENVL_NOWHERE;
>+
> 	switch (dev) {
> 	case QSPI_BOOT:
>-		env_loc = ENVL_SPI_FLASH;
>+		if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
>+			env_loc = ENVL_SPI_FLASH;
> 		break;
> 	case SD1_BOOT:
> 	case SD2_BOOT:
>@@ -643,10 +647,14 @@ enum env_location env_get_location(enum env_operation op, int prio)
> 	case MMC1_BOOT:
> 	case MMC2_BOOT:
> 	case MMC3_BOOT:
>-		env_loc =  ENVL_MMC;
>+		if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
>+			env_loc =  ENVL_MMC;
> 		break;
> 	default:
>-		env_loc = ENVL_NOWHERE;
>+		if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
>+			env_loc = ENVL_SPI_FLASH;
>+		else if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
>+			env_loc = ENVL_MMC;

If boot from USB, this means env_loc will be override here.

NXP boards always use RAM env when booting from USB.
If your boards has different settings, I think we may need to
introduce board_env_get_location. Or add some device tree
properties to specify the env settings.

Thanks,
Peng

> 		break;
> 	}
> 
>
>---
>base-commit: bd0ade7d090a334b3986936d63a34001d99722ad
>change-id: 20250722-v1-fix-imx95-usb-boot-9e6d760be10e
>
>Best regards,
>-- 
>João Paulo Gonçalves <joao.goncalves@toradex.com>
>

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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-07-24  3:38 ` Peng Fan
@ 2025-07-24 11:28   ` João Paulo Gonçalves
  2025-07-28 10:29     ` Francesco Dolcini
  0 siblings, 1 reply; 13+ messages in thread
From: João Paulo Gonçalves @ 2025-07-24 11:28 UTC (permalink / raw)
  To: Peng Fan
  Cc: Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team, Tom Rini,
	u-boot, Alice Guo, Ye Li, Peng Fan,
	João Paulo Gonçalves

Hi Peng,

> If boot from USB, this means env_loc will be override here.
> 
> NXP boards always use RAM env when booting from USB.
In that case, this seems like an ARCH configuration and the ARCH should
imply the necessary kconfig. Currently, every i.MX9 board needs to
enable CONFIG_ENV_IS_NOWHERE or the boot hangs when booting from USB.

> If your boards has different settings, I think we may need to
> introduce board_env_get_location. Or add some device tree
> properties to specify the env settings.
> 
> Thanks,
> Peng

Best Regards,
João Paulo Gonçalves

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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-07-24 11:28   ` João Paulo Gonçalves
@ 2025-07-28 10:29     ` Francesco Dolcini
  2025-07-28 14:25       ` Fabio Estevam
  0 siblings, 1 reply; 13+ messages in thread
From: Francesco Dolcini @ 2025-07-28 10:29 UTC (permalink / raw)
  To: João Paulo Gonçalves, Fabio Estevam
  Cc: Peng Fan, Stefano Babic, NXP i.MX U-Boot Team, Tom Rini, u-boot,
	Alice Guo, Ye Li, Peng Fan, João Paulo Gonçalves

Hello Fabio,

On Thu, Jul 24, 2025 at 08:28:22AM -0300, João Paulo Gonçalves wrote:
> > If boot from USB, this means env_loc will be override here.
> > 
> > NXP boards always use RAM env when booting from USB.
> In that case, this seems like an ARCH configuration and the ARCH should
> imply the necessary kconfig. Currently, every i.MX9 board needs to
> enable CONFIG_ENV_IS_NOWHERE or the boot hangs when booting from USB.

You worked on a similar topic, for imx8m, some time ago, commit
d175982c207b ("imx8mn/8mp: Allow booting via USB"). What's your opinion
here? How should we fix this?

Francesco



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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-07-28 10:29     ` Francesco Dolcini
@ 2025-07-28 14:25       ` Fabio Estevam
  2025-07-28 16:44         ` Francesco Dolcini
  0 siblings, 1 reply; 13+ messages in thread
From: Fabio Estevam @ 2025-07-28 14:25 UTC (permalink / raw)
  To: Francesco Dolcini, Tim Harvey
  Cc: João Paulo Gonçalves, Peng Fan, Stefano Babic,
	NXP i.MX U-Boot Team, Tom Rini, u-boot, Alice Guo, Ye Li,
	Peng Fan, João Paulo Gonçalves

Hi Francesco,

On Mon, Jul 28, 2025 at 7:29 AM Francesco Dolcini <francesco@dolcini.it> wrote:

> You worked on a similar topic, for imx8m, some time ago, commit
> d175982c207b ("imx8mn/8mp: Allow booting via USB"). What's your opinion
> here? How should we fix this?

The solution on the commit you mentioned is related to the
i.MX8MN/i.MX8MP boot ROM implementation, and it works there.

What confuses me about João's patch is that it was not tested against
the mainline U-Boot.

Can U-Boot mainline boot over serial download on i.MX95?

Adding Tim, as he has been trying to get USB boot to work with i.MX95.

I don't have access to any i.MX95 board to try it myself, so I
appreciate some help here.

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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-07-28 14:25       ` Fabio Estevam
@ 2025-07-28 16:44         ` Francesco Dolcini
  2025-07-30  6:35           ` Frieder Schrempf
  0 siblings, 1 reply; 13+ messages in thread
From: Francesco Dolcini @ 2025-07-28 16:44 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Francesco Dolcini, Tim Harvey, João Paulo Gonçalves,
	Peng Fan, Stefano Babic, NXP i.MX U-Boot Team, Tom Rini, u-boot,
	Alice Guo, Ye Li, Peng Fan, João Paulo Gonçalves

On Mon, Jul 28, 2025 at 11:25:04AM -0300, Fabio Estevam wrote:
> On Mon, Jul 28, 2025 at 7:29 AM Francesco Dolcini <francesco@dolcini.it> wrote:
> 
> > You worked on a similar topic, for imx8m, some time ago, commit
> > d175982c207b ("imx8mn/8mp: Allow booting via USB"). What's your opinion
> > here? How should we fix this?
> 
> The solution on the commit you mentioned is related to the
> i.MX8MN/i.MX8MP boot ROM implementation, and it works there.
> 
> What confuses me about João's patch is that it was not tested against
> the mainline U-Boot.
> 
> Can U-Boot mainline boot over serial download on i.MX95?
> 
> Adding Tim, as he has been trying to get USB boot to work with i.MX95.
> 
> I don't have access to any i.MX95 board to try it myself, so I
> appreciate some help here.

The issue here is not specific about USB, this is about code assuming
that the relevant env config options are enabled without checking
anything AND assuming that ENVL_NOWHERE is working as a default in any
case.

See also env_locations in env/env.c and arch_env_get_location()

Francesco


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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-07-28 16:44         ` Francesco Dolcini
@ 2025-07-30  6:35           ` Frieder Schrempf
  2025-07-31 18:47             ` João Paulo Gonçalves
  0 siblings, 1 reply; 13+ messages in thread
From: Frieder Schrempf @ 2025-07-30  6:35 UTC (permalink / raw)
  To: Francesco Dolcini, Fabio Estevam
  Cc: Tim Harvey, João Paulo Gonçalves, Peng Fan,
	Stefano Babic, NXP i.MX U-Boot Team, Tom Rini, u-boot, Alice Guo,
	Ye Li, Peng Fan, João Paulo Gonçalves

Hi,

Am 28.07.25 um 18:44 schrieb Francesco Dolcini:
> On Mon, Jul 28, 2025 at 11:25:04AM -0300, Fabio Estevam wrote:
>> On Mon, Jul 28, 2025 at 7:29 AM Francesco Dolcini <francesco@dolcini.it> wrote:
>>
>>> You worked on a similar topic, for imx8m, some time ago, commit
>>> d175982c207b ("imx8mn/8mp: Allow booting via USB"). What's your opinion
>>> here? How should we fix this?
>>
>> The solution on the commit you mentioned is related to the
>> i.MX8MN/i.MX8MP boot ROM implementation, and it works there.
>>
>> What confuses me about João's patch is that it was not tested against
>> the mainline U-Boot.
>>
>> Can U-Boot mainline boot over serial download on i.MX95?
>>
>> Adding Tim, as he has been trying to get USB boot to work with i.MX95.
>>
>> I don't have access to any i.MX95 board to try it myself, so I
>> appreciate some help here.
> 
> The issue here is not specific about USB, this is about code assuming
> that the relevant env config options are enabled without checking
> anything AND assuming that ENVL_NOWHERE is working as a default in any
> case.
> 
> See also env_locations in env/env.c and arch_env_get_location()
> 
> Francesco

I have the below patch in our downstream fork to fix the issue mentioned
here for i.MX93. It is derived from Fabio's patch [1]. I'm not sure if
it's correct, though.

[1]
https://source.denx.de/u-boot/u-boot/-/commit/d175982c207bb2ace592d7985cd3f05ab99759d9

Best regards
Frieder


From 49b028284e36eeb7516f618e31bbf569956295ad Mon Sep 17 00:00:00 2001
From: Frieder Schrempf <frieder.schrempf@kontron.de>
Date: Thu, 16 May 2024 14:27:39 +0200
Subject: [PATCH] arm: imx: imx9: Allow booting via USB

When trying to boot via USB on i.MX93 it is necessary to specify
the U-Boot environment location, otherwise the boot process simply
hangs (unless CONFIG_ENV_IS_NOWHERE is enabled).

Specify the environment location when booting from USB.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 arch/arm/mach-imx/imx9/soc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c
index 829b3b7b748..5bb0ab871ac 100644
--- a/arch/arm/mach-imx/imx9/soc.c
+++ b/arch/arm/mach-imx/imx9/soc.c
@@ -808,6 +808,14 @@ enum env_location arch_env_get_location(enum
env_operation op, int prio)
                return ENVL_UNKNOWN;

        switch (dev) {
+       case USB_BOOT:
+               if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
+                       return ENVL_SPI_FLASH;
+               if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
+                       return ENVL_MMC;
+               if (CONFIG_IS_ENABLED(ENV_IS_NOWHERE))
+                       return ENVL_NOWHERE;
+               return ENVL_UNKNOWN;
        case QSPI_BOOT:
                if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
                        return ENVL_SPI_FLASH;
-- 
2.50.1


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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-07-30  6:35           ` Frieder Schrempf
@ 2025-07-31 18:47             ` João Paulo Gonçalves
  2025-08-05 23:07               ` Fabio Estevam
  2025-08-06  6:53               ` Frieder Schrempf
  0 siblings, 2 replies; 13+ messages in thread
From: João Paulo Gonçalves @ 2025-07-31 18:47 UTC (permalink / raw)
  To: Fabio Estevam, Frieder Schrempf, Peng Fan
  Cc: Francesco Dolcini, Tim Harvey, Peng Fan, Stefano Babic,
	NXP i.MX U-Boot Team, Tom Rini, u-boot, Alice Guo, Ye Li,
	Peng Fan, João Paulo Gonçalves

Hello,

On Mon, Jul 28, 2025 at 11:25:04AM -0300, Fabio Estevam wrote:
> What confuses me about João's patch is that it was not tested against
> the mainline U-Boot.

In the end, the code is nearly identical between the downstream and
mainline U-Boot.

On Wed, Jul 30, 2025 at 08:35:40AM +0200, Frieder Schrempf wrote:
> I have the below patch in our downstream fork to fix the issue mentioned
> here for i.MX93. It is derived from Fabio's patch [1]. I'm not sure if
> it's correct, though.

We are also doing something similar on our branch.

I have two proposals. My goal is to prevent the board from hanging when
booting from USB if CONFIG_ENV_IS_NOWHERE=n (since the current code
assumes it is always enabled) and/or if the environment is defined
elsewhere:

1) Imply CONFIG_ENV_IS_NOWHERE for i.MX9 (as mentioned earlier), to make
it clear that it is required by ARCH.

or

2) Doing something similar to what Frieder showed for USB boot (which is
almost the same on i.MX8MM/i.MX8MP), but preserving the current
behavior:

diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
index 13f13ca7d105..f973652d0cbe 100644
--- a/arch/arm/mach-imx/imx9/scmi/soc.c
+++ b/arch/arm/mach-imx/imx9/scmi/soc.c
@@ -635,7 +635,8 @@ enum env_location env_get_location(enum env_operation op, int prio)

        switch (dev) {
        case QSPI_BOOT:
-               env_loc = ENVL_SPI_FLASH;
+               if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
+                       env_loc = ENVL_SPI_FLASH;
                break;
        case SD1_BOOT:
        case SD2_BOOT:
@@ -643,10 +644,16 @@ enum env_location env_get_location(enum env_operation op, int prio)
        case MMC1_BOOT:
        case MMC2_BOOT:
        case MMC3_BOOT:
-               env_loc =  ENVL_MMC;
+               if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
+                       env_loc =  ENVL_MMC;
                break;
        default:
-               env_loc = ENVL_NOWHERE;
+               if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
+                       env_loc = ENVL_NOWHERE;
+               else if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
+                       env_loc = ENVL_SPI_FLASH;
+               else if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
+                       env_loc = ENVL_MMC;
                break;
        }

With this patch, I believe Peng's concerns are addressed, and it also
works for our use case.

What do you think?

Best Regards,
João Paulo

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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-07-31 18:47             ` João Paulo Gonçalves
@ 2025-08-05 23:07               ` Fabio Estevam
  2025-08-06  6:53               ` Frieder Schrempf
  1 sibling, 0 replies; 13+ messages in thread
From: Fabio Estevam @ 2025-08-05 23:07 UTC (permalink / raw)
  To: João Paulo Gonçalves
  Cc: Frieder Schrempf, Peng Fan, Francesco Dolcini, Tim Harvey,
	Peng Fan, Stefano Babic, NXP i.MX U-Boot Team, Tom Rini, u-boot,
	Alice Guo, Ye Li, João Paulo Gonçalves

Hi João,

On Thu, Jul 31, 2025 at 3:47 PM João Paulo Gonçalves
<jpaulo.silvagoncalves@gmail.com> wrote:

> With this patch, I believe Peng's concerns are addressed, and it also
> works for our use case.
>
> What do you think?

It looks good. Please send a formal patch.

Thanks

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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-07-31 18:47             ` João Paulo Gonçalves
  2025-08-05 23:07               ` Fabio Estevam
@ 2025-08-06  6:53               ` Frieder Schrempf
  2025-08-22 17:05                 ` Tim Harvey
  1 sibling, 1 reply; 13+ messages in thread
From: Frieder Schrempf @ 2025-08-06  6:53 UTC (permalink / raw)
  To: João Paulo Gonçalves, Fabio Estevam, Peng Fan
  Cc: Francesco Dolcini, Tim Harvey, Peng Fan, Stefano Babic,
	NXP i.MX U-Boot Team, Tom Rini, u-boot, Alice Guo, Ye Li,
	João Paulo Gonçalves

Am 31.07.25 um 20:47 schrieb João Paulo Gonçalves:
> Hello,
> 
> On Mon, Jul 28, 2025 at 11:25:04AM -0300, Fabio Estevam wrote:
>> What confuses me about João's patch is that it was not tested against
>> the mainline U-Boot.
> 
> In the end, the code is nearly identical between the downstream and
> mainline U-Boot.
> 
> On Wed, Jul 30, 2025 at 08:35:40AM +0200, Frieder Schrempf wrote:
>> I have the below patch in our downstream fork to fix the issue mentioned
>> here for i.MX93. It is derived from Fabio's patch [1]. I'm not sure if
>> it's correct, though.
> 
> We are also doing something similar on our branch.
> 
> I have two proposals. My goal is to prevent the board from hanging when
> booting from USB if CONFIG_ENV_IS_NOWHERE=n (since the current code
> assumes it is always enabled) and/or if the environment is defined
> elsewhere:
> 
> 1) Imply CONFIG_ENV_IS_NOWHERE for i.MX9 (as mentioned earlier), to make
> it clear that it is required by ARCH.
> 
> or
> 
> 2) Doing something similar to what Frieder showed for USB boot (which is
> almost the same on i.MX8MM/i.MX8MP), but preserving the current
> behavior:
> 
> diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
> index 13f13ca7d105..f973652d0cbe 100644
> --- a/arch/arm/mach-imx/imx9/scmi/soc.c
> +++ b/arch/arm/mach-imx/imx9/scmi/soc.c
> @@ -635,7 +635,8 @@ enum env_location env_get_location(enum env_operation op, int prio)
> 
>         switch (dev) {
>         case QSPI_BOOT:
> -               env_loc = ENVL_SPI_FLASH;
> +               if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
> +                       env_loc = ENVL_SPI_FLASH;
>                 break;
>         case SD1_BOOT:
>         case SD2_BOOT:
> @@ -643,10 +644,16 @@ enum env_location env_get_location(enum env_operation op, int prio)
>         case MMC1_BOOT:
>         case MMC2_BOOT:
>         case MMC3_BOOT:
> -               env_loc =  ENVL_MMC;
> +               if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
> +                       env_loc =  ENVL_MMC;
>                 break;
>         default:
> -               env_loc = ENVL_NOWHERE;
> +               if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
> +                       env_loc = ENVL_NOWHERE;
> +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
> +                       env_loc = ENVL_SPI_FLASH;
> +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
> +                       env_loc = ENVL_MMC;
>                 break;
>         }
> 
> With this patch, I believe Peng's concerns are addressed, and it also
> works for our use case.
> 
> What do you think?

On first glance, this looks good to me. If possible, can you please also
send a patch for i.MX93 (arch/arm/mach-imx/imx9/soc.c) to align the
behavior of both platforms?

Thanks!


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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-08-06  6:53               ` Frieder Schrempf
@ 2025-08-22 17:05                 ` Tim Harvey
  2025-08-25  7:50                   ` Frieder Schrempf
  0 siblings, 1 reply; 13+ messages in thread
From: Tim Harvey @ 2025-08-22 17:05 UTC (permalink / raw)
  To: João Paulo Gonçalves
  Cc: Fabio Estevam, Peng Fan, Francesco Dolcini, Peng Fan,
	Stefano Babic, NXP i.MX U-Boot Team, Tom Rini, u-boot, Alice Guo,
	Ye Li, João Paulo Gonçalves, Frieder Schrempf

On Tue, Aug 5, 2025 at 11:53 PM Frieder Schrempf
<frieder.schrempf@kontron.de> wrote:
>
> Am 31.07.25 um 20:47 schrieb João Paulo Gonçalves:
> > Hello,
> >
> > On Mon, Jul 28, 2025 at 11:25:04AM -0300, Fabio Estevam wrote:
> >> What confuses me about João's patch is that it was not tested against
> >> the mainline U-Boot.
> >
> > In the end, the code is nearly identical between the downstream and
> > mainline U-Boot.
> >
> > On Wed, Jul 30, 2025 at 08:35:40AM +0200, Frieder Schrempf wrote:
> >> I have the below patch in our downstream fork to fix the issue mentioned
> >> here for i.MX93. It is derived from Fabio's patch [1]. I'm not sure if
> >> it's correct, though.
> >
> > We are also doing something similar on our branch.
> >
> > I have two proposals. My goal is to prevent the board from hanging when
> > booting from USB if CONFIG_ENV_IS_NOWHERE=n (since the current code
> > assumes it is always enabled) and/or if the environment is defined
> > elsewhere:
> >
> > 1) Imply CONFIG_ENV_IS_NOWHERE for i.MX9 (as mentioned earlier), to make
> > it clear that it is required by ARCH.
> >
> > or
> >
> > 2) Doing something similar to what Frieder showed for USB boot (which is
> > almost the same on i.MX8MM/i.MX8MP), but preserving the current
> > behavior:
> >
> > diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
> > index 13f13ca7d105..f973652d0cbe 100644
> > --- a/arch/arm/mach-imx/imx9/scmi/soc.c
> > +++ b/arch/arm/mach-imx/imx9/scmi/soc.c
> > @@ -635,7 +635,8 @@ enum env_location env_get_location(enum env_operation op, int prio)
> >
> >         switch (dev) {
> >         case QSPI_BOOT:
> > -               env_loc = ENVL_SPI_FLASH;
> > +               if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
> > +                       env_loc = ENVL_SPI_FLASH;
> >                 break;
> >         case SD1_BOOT:
> >         case SD2_BOOT:
> > @@ -643,10 +644,16 @@ enum env_location env_get_location(enum env_operation op, int prio)
> >         case MMC1_BOOT:
> >         case MMC2_BOOT:
> >         case MMC3_BOOT:
> > -               env_loc =  ENVL_MMC;
> > +               if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
> > +                       env_loc =  ENVL_MMC;
> >                 break;
> >         default:
> > -               env_loc = ENVL_NOWHERE;
> > +               if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
> > +                       env_loc = ENVL_NOWHERE;
> > +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
> > +                       env_loc = ENVL_SPI_FLASH;
> > +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
> > +                       env_loc = ENVL_MMC;
> >                 break;
> >         }
> >
> > With this patch, I believe Peng's concerns are addressed, and it also
> > works for our use case.
> >
> > What do you think?
>
> On first glance, this looks good to me. If possible, can you please also
> send a patch for i.MX93 (arch/arm/mach-imx/imx9/soc.c) to align the
> behavior of both platforms?
>
> Thanks!
>

Hi João,

This does resolve an issue I encountered as well on the imx95 while
booting via USB2 SDP.

Can you submit a formal patch?

Best Regards,

Tim

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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-08-22 17:05                 ` Tim Harvey
@ 2025-08-25  7:50                   ` Frieder Schrempf
  2025-08-25 16:27                     ` Tim Harvey
  0 siblings, 1 reply; 13+ messages in thread
From: Frieder Schrempf @ 2025-08-25  7:50 UTC (permalink / raw)
  To: Tim Harvey, João Paulo Gonçalves
  Cc: Fabio Estevam, Peng Fan, Francesco Dolcini, Peng Fan,
	Stefano Babic, NXP i.MX U-Boot Team, Tom Rini, u-boot, Alice Guo,
	Ye Li, João Paulo Gonçalves

Am 22.08.25 um 19:05 schrieb Tim Harvey:
> On Tue, Aug 5, 2025 at 11:53 PM Frieder Schrempf
> <frieder.schrempf@kontron.de> wrote:
>>
>> Am 31.07.25 um 20:47 schrieb João Paulo Gonçalves:
>>> Hello,
>>>
>>> On Mon, Jul 28, 2025 at 11:25:04AM -0300, Fabio Estevam wrote:
>>>> What confuses me about João's patch is that it was not tested against
>>>> the mainline U-Boot.
>>>
>>> In the end, the code is nearly identical between the downstream and
>>> mainline U-Boot.
>>>
>>> On Wed, Jul 30, 2025 at 08:35:40AM +0200, Frieder Schrempf wrote:
>>>> I have the below patch in our downstream fork to fix the issue mentioned
>>>> here for i.MX93. It is derived from Fabio's patch [1]. I'm not sure if
>>>> it's correct, though.
>>>
>>> We are also doing something similar on our branch.
>>>
>>> I have two proposals. My goal is to prevent the board from hanging when
>>> booting from USB if CONFIG_ENV_IS_NOWHERE=n (since the current code
>>> assumes it is always enabled) and/or if the environment is defined
>>> elsewhere:
>>>
>>> 1) Imply CONFIG_ENV_IS_NOWHERE for i.MX9 (as mentioned earlier), to make
>>> it clear that it is required by ARCH.
>>>
>>> or
>>>
>>> 2) Doing something similar to what Frieder showed for USB boot (which is
>>> almost the same on i.MX8MM/i.MX8MP), but preserving the current
>>> behavior:
>>>
>>> diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
>>> index 13f13ca7d105..f973652d0cbe 100644
>>> --- a/arch/arm/mach-imx/imx9/scmi/soc.c
>>> +++ b/arch/arm/mach-imx/imx9/scmi/soc.c
>>> @@ -635,7 +635,8 @@ enum env_location env_get_location(enum env_operation op, int prio)
>>>
>>>         switch (dev) {
>>>         case QSPI_BOOT:
>>> -               env_loc = ENVL_SPI_FLASH;
>>> +               if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
>>> +                       env_loc = ENVL_SPI_FLASH;
>>>                 break;
>>>         case SD1_BOOT:
>>>         case SD2_BOOT:
>>> @@ -643,10 +644,16 @@ enum env_location env_get_location(enum env_operation op, int prio)
>>>         case MMC1_BOOT:
>>>         case MMC2_BOOT:
>>>         case MMC3_BOOT:
>>> -               env_loc =  ENVL_MMC;
>>> +               if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
>>> +                       env_loc =  ENVL_MMC;
>>>                 break;
>>>         default:
>>> -               env_loc = ENVL_NOWHERE;
>>> +               if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
>>> +                       env_loc = ENVL_NOWHERE;
>>> +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
>>> +                       env_loc = ENVL_SPI_FLASH;
>>> +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
>>> +                       env_loc = ENVL_MMC;
>>>                 break;
>>>         }
>>>
>>> With this patch, I believe Peng's concerns are addressed, and it also
>>> works for our use case.
>>>
>>> What do you think?
>>
>> On first glance, this looks good to me. If possible, can you please also
>> send a patch for i.MX93 (arch/arm/mach-imx/imx9/soc.c) to align the
>> behavior of both platforms?
>>
>> Thanks!
>>
> 
> Hi João,
> 
> This does resolve an issue I encountered as well on the imx95 while
> booting via USB2 SDP.
> 
> Can you submit a formal patch?

I think the patch you are looking for has already been sent:
https://patchwork.ozlabs.org/project/uboot/patch/20250811-v2-fix-imx9-usb-boot-v2-1-3d89974e2881@toradex.com/


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

* Re: [PATCH] arm: imx: imx9: scmi: Fix booting from USB
  2025-08-25  7:50                   ` Frieder Schrempf
@ 2025-08-25 16:27                     ` Tim Harvey
  0 siblings, 0 replies; 13+ messages in thread
From: Tim Harvey @ 2025-08-25 16:27 UTC (permalink / raw)
  To: Frieder Schrempf
  Cc: João Paulo Gonçalves, Fabio Estevam, Peng Fan,
	Francesco Dolcini, Peng Fan, Stefano Babic, NXP i.MX U-Boot Team,
	Tom Rini, u-boot, Alice Guo, Ye Li,
	João Paulo Gonçalves

On Mon, Aug 25, 2025 at 12:50 AM Frieder Schrempf
<frieder.schrempf@kontron.de> wrote:
>
> Am 22.08.25 um 19:05 schrieb Tim Harvey:
> > On Tue, Aug 5, 2025 at 11:53 PM Frieder Schrempf
> > <frieder.schrempf@kontron.de> wrote:
> >>
> >> Am 31.07.25 um 20:47 schrieb João Paulo Gonçalves:
> >>> Hello,
> >>>
> >>> On Mon, Jul 28, 2025 at 11:25:04AM -0300, Fabio Estevam wrote:
> >>>> What confuses me about João's patch is that it was not tested against
> >>>> the mainline U-Boot.
> >>>
> >>> In the end, the code is nearly identical between the downstream and
> >>> mainline U-Boot.
> >>>
> >>> On Wed, Jul 30, 2025 at 08:35:40AM +0200, Frieder Schrempf wrote:
> >>>> I have the below patch in our downstream fork to fix the issue mentioned
> >>>> here for i.MX93. It is derived from Fabio's patch [1]. I'm not sure if
> >>>> it's correct, though.
> >>>
> >>> We are also doing something similar on our branch.
> >>>
> >>> I have two proposals. My goal is to prevent the board from hanging when
> >>> booting from USB if CONFIG_ENV_IS_NOWHERE=n (since the current code
> >>> assumes it is always enabled) and/or if the environment is defined
> >>> elsewhere:
> >>>
> >>> 1) Imply CONFIG_ENV_IS_NOWHERE for i.MX9 (as mentioned earlier), to make
> >>> it clear that it is required by ARCH.
> >>>
> >>> or
> >>>
> >>> 2) Doing something similar to what Frieder showed for USB boot (which is
> >>> almost the same on i.MX8MM/i.MX8MP), but preserving the current
> >>> behavior:
> >>>
> >>> diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
> >>> index 13f13ca7d105..f973652d0cbe 100644
> >>> --- a/arch/arm/mach-imx/imx9/scmi/soc.c
> >>> +++ b/arch/arm/mach-imx/imx9/scmi/soc.c
> >>> @@ -635,7 +635,8 @@ enum env_location env_get_location(enum env_operation op, int prio)
> >>>
> >>>         switch (dev) {
> >>>         case QSPI_BOOT:
> >>> -               env_loc = ENVL_SPI_FLASH;
> >>> +               if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
> >>> +                       env_loc = ENVL_SPI_FLASH;
> >>>                 break;
> >>>         case SD1_BOOT:
> >>>         case SD2_BOOT:
> >>> @@ -643,10 +644,16 @@ enum env_location env_get_location(enum env_operation op, int prio)
> >>>         case MMC1_BOOT:
> >>>         case MMC2_BOOT:
> >>>         case MMC3_BOOT:
> >>> -               env_loc =  ENVL_MMC;
> >>> +               if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
> >>> +                       env_loc =  ENVL_MMC;
> >>>                 break;
> >>>         default:
> >>> -               env_loc = ENVL_NOWHERE;
> >>> +               if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
> >>> +                       env_loc = ENVL_NOWHERE;
> >>> +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
> >>> +                       env_loc = ENVL_SPI_FLASH;
> >>> +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
> >>> +                       env_loc = ENVL_MMC;
> >>>                 break;
> >>>         }
> >>>
> >>> With this patch, I believe Peng's concerns are addressed, and it also
> >>> works for our use case.
> >>>
> >>> What do you think?
> >>
> >> On first glance, this looks good to me. If possible, can you please also
> >> send a patch for i.MX93 (arch/arm/mach-imx/imx9/soc.c) to align the
> >> behavior of both platforms?
> >>
> >> Thanks!
> >>
> >
> > Hi João,
> >
> > This does resolve an issue I encountered as well on the imx95 while
> > booting via USB2 SDP.
> >
> > Can you submit a formal patch?
>
> I think the patch you are looking for has already been sent:
> https://patchwork.ozlabs.org/project/uboot/patch/20250811-v2-fix-imx9-usb-boot-v2-1-3d89974e2881@toradex.com/
>

Hi Frieder,

Indeed it has - I missed that. Thanks,

Tim

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

end of thread, other threads:[~2025-08-25 16:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 14:04 [PATCH] arm: imx: imx9: scmi: Fix booting from USB João Paulo Gonçalves
2025-07-24  3:38 ` Peng Fan
2025-07-24 11:28   ` João Paulo Gonçalves
2025-07-28 10:29     ` Francesco Dolcini
2025-07-28 14:25       ` Fabio Estevam
2025-07-28 16:44         ` Francesco Dolcini
2025-07-30  6:35           ` Frieder Schrempf
2025-07-31 18:47             ` João Paulo Gonçalves
2025-08-05 23:07               ` Fabio Estevam
2025-08-06  6:53               ` Frieder Schrempf
2025-08-22 17:05                 ` Tim Harvey
2025-08-25  7:50                   ` Frieder Schrempf
2025-08-25 16:27                     ` Tim Harvey

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.