public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v3] arm: imx8m: add boot_device and boot_instance env variables
@ 2026-02-11 10:31 William MARTIN
  2026-02-11 11:49 ` Peng Fan
  0 siblings, 1 reply; 4+ messages in thread
From: William MARTIN @ 2026-02-11 10:31 UTC (permalink / raw)
  To: herve codina, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
	Tom Rini, Ye Li
  Cc: u-boot, William MARTIN

Some SoCs have supports for 'boot_device' and 'boot_instance' environment
variable. Those variables help to choose the right boot media during the
execution of the boot command.

The i.MX8M SoC doesn't have support for those variables but provides
internally all the needed information to create those variables.

Fill this lack adding support for those variables in the i.MX8M SoC. 

Signed-off-by: William MARTIN <william.martin@muxen.fr>
---
 arch/arm/mach-imx/imx8m/soc.c | 72 +++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index 1fe083ae94f..498b565183b 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -1472,6 +1472,76 @@ void reset_cpu(void)
 #endif
 
 #if IS_ENABLED(CONFIG_ARCH_MISC_INIT)
+static void setup_boot_mode(void)
+{
+	enum boot_device dev = get_boot_device();
+
+	log_debug("setup_boot_mode = %u\n", dev);
+
+	switch (dev) {
+	case USB_BOOT:
+		env_set("boot_device", "usb");
+		env_set("boot_instance", "0");
+		break;
+
+	case USB2_BOOT:
+		env_set("boot_device", "usb");
+		env_set("boot_instance", "1");
+		break;
+
+	case QSPI_BOOT:
+		env_set("boot_device", "flexspi");
+		env_set("boot_instance", "0");
+		break;
+
+	case SPI_NOR_BOOT:
+		env_set("boot_device", "spi");
+		env_set("boot_instance", "0");
+		break;
+
+	case NAND_BOOT:
+		env_set("boot_device", "nand");
+		env_set("boot_instance", "0");
+		break;
+
+	case SD1_BOOT:
+		env_set("boot_device", "sdcard");
+		env_set("boot_instance", "0");
+		break;
+
+	case SD2_BOOT:
+		env_set("boot_device", "sdcard");
+		env_set("boot_instance", "1");
+		break;
+
+	case SD3_BOOT:
+		env_set("boot_device", "sdcard");
+		env_set("boot_instance", "2");
+		break;
+
+	case MMC1_BOOT:
+		env_set("boot_device", "mmc");
+		env_set("boot_instance", "0");
+		break;
+
+	case MMC2_BOOT:
+		env_set("boot_device", "mmc");
+		env_set("boot_instance", "1");
+		break;
+
+	case MMC3_BOOT:
+		env_set("boot_device", "mmc");
+		env_set("boot_instance", "2");
+		break;
+
+	default:
+		env_set("boot_device", "invalid");
+		env_set("boot_instance", "");
+		log_err("unexpected boot mode = %x\n", dev);
+		break;
+	}
+}
+
 int arch_misc_init(void)
 {
 	if (IS_ENABLED(CONFIG_FSL_CAAM)) {
@@ -1483,6 +1553,8 @@ int arch_misc_init(void)
 			printf("Failed to initialize caam_jr: %d\n", ret);
 	}
 
+	setup_boot_mode();
+
 	return 0;
 }
 #endif
-- 
2.47.3


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

* RE: [PATCH v3] arm: imx8m: add boot_device and boot_instance env variables
  2026-02-11 10:31 [PATCH v3] arm: imx8m: add boot_device and boot_instance env variables William MARTIN
@ 2026-02-11 11:49 ` Peng Fan
  2026-02-11 13:18   ` William MARTIN
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Fan @ 2026-02-11 11:49 UTC (permalink / raw)
  To: William MARTIN, herve codina, Stefano Babic, Fabio Estevam,
	dl-uboot-imx, Tom Rini, Ye Li (OSS)
  Cc: u-boot@lists.denx.de

Hi William,

Thanks for your patch!

> Subject: [PATCH v3] arm: imx8m: add boot_device and boot_instance
> env variables
> 
> Some SoCs have supports for 'boot_device' and 'boot_instance'
> environment variable. Those variables help to choose the right boot
> media during the execution of the boot command.
> 
> The i.MX8M SoC doesn't have support for those variables but provides
> internally all the needed information to create those variables.
> 
> Fill this lack adding support for those variables in the i.MX8M SoC.
> 
> Signed-off-by: William MARTIN <william.martin@muxen.fr>
> ---

No change log here.

>  arch/arm/mach-imx/imx8m/soc.c | 72
> +++++++++++++++++++++++++++++++++++
>  1 file changed, 72 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-
> imx/imx8m/soc.c index 1fe083ae94f..498b565183b 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -1472,6 +1472,76 @@ void reset_cpu(void)  #endif
> 
>  #if IS_ENABLED(CONFIG_ARCH_MISC_INIT)
> +static void setup_boot_mode(void)
> +{
> +       enum boot_device dev = get_boot_device();
> +
> +       log_debug("setup_boot_mode = %u\n", dev);
> +
> +       switch (dev) {
> +       case USB_BOOT:
> +               env_set("boot_device", "usb");
> +               env_set("boot_instance", "0");
> +               break;
> +
> +       case USB2_BOOT:
> +               env_set("boot_device", "usb");
> +               env_set("boot_instance", "1");
> +               break;
> +
> +       case QSPI_BOOT:
> +               env_set("boot_device", "flexspi");

i.MX8MQ does not have flexspi. It is qspi.
i.MX8MM/N/P has flexspi.

Regards
Peng.

> +               env_set("boot_instance", "0");
> +               break;
> +
> +       case SPI_NOR_BOOT:
> +               env_set("boot_device", "spi");
> +               env_set("boot_instance", "0");
> +               break;
> +
> +       case NAND_BOOT:
> +               env_set("boot_device", "nand");
> +               env_set("boot_instance", "0");
> +               break;
> +
> +       case SD1_BOOT:
> +               env_set("boot_device", "sdcard");
> +               env_set("boot_instance", "0");
> +               break;
> +
> +       case SD2_BOOT:
> +               env_set("boot_device", "sdcard");
> +               env_set("boot_instance", "1");
> +               break;
> +
> +       case SD3_BOOT:
> +               env_set("boot_device", "sdcard");
> +               env_set("boot_instance", "2");
> +               break;
> +
> +       case MMC1_BOOT:
> +               env_set("boot_device", "mmc");
> +               env_set("boot_instance", "0");
> +               break;
> +
> +       case MMC2_BOOT:
> +               env_set("boot_device", "mmc");
> +               env_set("boot_instance", "1");
> +               break;
> +
> +       case MMC3_BOOT:
> +               env_set("boot_device", "mmc");
> +               env_set("boot_instance", "2");
> +               break;
> +
> +       default:
> +               env_set("boot_device", "invalid");
> +               env_set("boot_instance", "");
> +               log_err("unexpected boot mode = %x\n", dev);
> +               break;
> +       }
> +}
> +
>  int arch_misc_init(void)
>  {
>         if (IS_ENABLED(CONFIG_FSL_CAAM)) { @@ -1483,6 +1553,8 @@
> int arch_misc_init(void)
>                         printf("Failed to initialize caam_jr: %d\n", ret);
>         }
> 
> +       setup_boot_mode();
> +
>         return 0;
>  }
>  #endif
> --
> 2.47.3


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

* Re: [PATCH v3] arm: imx8m: add boot_device and boot_instance env variables
  2026-02-11 11:49 ` Peng Fan
