Skip to content

Commit

Permalink
mimxrt: Add support for Hyperflash chips.
Browse files Browse the repository at this point in the history
Hyperflash is used by the MIMXRT1050_EVKB, MIMXRT1060_EVK and
MIMXRT1064_EVK boards.

This commit includes:
- add support for Hyperflash
- modify MIMXRT1060_EVK and MIMXRT1064_EVK to change from QSPI to
  hyperflash.
- minor incidental changes to other boards so they still build

Note: Erasing a sector on the hyperflash is slow. It takes about a second,
which seems too long, but matches the data sheet.
  • Loading branch information
robert-hh authored and dpgeorge committed Jul 31, 2021
1 parent e29259d commit 1074c78
Show file tree
Hide file tree
Showing 29 changed files with 725 additions and 198 deletions.
3 changes: 1 addition & 2 deletions ports/mimxrt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ SRC_HAL_IMX_C += \
$(MCU_DIR)/drivers/fsl_snvs_lp.c \
$(MCU_DIR)/drivers/fsl_trng.c \

SRC_C = \
SRC_C += \
main.c \
led.c \
pin.c \
Expand All @@ -156,7 +156,6 @@ SRC_C = \
modmimxrt.c \
moduos.c \
mphalport.c \
hal/flexspi_nor_flash.c \
shared/libc/printf.c \
shared/libc/string0.c \
shared/readline/readline.c \
Expand Down
1 change: 1 addition & 0 deletions ports/mimxrt/boards/MIMXRT1010_EVK/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
#define BOARD_FLASH_CONFIG_HEADER_H "evkmimxrt1010_flexspi_nor_config.h"
#define BOARD_FLASH_OPS_HEADER_H "hal/flexspi_nor_flash.h"

#define MICROPY_HW_NUM_PIN_IRQS (2 * 32)

Expand Down
3 changes: 3 additions & 0 deletions ports/mimxrt/boards/MIMXRT1010_EVK/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ MCU_VARIANT = MIMXRT1011DAE5A

MICROPY_FLOAT_IMPL = single

SRC_C += \
hal/flexspi_nor_flash.c \

JLINK_PATH = /media/RT1010-EVK/
JLINK_COMMANDER_SCRIPT = $(BUILD)/script.jlink

Expand Down
1 change: 1 addition & 0 deletions ports/mimxrt/boards/MIMXRT1020_EVK/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
#define BOARD_FLASH_CONFIG_HEADER_H "evkmimxrt1020_flexspi_nor_config.h"
#define BOARD_FLASH_OPS_HEADER_H "hal/flexspi_nor_flash.h"

#define MICROPY_HW_NUM_PIN_IRQS (3 * 32)

Expand Down
3 changes: 3 additions & 0 deletions ports/mimxrt/boards/MIMXRT1020_EVK/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ MCU_VARIANT = MIMXRT1021DAG5A

MICROPY_FLOAT_IMPL = double

SRC_C += \
hal/flexspi_nor_flash.c \

JLINK_PATH ?= /media/RT1020-EVK/
JLINK_COMMANDER_SCRIPT = $(BUILD)/script.jlink

Expand Down
1 change: 1 addition & 0 deletions ports/mimxrt/boards/MIMXRT1050_EVK/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
#define BOARD_FLASH_CONFIG_HEADER_H "evkmimxrt1050_flexspi_nor_config.h"
#define BOARD_FLASH_OPS_HEADER_H "hal/flexspi_nor_flash.h"

#define MICROPY_HW_NUM_PIN_IRQS (4 * 32 + 3)

Expand Down
3 changes: 3 additions & 0 deletions ports/mimxrt/boards/MIMXRT1050_EVK/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ MCU_VARIANT = MIMXRT1052DVL6B

MICROPY_FLOAT_IMPL = double

SRC_C += \
hal/flexspi_nor_flash.c \

JLINK_PATH ?= /media/RT1050-EVK/

deploy: $(BUILD)/firmware.bin
Expand Down
4 changes: 2 additions & 2 deletions ports/mimxrt/boards/MIMXRT1052.ld
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ivt_size = 0x00001000;
interrupts_start = 0x60002000;
interrupts_size = 0x00000400;
text_start = 0x60002400;
text_size = ((((text_start) + 1M) + (4k - 1)) & ~(4k - 1)) - (text_start); /* reserve 1M for code but align on 4k boundary */
vfs_start = (text_start) + (text_size);
vfs_start = 0x60100000;
text_size = ((vfs_start) - (text_start));
vfs_size = ((flash_end) - (vfs_start));
itcm_start = 0x00000000;
itcm_size = 0x00020000;
Expand Down
2 changes: 1 addition & 1 deletion ports/mimxrt/boards/MIMXRT1060_EVK/MIMXRT1060_EVK.ld
Original file line number Diff line number Diff line change
@@ -1 +1 @@
flash_size = 8M;
flash_size = 64M;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <stdint.h>
#include <stdbool.h>
#include "fsl_common.h"
#include "fsl_flexspi.h"

