[PATCH v2] arm: imx: imx8m: soc: Add support for 'boot_device' and 'boot_instance' environment variablesAdd setup_boot_mode for imx8m

Ye Li ye.li at oss.nxp.com
Mon Dec 15 15:14:51 CET 2025



On 12/6/2025 5:16 AM, Fabio Estevam wrote:
> Hi William,
> 
> The Subject line ended up super long.
> 
> On Wed, Dec 3, 2025 at 7:02 AM William MARTIN <william.martin at muxen.fr> wrote:
>>
>> 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.
> 
> 
> Peng/Ye Li,
> 
> Could you please help review this patch?
> 
> Thanks
> 
>>
>> Signed-off-by: William MARTIN <william.martin at muxen.fr>
>> ---
>>   arch/arm/mach-imx/imx8m/soc.c | 67 +++++++++++++++++++++++++++++++++++
>>   1 file changed, 67 insertions(+)
>>
>> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
>> index 1fe083ae94f..f39f2e90e55 100644
>> --- a/arch/arm/mach-imx/imx8m/soc.c
>> +++ b/arch/arm/mach-imx/imx8m/soc.c
>> @@ -1472,6 +1472,71 @@ 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;
>> +
There are two instances.

>> +       case QSPI_BOOT:
>> +               env_set("boot_device", "spi-nand");
>> +               env_set("boot_instance", "0");
>> +               break;
>> +
iMX8M does not support SPI NAND boot.  QSPI_BOOT is for QSPI (8MM/MQ) or 
FlexSPI (8MP/MN) NOR flash boot.

>> +       case SPI_NOR_BOOT:
>> +               env_set("boot_device", "nor");
>> +               env_set("boot_instance", "0");
>> +               break;
>> +
The SPI_NOR_BOOT is for recovery boot using SPI controller from nor 
flash. This controller is different with above QSPI and FlexSPI.
Is there any naming rule for the boot_device? You need to distinguish them.

>> +       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", "1");
>> +               break;
>> +
>> +       case SD2_BOOT:
>> +               env_set("boot_device", "sdcard");
>> +               env_set("boot_instance", "2");
>> +               break;
>> +
>> +       case SD3_BOOT:
>> +               env_set("boot_device", "sdcard");
>> +               env_set("boot_instance", "3");
>> +               break;
>> +
>> +       case MMC1_BOOT:
>> +               env_set("boot_device", "mmc");
>> +               env_set("boot_instance", "1");
>> +               break;
>> +
>> +       case MMC2_BOOT:
>> +               env_set("boot_device", "mmc");
>> +               env_set("boot_instance", "2");
>> +               break;
>> +
>> +       case MMC3_BOOT:
>> +               env_set("boot_device", "mmc");
>> +               env_set("boot_instance", "3");
>> +               break;
>> +
For SD and eMMC, shouldn't the instance index start from 0 not 1?

Best regards,
Ye Li>> +       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 +1548,8 @@ int arch_misc_init(void)
>>                          printf("Failed to initialize caam_jr: %d\n", ret);
>>          }
>>
>> +       setup_boot_mode();
>> +
>>          return 0;
>>   }
>>   #endif
>> --
>> 2.47.3
>>




More information about the U-Boot mailing list