@ 2026-02-11 13:18   ` William MARTIN
  2026-02-12  3:42     ` Peng Fan
  0 siblings, 1 reply; 4+ messages in thread
From: William MARTIN @ 2026-02-11 13:18 UTC (permalink / raw)
  To: Peng Fan
  Cc: u-boot@lists.denx.de, herve codina, Fabio Estevam, Stefano Babic,
	Ye Li (OSS), Tom Rini, dl-uboot-imx


Le 11/02/2026 à 12:49, Peng Fan a écrit :
> Hi William,
>
> Thanks for your patch!
>
>> Subject: [PATCH v3] arm: imx8m: add boot_device and boot_instance
>> env variables
>>
>> Some SoCs have supports for 'boot_device' and 'boot_instance'
>> environment variable. Those variables help to choose the right boot
>> media during the execution of the boot command.
>>
>> The i.MX8M SoC doesn't have support for those variables but provides
>> internally all the needed information to create those variables.
>>
>> Fill this lack adding support for those variables in the i.MX8M SoC.
>>
>> Signed-off-by: William MARTIN <william.martin@muxen.fr>
>> ---
> No change log here.
I will add in next patch
>
>>   arch/arm/mach-imx/imx8m/soc.c | 72
>> +++++++++++++++++++++++++++++++++++
>>   1 file changed, 72 insertions(+)
>>
>> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-
>> imx/imx8m/soc.c index 1fe083ae94f..498b565183b 100644
>> --- a/arch/arm/mach-imx/imx8m/soc.c
>> +++ b/arch/arm/mach-imx/imx8m/soc.c
>> @@ -1472,6 +1472,76 @@ void reset_cpu(void)  #endif
>>
>>   #if IS_ENABLED(CONFIG_ARCH_MISC_INIT)
>> +static void setup_boot_mode(void)
>> +{
>> +       enum boot_device dev = get_boot_device();
>> +
>> +       log_debug("setup_boot_mode = %u\n", dev);
>> +
>> +       switch (dev) {
>> +       case USB_BOOT:
>> +               env_set("boot_device", "usb");
>> +               env_set("boot_instance", "0");
>> +               break;
>> +
>> +       case USB2_BOOT:
>> +               env_set("boot_device", "usb");
>> +               env_set("boot_instance", "1");
>> +               break;
>> +
>> +       case QSPI_BOOT:
>> +               env_set("boot_device", "flexspi");
> i.MX8MQ does not have flexspi. It is qspi.
> i.MX8MM/N/P has flexspi.
>
> Regards
> Peng.

Thanks for your feedback.

Does the use of IS_ENABLED(CONFIG_IMX8MQ) to change boot_device from 
flexspi to qspi is enought ?

Regards,
William

>
>> +               env_set("boot_instance", "0");
>> +               break;
>> +
>> +       case SPI_NOR_BOOT:
>> +               env_set("boot_device", "spi");
>> +               env_set("boot_instance", "0");
>> +               break;
>> +
>> +       case NAND_BOOT:
>> +               env_set("boot_device", "nand");
>> +               env_set("boot_instance", "0");
>> +               break;
>> +
>> +       case SD1_BOOT:
>> +               env_set("boot_device", "sdcard");
>> +               env_set("boot_instance", "0");
>> +               break;
>> +
>> +       case SD2_BOOT:
>> +               env_set("boot_device", "sdcard");
>> +               env_set("boot_instance", "1");
>> +               break;
>> +
>> +       case SD3_BOOT:
>> +               env_set("boot_device", "sdcard");
>> +               env_set("boot_instance", "2");
>> +               break;
>> +
>> +       case MMC1_BOOT:
>> +               env_set("boot_device", "mmc");
>> +               env_set("boot_instance", "0");
>> +               break;
>> +
>> +       case MMC2_BOOT:
>> +               env_set("boot_device", "mmc");
>> +               env_set("boot_instance", "1");
>> +               break;
>> +
>> +       case MMC3_BOOT:
>> +               env_set("boot_device", "mmc");
>> +               env_set("boot_instance", "2");
>> +               break;
>> +
>> +       default:
>> +               env_set("boot_device", "invalid");
>> +               env_set("boot_instance", "");
>> +               log_err("unexpected boot mode = %x\n", dev);
>> +               break;
>> +       }
>> +}
>> +
>>   int arch_misc_init(void)
>>   {
>>          if (IS_ENABLED(CONFIG_FSL_CAAM)) { @@ -1483,6 +1553,8 @@
>> int arch_misc_init(void)
>>                          printf("Failed to initialize caam_jr: %d\n", ret);
>>          }
>>
>> +       setup_boot_mode();
>> +
>>          return 0;
>>   }
>>   #endif
>> --
>> 2.47.3

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

