[PATCH v1 1/2] imx: imxrt1050-evk: Add support for SPI flash booting

This add some macros to change addresses to use flexspi.
This commit adds support for booting the imxrt1050-evk from spi. It adds imximage config and the ability for SPL to boot from NOR.
Signed-off-by: Jesse Taube Mr.Bossman075@gmail.com --- .../freescale/imxrt1050-evk/imximage-nor.cfg | 42 +++++++++++++++++++ board/freescale/imxrt1050-evk/imximage.cfg | 11 ++++- board/freescale/imxrt1050-evk/imxrt1050-evk.c | 8 +++- configs/imxrt1050-evk_defconfig | 6 ++- include/configs/imxrt1050-evk.h | 4 +- 5 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 board/freescale/imxrt1050-evk/imximage-nor.cfg
diff --git a/board/freescale/imxrt1050-evk/imximage-nor.cfg b/board/freescale/imxrt1050-evk/imximage-nor.cfg new file mode 100644 index 0000000000..3e1b059075 --- /dev/null +++ b/board/freescale/imxrt1050-evk/imximage-nor.cfg @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2019 + * Author(s): Giulio Benetti giulio.benetti@benettiengineering.com + */ + +#define __ASSEMBLY__ +#include <config.h> + +/* image version */ + +IMAGE_VERSION 2 + +/* + * Boot Device : one of + * spi/sd/nand/onenand, qspi/nor + */ + +BOOT_FROM nor + +/* + * Device Configuration Data (DCD) + * + * Each entry must have the format: + * Addr-type Address Value + * + * where: + * Addr-type register length (1,2 or 4 bytes) + * Address absolute address of the register + * value value to be stored in the register + */ + +/* + * 0x400AC044 is used to configure the flexram. + * Unfortunatly seting all to OCRAM only works for MMC + * and setting all to DTCM only works for FLEXSPI NOR. + * This configureation fortunaly works for both SPI and MMC. +*/ +/* Set first two banks FlexRAM as OCRAM(01b) and the rest to DTCM(10b) */ +DATA 4 0x400AC044 0x55aaaaaa +/* Use FLEXRAM_BANK_CFG to config FlexRAM */ +SET_BIT 4 0x400AC040 0x4 diff --git a/board/freescale/imxrt1050-evk/imximage.cfg b/board/freescale/imxrt1050-evk/imximage.cfg index cf1665be61..dffca91f0a 100644 --- a/board/freescale/imxrt1050-evk/imximage.cfg +++ b/board/freescale/imxrt1050-evk/imximage.cfg @@ -30,7 +30,14 @@ BOOT_FROM sd * value value to be stored in the register */
-/* Set all FlexRAM as OCRAM(01b) */ -DATA 4 0x400AC044 0x55555555 +/* + * 0x400AC044 is used to configure the flexram. + * Unfortunatly seting all to OCRAM only works for MMC + * and setting all to DTCM only works for FLEXSPI NOR. + * This configureation fortunaly works for both SPI and MMC. +*/ +/* Set first two banks FlexRAM as OCRAM(01b) and the rest to DTCM(10b) */ +DATA 4 0x400AC044 0x55aaaaaa /* Use FLEXRAM_BANK_CFG to config FlexRAM */ SET_BIT 4 0x400AC040 0x4 + diff --git a/board/freescale/imxrt1050-evk/imxrt1050-evk.c b/board/freescale/imxrt1050-evk/imxrt1050-evk.c index 6132916578..d4e39fd914 100644 --- a/board/freescale/imxrt1050-evk/imxrt1050-evk.c +++ b/board/freescale/imxrt1050-evk/imxrt1050-evk.c @@ -13,6 +13,7 @@ #include <asm/global_data.h> #include <asm/io.h> #include <asm/armv7m.h> +#include <serial.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -67,7 +68,12 @@ void spl_board_init(void)
u32 spl_boot_device(void) { - return BOOT_DEVICE_MMC1; + /* There is no way to find boot device so look if there is valid IVT in RAM for MMC*/ + u32 nor_ivt = *(u32 *)(CONFIG_SYS_LOAD_ADDR - 0xC00); + + if (nor_ivt == 0x402000d1) + return BOOT_DEVICE_MMC1; + return BOOT_DEVICE_NOR; } #endif
diff --git a/configs/imxrt1050-evk_defconfig b/configs/imxrt1050-evk_defconfig index ca3f810e02..eaf46bbeb6 100644 --- a/configs/imxrt1050-evk_defconfig +++ b/configs/imxrt1050-evk_defconfig @@ -12,15 +12,16 @@ CONFIG_NR_DRAM_BANKS=1 CONFIG_ENV_OFFSET=0x80000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="imxrt1050-evk" -CONFIG_SPL_TEXT_BASE=0x20209000 +CONFIG_SPL_TEXT_BASE=0x20002000 CONFIG_TARGET_IMXRT1050_EVK=y CONFIG_SPL_MMC=y CONFIG_SPL_SERIAL=y CONFIG_SPL_SIZE_LIMIT=0x20000 CONFIG_SPL=y CONFIG_DISTRO_DEFAULTS=y -CONFIG_SYS_LOAD_ADDR=0x20209000 +CONFIG_SYS_LOAD_ADDR=0x20002000 CONFIG_SD_BOOT=y +CONFIG_SPI_BOOT=y # CONFIG_USE_BOOTCOMMAND is not set CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y # CONFIG_DISPLAY_CPUINFO is not set @@ -30,6 +31,7 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x100 # CONFIG_SPL_CRC32 is not set +CONFIG_SPL_NOR_SUPPORT=y # CONFIG_BOOTM_NETBSD is not set # CONFIG_BOOTM_PLAN9 is not set # CONFIG_BOOTM_RTEMS is not set diff --git a/include/configs/imxrt1050-evk.h b/include/configs/imxrt1050-evk.h index 99d25c1e6e..f9b80e7b2b 100644 --- a/include/configs/imxrt1050-evk.h +++ b/include/configs/imxrt1050-evk.h @@ -9,7 +9,7 @@
#include <asm/arch/imx-regs.h>
-#define CONFIG_SYS_INIT_SP_ADDR 0x20280000 +#define CONFIG_SYS_INIT_SP_ADDR 0x20020000
#define CONFIG_SYS_FSL_ERRATUM_ESDHC135 1 #define ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE 1 @@ -40,6 +40,8 @@ #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR #define CONFIG_SYS_SPL_LEN 0x00008000 #define CONFIG_SYS_UBOOT_START 0x800023FD +#define CONFIG_SYS_UBOOT_BASE 0x60010000 +#define CONFIG_SYS_FDT_BASE 0x6008C000 #endif /* For SPL ends */

