From f837f2231f93d8509d0b74b7d8529672b98e367a Mon Sep 17 00:00:00 2001 From: Ivan Ucherdzhiev Date: Mon, 21 May 2018 06:23:07 -0600 Subject: [PATCH] configs/imxrt1050-evk/src: Add support for on-board NOR FLASH boot. --- configs/imxrt1050-evk/Kconfig | 13 ++ configs/imxrt1050-evk/scripts/flash-ocram.ld | 2 +- .../src/imxrt_flexspi_nor_flash.c | 124 +++++++++++++++++- 3 files changed, 135 insertions(+), 4 deletions(-) diff --git a/configs/imxrt1050-evk/Kconfig b/configs/imxrt1050-evk/Kconfig index b5efe40f1d..97dcc345d9 100644 --- a/configs/imxrt1050-evk/Kconfig +++ b/configs/imxrt1050-evk/Kconfig @@ -4,4 +4,17 @@ # if ARCH_BOARD_IMXRT1050_EVK + +choice + prompt "Boot Flash" + default IMXRT1050_EVK_HYPER_FLASH + +config IMXRT1050_EVK_HYPER_FLASH + bool "HYPER Flash" + +config IMXRT1050_EVK_NOR_FLASH + bool "Serial NOR Flash" + +endchoice # Boot Flash + endif diff --git a/configs/imxrt1050-evk/scripts/flash-ocram.ld b/configs/imxrt1050-evk/scripts/flash-ocram.ld index 27ed1cb2c3..13a6e884ef 100644 --- a/configs/imxrt1050-evk/scripts/flash-ocram.ld +++ b/configs/imxrt1050-evk/scripts/flash-ocram.ld @@ -45,7 +45,7 @@ MEMORY OUTPUT_ARCH(arm) EXTERN(_vectors) -EXTERN(hyperflash_config) +EXTERN(flash_config) EXTERN(image_vector_table) EXTERN(boot_data) diff --git a/configs/imxrt1050-evk/src/imxrt_flexspi_nor_flash.c b/configs/imxrt1050-evk/src/imxrt_flexspi_nor_flash.c index 17693171d7..ac1b6dde65 100644 --- a/configs/imxrt1050-evk/src/imxrt_flexspi_nor_flash.c +++ b/configs/imxrt1050-evk/src/imxrt_flexspi_nor_flash.c @@ -37,16 +37,18 @@ * Included Files ******************************************************************************/ + #include "imxrt_flexspi_nor_flash.h" /******************************************************************************* * Public Data ******************************************************************************/ +#if defined (CONFIG_IMXRT1050_EVK_HYPER_FLASH) __attribute__((section(".boot_hdr.conf"))) -const struct flexspi_nor_config_s hyperflash_config = +const struct flexspi_nor_config_s flash_config = { - .mem_config = + .mem_config = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, @@ -55,7 +57,7 @@ const struct flexspi_nor_config_s hyperflash_config = .cs_setup_time = 3u, .column_address_width = 3u, - /* Enable DDR mode, Wordaddassable, Safe configuration, Differential clock */ + /* Enable DDR mode, Word addassable, Safe configuration, Differential clock */ .controller_misc_option = (1u << FLEXSPIMISC_OFFSET_DDR_MODE_EN) | (1u << FLEXSPIMISC_OFFSET_WORD_ADDRESSABLE_EN) | @@ -79,3 +81,119 @@ const struct flexspi_nor_config_s hyperflash_config = .blocksize = 256u * 1024u, .is_uniform_blocksize = 1, }; + +#elif defined (CONFIG_IMXRT1050_EVK_NOR_FLASH) +__attribute__((section(".boot_hdr.conf"))) +const struct flexspi_nor_config_s flash_config = +{ + .mem_config = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .read_sample_clksrc = FLASH_READ_SAMPLE_CLK_LOOPBACK_FROM_SCKPAD, + .cs_hold_time = 3u, + .cs_setup_time = 3u, + .column_address_width = 0u, + .device_type = FLEXSPI_DEVICE_TYPE_SERIAL_NOR, + .sflash_pad_type = SERIAL_FLASH_4PADS, + .serial_clk_freq = FLEXSPI_SERIAL_CLKFREQ_60MHz, + .sflash_a1size = 8u * 1024u * 1024u, + .data_valid_time = {16u, 16u}, + .lookup_table = + { + /* LUTs */ + /* 0 Fast read Quad IO DTR Mode Operation in SPI Mode (normal read)*/ + + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xED, RADDR_DDR, FLEXSPI_4PAD, 0x18), + FLEXSPI_LUT_SEQ(DUMMY_DDR, FLEXSPI_4PAD, 0x0C, READ_DDR, FLEXSPI_4PAD, 0x08), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + + /* 1 Read Status */ + + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05, READ_SDR, FLEXSPI_1PAD, 0x1), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + + /* 2 */ + + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 3 */ + + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + + /* 4 */ + + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 5 Erase Sector */ + + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD7, RADDR_SDR, FLEXSPI_1PAD, 0x18), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + + /* 6 */ + + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 7 */ + + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 8 */ + + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 9 Page Program */ + + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02, RADDR_SDR, FLEXSPI_1PAD, 0x18), + FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x8, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + + /* 10 */ + + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 11 Chip Erase */ + + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xC7, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x0, STOP, FLEXSPI_1PAD, 0x0), + + }, + }, + + .page_size = 256u, + .sector_size = 4u * 1024u, + .blocksize = 32u * 1024u, + .is_uniform_blocksize = false, +}; +#else +# error Boot Flash type not chosen! +#endif