* Re: [PATCH v3] arm: imx8m: add boot_device and boot_instance env variables
  2026-02-11 13:18   ` William MARTIN
@ 2026-02-12  3:42     ` Peng Fan
  0 siblings, 0 replies; 4+ messages in thread
From: Peng Fan @ 2026-02-12  3:42 UTC (permalink / raw)
  To: William MARTIN
  Cc: Peng Fan, u-boot@lists.denx.de, herve codina, Fabio Estevam,
	Stefano Babic, Ye Li (OSS), Tom Rini, dl-uboot-imx

On Wed, Feb 11, 2026 at 02:18:28PM +0100, William MARTIN wrote:
>
>Le 11/02/2026 à 12:49, Peng Fan a écrit :
>> Hi William,
>> 
>> Thanks for your patch!
>> 
>> > Subject: [PATCH v3] arm: imx8m: add boot_device and boot_instance
>> > env variables
>> > 
>> > Some SoCs have supports for 'boot_device' and 'boot_instance'
>> > environment variable. Those variables help to choose the right boot
>> > media during the execution of the boot command.
>> > 
>> > The i.MX8M SoC doesn't have support for those variables but provides
>> > internally all the needed information to create those variables.
>> > 
>> > Fill this lack adding support for those variables in the i.MX8M SoC.
>> > 
>> > Signed-off-by: William MARTIN <william.martin@muxen.fr>
>> > ---
>> No change log here.
>I will add in next patch
>> 
>> >   arch/arm/mach-imx/imx8m/soc.c | 72
>> > +++++++++++++++++++++++++++++++++++
>> >   1 file changed, 72 insertions(+)
>> > 
>> > diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-
>> > imx/imx8m/soc.c index 1fe083ae94f..498b565183b 100644
>> > --- a/arch/arm/mach-imx/imx8m/soc.c
>> > +++ b/arch/arm/mach-imx/imx8m/soc.c
>> > @@ -1472,6 +1472,76 @@ void reset_cpu(void)  #endif
>> > 
>> >   #if IS_ENABLED(CONFIG_ARCH_MISC_INIT)
>> > +static void setup_boot_mode(void)
>> > +{
>> > +       enum boot_device dev = get_boot_device();
>> > +
>> > +       log_debug("setup_boot_mode = %u\n", dev);
>> > +
>> > +       switch (dev) {
>> > +       case USB_BOOT:
>> > +               env_set("boot_device", "usb");
>> > +               env_set("boot_instance", "0");
>> > +               break;
>> > +
>> > +       case USB2_BOOT:
>> > +               env_set("boot_device", "usb");
>> > +               env_set("boot_instance", "1");
>> > +               break;
>> > +
>> > +       case QSPI_BOOT:
>> > +               env_set("boot_device", "flexspi");
>> i.MX8MQ does not have flexspi. It is qspi.
>> i.MX8MM/N/P has flexspi.
>> 
>> Regards
>> Peng.
>
>Thanks for your feedback.
>
>Does the use of IS_ENABLED(CONFIG_IMX8MQ) to change boot_device from flexspi
>to qspi is enought ?
>

if (IS_ENABLED(CONFIG_IMX8MQ))
	env_set("boot_device", "qspi");
else
	env_set("boot_device", "flexspi");

Regards
Peng

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

end of thread, other threads:[~2026-02-12  3:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11 10:31 [PATCH v3] arm: imx8m: add boot_device and boot_instance env variables William MARTIN
2026-02-11 11:49 ` Peng Fan
2026-02-11 13:18   ` William MARTIN
2026-02-12  3:42     ` Peng Fan

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