Adds documentation for SPI boot.
Signed-off-by: Jesse Taube Mr.Bossman075@gmail.com --- doc/board/nxp/imxrt1050-evk.rst | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/doc/board/nxp/imxrt1050-evk.rst b/doc/board/nxp/imxrt1050-evk.rst index c1fb48f0cd..0838a04871 100644 --- a/doc/board/nxp/imxrt1050-evk.rst +++ b/doc/board/nxp/imxrt1050-evk.rst @@ -39,3 +39,44 @@ switch label numbers reference). The USB console connector is the one close the ethernet connector
- Insert the micro SD card in the board, power it up and U-Boot messages should come up. + + +How to use U-Boot with SPI flash on NXP i.MXRT1050 EVK +------------------------------------------------------ + +- Build U-Boot for i.MXRT1050 EVK: + +First you will need to enable the following option: +CONFIG_IMX_CONFIG="board/freescale/imxrt1050-evk/imximage-nor.cfg" + +.. code-block:: bash + + $ make mrproper + $ make imxrt1050-evk_defconfig + $ make + +This will generate the SPL image called SPL and the u-boot.img. + +To boot from SPI flash you will need to provide a flash configuration block that is specific to your flash chip. +The flash config is 4K in size and is documented on page 217 of the imxrt1050RM. + +I took my FLASH config from a binary made from MCUexpresso IDE. +The truncate command should pad the spl with zeros till the value from CONFIG_SYS_UBOOT_BASE. + +.. code-block:: bash + + $ cp FLASH nor.bin + $ cat SPL >> nor.bin + $ truncate -s $((0x10000)) nor.bin + $ cat u-boot.img >> nor.bin + +- Jumper settings:: + + SW7: 0 1 1 0 + +where 0 means bottom position and 1 means top position (from the +switch label numbers reference). + +- Connect the USB cable between the EVK and the PC for the console. + +- Use either JTAG or SWD to flash the flash I used Mcuexpresso IDEs GUI flash tool
participants (1)
-
Jesse Taube