[PATCH] imx9: Improve boot device auto-selection

Szőke Benjamin egyszeregy at freemail.hu
Mon Oct 14 11:25:43 CEST 2024


2024. 10. 14. 2:39 keltezéssel, Peng Fan írta:
>> Subject: [PATCH] imx9: Improve boot device auto-selection
>>
>> From: Benjamin Szőke <egyszeregy at freemail.hu>
>>
>> Improve "mmcautodetect=yes" boot device auto-selection to able to
>> use it if CONFIG_ENV_IS_NOWHERE is enabled for i.MX9 SoC and
>> i.MX93 EVK board.
> 
> Would you please give more background on this, I not got
> the point on why doing this?
> 
> Thanks,
> Peng.
> 

If CONFIG_ENV_IS_NOWHERE is used in u-boot config instead of 
CONFIG_ENV_IS_IN_MMC, boot auto-selection does not work because of the incorrect 
#ifdef usage in /arch/arm/mach-imx/imx9/soc.c.

If CONFIG_ENV_IS_IN_MMC is not used, also need to define CONFIG_SYS_MMC_ENV_DEV 
to any default zero value manually, because the code of mmc_get_env_dev() of 
imx9 soc like to use it, if auto detection of boot is failed or it is not in SD 
or MMC boot mode.

Same things were solved in pico-imx7d source also.
https://github.com/u-boot/u-boot/blob/master/board/technexion/pico-imx7d/pico-imx7d.c#L159

>>
>> Signed-off-by: Benjamin Szőke <egyszeregy at freemail.hu>
>> ---
>>   arch/arm/mach-imx/imx9/soc.c          | 6 +++++-
>>   board/freescale/imx93_evk/imx93_evk.c | 2 +-
>>   include/configs/imx93_evk.h           | 6 ++++++
>>   3 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-
>> imx/imx9/soc.c index 7c28fa39e1..79ddbc7241 100644
>> --- a/arch/arm/mach-imx/imx9/soc.c
>> +++ b/arch/arm/mach-imx/imx9/soc.c
>> @@ -42,12 +42,16 @@ DECLARE_GLOBAL_DATA_PTR;
>>
>>   struct rom_api *g_rom_api = (struct rom_api *)0x1980;
>>
>> -#ifdef CONFIG_ENV_IS_IN_MMC
>> +#if CONFIG_IS_ENABLED(ENV_IS_IN_MMC) ||
>> +CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
>>   __weak int board_mmc_get_env_dev(int devno)  {
>>   	return devno;
>>   }
>>
>> +#ifndef CONFIG_SYS_MMC_ENV_DEV
>> +#define CONFIG_SYS_MMC_ENV_DEV 0
>> +#endif
>> +
>>   int mmc_get_env_dev(void)
>>   {
>>   	int ret;
>> diff --git a/board/freescale/imx93_evk/imx93_evk.c
>> b/board/freescale/imx93_evk/imx93_evk.c
>> index 341831a7d3..c9171df330 100644
>> --- a/board/freescale/imx93_evk/imx93_evk.c
>> +++ b/board/freescale/imx93_evk/imx93_evk.c
>> @@ -58,7 +58,7 @@ int board_init(void)
>>
>>   int board_late_init(void)
>>   {
>> -#ifdef CONFIG_ENV_IS_IN_MMC
>> +#if CONFIG_IS_ENABLED(ENV_IS_IN_MMC) ||
>> +CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
>>   	board_late_mmc_env_init();
>>   #endif
>>
>> diff --git a/include/configs/imx93_evk.h b/include/configs/imx93_evk.h
>> index 53fb8c9b1b..2a9595a261 100644
>> --- a/include/configs/imx93_evk.h
>> +++ b/include/configs/imx93_evk.h
>> @@ -27,6 +27,12 @@
>>   #define BOOTENV
>>   #endif
>>
>> +#if CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
>> +#ifndef CONFIG_SYS_MMC_ENV_DEV
>> +#define CONFIG_SYS_MMC_ENV_DEV 0
>> +#endif
>> +#endif
>> +
>>   /* Initial environment variables */
>>   #define CFG_EXTRA_ENV_SETTINGS		\
>>   	BOOTENV \
>> --
>> 2.47.0.windows.1
> 



More information about the U-Boot mailing list