summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2023-02-28 22:11:45 +0100
committerDamien George <damien@micropython.org>2023-04-11 17:03:28 +1000
commited5e3598f16a24022e78755e1a86b2d6ed12e5ca (patch)
tree5b2cc623f63591a3a9a61ecd2ee3b4dbfdad36e5
parenta22136a7322616e768962804075380103d34a09b (diff)
mimxrt/Makefile: Fix internal flash configuration and build.
-rw-r--r--ports/mimxrt/Makefile54
-rw-r--r--ports/mimxrt/boards/MIMXRT1064.ld10
-rw-r--r--ports/mimxrt/hal/flexspi_hyper_flash.h5
-rw-r--r--ports/mimxrt/hal/flexspi_nor_flash.h6
4 files changed, 41 insertions, 34 deletions
diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile
index b73d3f4db..800370e0a 100644
--- a/ports/mimxrt/Makefile
+++ b/ports/mimxrt/Makefile
@@ -228,21 +228,33 @@ SHARED_SRC_C += \
shared/runtime/sys_stdio_mphal.c \
shared/timeutils/timeutils.c \
-# Add sources for respective board flash type
-ifeq ($(MICROPY_HW_FLASH_TYPE),$(filter $(MICROPY_HW_FLASH_TYPE),qspi_nor_flash qspi_hyper_flash))
- # Add hal/flexspi_nor_flash.c or hal/flashspi_hyper_flash.c respectively
- SRC_HAL_C += hal/flexspi_$(subst qspi_,,$(MICROPY_HW_FLASH_TYPE)).c
- #
- # Add custom (board specific) or default configuration
- ifeq ($(MICROPY_HW_BOARD_FLASH_FILES),1)
- SRC_HAL_C += $(BOARD_DIR)/$(MICROPY_HW_FLASH_TYPE)_config.c
- else
- SRC_HAL_C += hal/$(MICROPY_HW_FLASH_TYPE)_config.c
- endif
+# Set flash driver name, base address and internal flash flag, based on the flash type.
+ifeq ($(MICROPY_HW_FLASH_TYPE),$(filter $(MICROPY_HW_FLASH_TYPE),qspi_nor_flash))
+ MICROPY_HW_FLASH_BASE = 0x60000000
+ FLEXSPI_FLASH_TYPE = $(MICROPY_HW_FLASH_TYPE)
+else ifeq ($(MICROPY_HW_FLASH_TYPE),$(filter $(MICROPY_HW_FLASH_TYPE),qspi_hyper_flash))
+ MICROPY_HW_FLASH_BASE = 0x60000000
+ FLEXSPI_FLASH_TYPE = $(MICROPY_HW_FLASH_TYPE)
+else ifeq ($(MICROPY_HW_FLASH_TYPE),$(filter $(MICROPY_HW_FLASH_TYPE),internal))
+ # The internal flash is an SPI NOR Flash.
+ MICROPY_HW_FLASH_BASE = 0x70000000
+ FLEXSPI_FLASH_TYPE = qspi_nor_flash
+ CFLAGS += -DMICROPY_HW_FLASH_INTERNAL
else
$(error Error: Unknown board flash type $(MICROPY_HW_FLASH_TYPE))
endif
+# Add sources for respective board flash type
+# Add hal/flexspi_nor_flash.c or hal/flashspi_hyper_flash.c respectively
+SRC_HAL_C += hal/flexspi_$(subst qspi_,,$(FLEXSPI_FLASH_TYPE)).c
+#
+# Add custom (board specific) or default configuration
+ifeq ($(MICROPY_HW_BOARD_FLASH_FILES),1)
+ SRC_HAL_C += $(BOARD_DIR)/$(FLEXSPI_FLASH_TYPE)_config.c
+else
+ SRC_HAL_C += hal/$(FLEXSPI_FLASH_TYPE)_config.c
+endif
+
# Math library source files
ifeq ($(MICROPY_FLOAT_IMPL),double)
LIBM_SRC_C += $(addprefix lib/libm_dbl/,\
@@ -341,18 +353,14 @@ CFLAGS += \
-Wno-error=unused-parameter
# Configure respective board flash type
-ifeq ($(MICROPY_HW_FLASH_TYPE),$(filter $(MICROPY_HW_FLASH_TYPE),qspi_nor_flash qspi_hyper_flash))
- # Add hal/flexspi_nor_flash.h or hal/flexspi_hyper_flash.h respectively
- CFLAGS += -DBOARD_FLASH_OPS_HEADER_H=\"hal/flexspi_$(subst qspi_,,$(MICROPY_HW_FLASH_TYPE)).h\"
- #
- # Add custom (board specific) or default configuration
- ifeq ($(MICROPY_HW_BOARD_FLASH_FILES),1)
- CFLAGS += -DBOARD_FLASH_CONFIG_HEADER_H=\"$(BOARD)_flexspi_flash_config.h\"
- else
- CFLAGS += -DBOARD_FLASH_CONFIG_HEADER_H=\"hal/flexspi_flash_config.h\"
- endif
+# Add hal/flexspi_nor_flash.h or hal/flexspi_hyper_flash.h respectively
+CFLAGS += -DBOARD_FLASH_OPS_HEADER_H=\"hal/flexspi_$(subst qspi_,,$(FLEXSPI_FLASH_TYPE)).h\"
+#
+# Add custom (board specific) or default configuration
+ifeq ($(MICROPY_HW_BOARD_FLASH_FILES),1)
+ CFLAGS += -DBOARD_FLASH_CONFIG_HEADER_H=\"$(BOARD)_flexspi_flash_config.h\"
else
- $(error Error: Unknown board flash type $(MICROPY_HW_FLASH_TYPE))
+ CFLAGS += -DBOARD_FLASH_CONFIG_HEADER_H=\"hal/flexspi_flash_config.h\"
endif
# Configure floating point support
@@ -399,7 +407,7 @@ LDFLAGS += \
# the C preprocessor. Therefore keep LDDEFINES separated from LDFLAGS!
LDDEFINES = \
- -DMICROPY_HW_FLASH_TYPE=$(MICROPY_HW_FLASH_TYPE) \
+ -DMICROPY_HW_FLASH_BASE=$(MICROPY_HW_FLASH_BASE) \
-DMICROPY_HW_FLASH_SIZE=$(MICROPY_HW_FLASH_SIZE)
ifdef MICROPY_HW_FLASH_RESERVED
diff --git a/ports/mimxrt/boards/MIMXRT1064.ld b/ports/mimxrt/boards/MIMXRT1064.ld
index 1fbc855fa..708dac4d5 100644
--- a/ports/mimxrt/boards/MIMXRT1064.ld
+++ b/ports/mimxrt/boards/MIMXRT1064.ld
@@ -3,15 +3,7 @@
reserved_size = MICROPY_HW_FLASH_RESERVED;
#endif
-#if MICROPY_HW_FLASH_TYPE == qspi_nor_flash
-flash_start = 0x60000000;
-#elif MICROPY_HW_FLASH_TYPE == qspi_hyper_flash
-flash_start = 0x60000000;
-#elif MICROPY_HW_FLASH_TYPE == internal
-flash_start = 0x70000000;
-#else
-#error Unknown MICROPY_HW_FLASH_TYPE
-#endif
+flash_start = MICROPY_HW_FLASH_BASE;
flash_size = MICROPY_HW_FLASH_SIZE;
flash_end = DEFINED(reserved_size) ? ((flash_start) + (flash_size - reserved_size)) : ((flash_start) + (flash_size));
flash_config_start = flash_start;
diff --git a/ports/mimxrt/hal/flexspi_hyper_flash.h b/ports/mimxrt/hal/flexspi_hyper_flash.h
index fe9acea42..3c016bc78 100644
--- a/ports/mimxrt/hal/flexspi_hyper_flash.h
+++ b/ports/mimxrt/hal/flexspi_hyper_flash.h
@@ -31,7 +31,10 @@
#include "fsl_flexspi.h"
// #include BOARD_FLASH_CONFIG_HEADER_H
-#if defined MIMXRT117x_SERIES
+#if defined MICROPY_HW_FLASH_INTERNAL
+#define BOARD_FLEX_SPI FLEXSPI2
+#define BOARD_FLEX_SPI_ADDR_BASE FlexSPI2_AMBA_BASE
+#elif defined MIMXRT117x_SERIES
#define BOARD_FLEX_SPI FLEXSPI1
#define BOARD_FLEX_SPI_ADDR_BASE FlexSPI1_AMBA_BASE
#else
diff --git a/ports/mimxrt/hal/flexspi_nor_flash.h b/ports/mimxrt/hal/flexspi_nor_flash.h
index 69d57da69..edc81e37f 100644
--- a/ports/mimxrt/hal/flexspi_nor_flash.h
+++ b/ports/mimxrt/hal/flexspi_nor_flash.h
@@ -27,9 +27,13 @@
#define MICROPY_INCLUDED_MIMXRT_HAL_FLEXSPI_NOR_FLASH_H
#include "fsl_flexspi.h"
+#include "mpconfigboard.h"
#include BOARD_FLASH_CONFIG_HEADER_H
-#if defined MIMXRT117x_SERIES
+#if defined MICROPY_HW_FLASH_INTERNAL
+#define BOARD_FLEX_SPI FLEXSPI2
+#define BOARD_FLEX_SPI_ADDR_BASE FlexSPI2_AMBA_BASE
+#elif defined MIMXRT117x_SERIES
#define BOARD_FLEX_SPI FLEXSPI1
#define BOARD_FLEX_SPI_ADDR_BASE FlexSPI1_AMBA_BASE
#else