ARM: imx: Support detection of ECSPI recovery mode on i.MX6
Subsystems (3)
PATCH 1/3 ARM: imx: Support detection of ECSPI recovery mode on i.MX6
From: Frieder Schrempf <[email protected]>
The i.MX6 allows to boot from a SPI NOR as a fallback if the primary boot fails. Parse the ROM log in order to detect this and return the proper boot device in spl_boot_device(). Otherwise the primary boot device is returned even if it was not used.
To make imx6_is_ecspi_recovery_boot() usable in U-Boot proper, add them in arch/arm/mach-imx/init.c.
This was tested on i.MX6S and the implementation covers other i.MX6 variants based on the documentation from NXP (AN12853).
--- arch/arm/include/asm/mach-imx/sys_proto.h | 1 + arch/arm/mach-imx/init.c | 75 +++++++++++++++++++++++ arch/arm/mach-imx/spl.c | 7 +++ 3 files changed, 83 insertions(+)
arch/arm/include/asm/mach-imx/sys_proto.h +1 -0
@@ -159,6 +159,7 @@ enum imx6_bmode { };u32 imx6_src_get_boot_mode (void ); +bool imx6_is_ecspi_recovery_boot (void );void gpr_init (void );#endif /* CONFIG_MX6 */
arch/arm/mach-imx/init.c +75 -0
79 lines not on this page · raw message
arch/arm/mach-imx/spl.c +7 -0
@@ -93,6 +93,13 @@ u32 spl_boot_device(void)if (is_usbotg_phy_active ())return BOOT_DEVICE_BOARD ; +/* +* Likewise the boot ROM may have done a recovery boot from a serial +* ROM on ECSPI after the primary boot device failed. +*/ +if (imx6_is_ecspi_recovery_boot ()) +return BOOT_DEVICE_SPI ; +/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */ switch ((reg &IMX6_BMODE_MASK ) >>IMX6_BMODE_SHIFT ) {/* EIM: See 8.5.1, Table 8-9 */
Signature · 1 line
2.55.0
PATCH 2/3 board: imx6dl-sielaff: Remove board_boot_order() workaround
From: Frieder Schrempf <[email protected]>
Now that the fallback to SPI NOR as boot device can be properly detected, remove the workaround.
--- board/sielaff/imx6dl-sielaff/spl.c | 22 ---------------------- 1 file changed, 22 deletions(-)
board/sielaff/imx6dl-sielaff/spl.c +0 -22
@@ -249,25 +249,3 @@ void board_init_f(ulong dummy)/* load/boot image from boot device */ board_init_r (NULL ,0 ); } - -void board_boot_order (u32 *spl_boot_list) -{ -u32 bootdev =spl_boot_device (); - -/* -* The default boot fuse settings use the SD card (MMC1) as primary -* boot device, but allow SPI NOR as a fallback boot device. -* We can't detect the fallback case and spl_boot_device() will return -* BOOT_DEVICE_MMC1 despite the actual boot device being SPI NOR. -* Therefore we try to load U-Boot proper vom SPI NOR after loading -* from MMC has failed. -*/ - spl_boot_list[0 ] = bootdev; - -switch (bootdev) { -case BOOT_DEVICE_MMC1 : -case BOOT_DEVICE_MMC2 : - spl_boot_list[1 ] =BOOT_DEVICE_SPI ; -break ; - } -}
Signature · 1 line
2.55.0
PATCH 3/3 board: imx6dl-sielaff: Enable environment on SD card
In reply to Frieder SchrempfFrom: Frieder Schrempf <[email protected]>
Enable storing the environment on SD card and choose the env location according to the boot device.
--- board/sielaff/imx6dl-sielaff/imx6dl-sielaff.c | 30 +++++++++++++++++++ configs/imx6dl_sielaff_defconfig | 2 ++ 2 files changed, 32 insertions(+)
board/sielaff/imx6dl-sielaff/imx6dl-sielaff.c +30 -0
@@ -9,6 +9,7 @@#include <asm/arch/crm_regs.h> #include <asm/arch/mx6-pins.h> #include <asm/io.h> +#include <env_internal.h> #include <init.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -109,3 +110,32 @@ int board_init(void)return 0 ; } + +/* +* Keep the environment on the device we were booted from. The boot fuses +* use the SD card as primary boot device and the SPI NOR as the ECSPI +* recovery device, so both are valid places for the environment to live. +*/ +enum env_location env_get_location (enum env_operation op,int prio) +{ +u32 bmode; + +if (prio >0 ) +return ENVL_UNKNOWN ; + +if (imx6_is_ecspi_recovery_boot ()) +return ENVL_SPI_FLASH ; + + bmode = (imx6_src_get_boot_mode () &IMX6_BMODE_MASK ) >> +IMX6_BMODE_SHIFT ; + +switch (bmode) { +case IMX6_BMODE_SD : +case IMX6_BMODE_ESD : +case IMX6_BMODE_MMC : +case IMX6_BMODE_EMMC : +return ENVL_MMC ; +default : +return ENVL_SPI_FLASH ; + } +}
configs/imx6dl_sielaff_defconfig +2 -0
@@ -61,8 +61,10 @@ CONFIG_EFI_PARTITION=y # CONFIG_SPL_EFI_PARTITION is not set CONFIG_OF_CONTROL=y CONFIG_OF_UPSTREAM=y +CONFIG_ENV_IS_IN_MMC=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_ENV_RELOC_GD_ENV_ADDR=y +CONFIG_ENV_MMC_DEVICE_INDEX=2 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y CONFIG_BOUNCE_BUFFER=y CONFIG_USB_FUNCTION_FASTBOOT=y
Signature · 1 line
2.55.0