/*! @name Driver version */
/*@{*/
Expand Down Expand Up @@ -224,6 +224,14 @@ typedef struct _FlexSPIConfig
#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11
#define NOR_CMD_LUT_SEQ_IDX_EXITQPI 12

#define HYPERFLASH_CMD_LUT_SEQ_IDX_READDATA 0
#define HYPERFLASH_CMD_LUT_SEQ_IDX_WRITEDATA 1
#define HYPERFLASH_CMD_LUT_SEQ_IDX_READSTATUS 2
#define HYPERFLASH_CMD_LUT_SEQ_IDX_WRITEENABLE 4
#define HYPERFLASH_CMD_LUT_SEQ_IDX_ERASESECTOR 6
#define HYPERFLASH_CMD_LUT_SEQ_IDX_PAGEPROGRAM 10
#define HYPERFLASH_CMD_LUT_SEQ_IDX_ERASECHIP 12

/*
* Serial NOR configuration block
*/
Expand Down
242 changes: 153 additions & 89 deletions ports/mimxrt/boards/MIMXRT1060_EVK/flash_config.c

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ports/mimxrt/boards/MIMXRT1060_EVK/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
#define BOARD_FLASH_CONFIG_HEADER_H "evkmimxrt1060_flexspi_nor_config.h"
#define BOARD_FLASH_OPS_HEADER_H "hal/flexspi_hyper_flash.h"

#define MICROPY_HW_NUM_PIN_IRQS (4 * 32 + 3)

Expand Down
3 changes: 3 additions & 0 deletions ports/mimxrt/boards/MIMXRT1060_EVK/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ MCU_VARIANT = MIMXRT1062DVJ6A

MICROPY_FLOAT_IMPL = double

SRC_C += \
hal/flexspi_hyper_flash.c \

JLINK_PATH ?= /media/RT1060-EVK/
JLINK_COMMANDER_SCRIPT = $(BUILD)/script.jlink

Expand Down
6 changes: 3 additions & 3 deletions ports/mimxrt/boards/MIMXRT1064.ld
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ivt_size = 0x00001000;
interrupts_start = 0x60002000;
interrupts_size = 0x00000400;
text_start = 0x60002400;
text_size = ((((text_start) + 1M) + (4k - 1)) & ~(4k - 1)) - (text_start); /* reserve 1M for code but align on 4k boundary */
vfs_start = (text_start) + (text_size);
vfs_start = 0x60100000;
text_size = ((vfs_start) - (text_start));
vfs_size = ((flash_end) - (vfs_start));
itcm_start = 0x00000000;
itcm_size = 0x00020000;
Expand All @@ -25,4 +25,4 @@ _sstack = __StackLimit;

/* Use second OCRAM bank for GC heap. */
_gc_heap_start = ORIGIN(m_ocrm);
_gc_heap_end = ORIGIN(m_ocrm) + LENGTH(m_ocrm);
_gc_heap_end = ORIGIN(m_ocrm) + LENGTH(m_ocrm);
2 changes: 1 addition & 1 deletion ports/mimxrt/boards/MIMXRT1064_EVK/MIMXRT1064_EVK.ld
Original file line number Diff line number Diff line change
@@ -1 +1 @@
flash_size = 8M;
flash_size = 64M;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <stdint.h>
#include <stdbool.h>
#include "fsl_common.h"
#include "fsl_flexspi.h"

/*! @name Driver version */
/*@{*/
Expand All @@ -19,9 +19,9 @@
/*@}*/

/* FLEXSPI memory config block related defintions */
#define FLEXSPI_CFG_BLK_TAG (0x42464346UL) // ascii "FCFB" Big Endian
#define FLEXSPI_CFG_BLK_TAG (0x42464346UL) // ascii "FCFB" Big Endian
#define FLEXSPI_CFG_BLK_VERSION (0x56010400UL) // V1.4.0
#define FLEXSPI_CFG_BLK_SIZE (512)
#define FLEXSPI_CFG_BLK_SIZE (512)

/* FLEXSPI Feature related definitions */
#define FLEXSPI_FEATURE_HAS_PARALLEL_MODE 1
Expand Down Expand Up @@ -223,6 +223,15 @@ typedef struct _FlexSPIConfig
#define NOR_CMD_LUT_SEQ_IDX_ENTERQPI 10
#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11
#define NOR_CMD_LUT_SEQ_IDX_EXITQPI 12

#define HYPERFLASH_CMD_LUT_SEQ_IDX_READDATA 0
#define HYPERFLASH_CMD_LUT_SEQ_IDX_WRITEDATA 1
#define HYPERFLASH_CMD_LUT_SEQ_IDX_READSTATUS 2
#define HYPERFLASH_CMD_LUT_SEQ_IDX_WRITEENABLE 4
#define HYPERFLASH_CMD_LUT_SEQ_IDX_ERASESECTOR 6
#define HYPERFLASH_CMD_LUT_SEQ_IDX_PAGEPROGRAM 10
#define HYPERFLASH_CMD_LUT_SEQ_IDX_ERASECHIP 12

/*
* Serial NOR configuration block
*/
Expand Down
Loading

0 comments on commit 1074c78

Please sign in to comment.