Commit ed5e3598 authored by iabdalkader's avatar iabdalkader Committed by Damien George

mimxrt/Makefile: Fix internal flash configuration and build.

parent a22136a7
...@@ -228,21 +228,33 @@ SHARED_SRC_C += \ ...@@ -228,21 +228,33 @@ SHARED_SRC_C += \
shared/runtime/sys_stdio_mphal.c \ shared/runtime/sys_stdio_mphal.c \
shared/timeutils/timeutils.c \ shared/timeutils/timeutils.c \
# Add sources for respective board flash type # 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 qspi_hyper_flash)) ifeq ($(MICROPY_HW_FLASH_TYPE),$(filter $(MICROPY_HW_FLASH_TYPE),qspi_nor_flash))
# Add hal/flexspi_nor_flash.c or hal/flashspi_hyper_flash.c respectively MICROPY_HW_FLASH_BASE = 0x60000000
SRC_HAL_C += hal/flexspi_$(subst qspi_,,$(MICROPY_HW_FLASH_TYPE)).c FLEXSPI_FLASH_TYPE = $(MICROPY_HW_FLASH_TYPE)
# else ifeq ($(MICROPY_HW_FLASH_TYPE),$(filter $(MICROPY_HW_FLASH_TYPE),qspi_hyper_flash))
# Add custom (board specific) or default configuration MICROPY_HW_FLASH_BASE = 0x60000000
ifeq ($(MICROPY_HW_BOARD_FLASH_FILES),1) FLEXSPI_FLASH_TYPE = $(MICROPY_HW_FLASH_TYPE)
SRC_HAL_C += $(BOARD_DIR)/$(MICROPY_HW_FLASH_TYPE)_config.c else ifeq ($(MICROPY_HW_FLASH_TYPE),$(filter $(MICROPY_HW_FLASH_TYPE),internal))
else # The internal flash is an SPI NOR Flash.
SRC_HAL_C += hal/$(MICROPY_HW_FLASH_TYPE)_config.c MICROPY_HW_FLASH_BASE = 0x70000000
endif FLEXSPI_FLASH_TYPE = qspi_nor_flash
CFLAGS += -DMICROPY_HW_FLASH_INTERNAL
else else
$(error Error: Unknown board flash type $(MICROPY_HW_FLASH_TYPE)) $(error Error: Unknown board flash type $(MICROPY_HW_FLASH_TYPE))
endif 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 # Math library source files
ifeq ($(MICROPY_FLOAT_IMPL),double) ifeq ($(MICROPY_FLOAT_IMPL),double)
LIBM_SRC_C += $(addprefix lib/libm_dbl/,\ LIBM_SRC_C += $(addprefix lib/libm_dbl/,\
...@@ -341,18 +353,14 @@ CFLAGS += \ ...@@ -341,18 +353,14 @@ CFLAGS += \
-Wno-error=unused-parameter -Wno-error=unused-parameter
# Configure respective board flash type # 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
# 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\"
CFLAGS += -DBOARD_FLASH_OPS_HEADER_H=\"hal/flexspi_$(subst qspi_,,$(MICROPY_HW_FLASH_TYPE)).h\" #
# # Add custom (board specific) or default configuration
# Add custom (board specific) or default configuration ifeq ($(MICROPY_HW_BOARD_FLASH_FILES),1)
ifeq ($(MICROPY_HW_BOARD_FLASH_FILES),1) CFLAGS += -DBOARD_FLASH_CONFIG_HEADER_H=\"$(BOARD)_flexspi_flash_config.h\"
CFLAGS += -DBOARD_FLASH_CONFIG_HEADER_H=\"$(BOARD)_flexspi_flash_config.h\"
else
CFLAGS += -DBOARD_FLASH_CONFIG_HEADER_H=\"hal/flexspi_flash_config.h\"
endif
else else
$(error Error: Unknown board flash type $(MICROPY_HW_FLASH_TYPE)) CFLAGS += -DBOARD_FLASH_CONFIG_HEADER_H=\"hal/flexspi_flash_config.h\"
endif endif
# Configure floating point support # Configure floating point support
...@@ -399,7 +407,7 @@ LDFLAGS += \ ...@@ -399,7 +407,7 @@ LDFLAGS += \
# the C preprocessor. Therefore keep LDDEFINES separated from LDFLAGS! # the C preprocessor. Therefore keep LDDEFINES separated from LDFLAGS!
LDDEFINES = \ 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) -DMICROPY_HW_FLASH_SIZE=$(MICROPY_HW_FLASH_SIZE)
ifdef MICROPY_HW_FLASH_RESERVED ifdef MICROPY_HW_FLASH_RESERVED
......
...@@ -3,15 +3,7 @@ ...@@ -3,15 +3,7 @@
reserved_size = MICROPY_HW_FLASH_RESERVED; reserved_size = MICROPY_HW_FLASH_RESERVED;
#endif #endif
#if MICROPY_HW_FLASH_TYPE == qspi_nor_flash flash_start = MICROPY_HW_FLASH_BASE;
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_size = MICROPY_HW_FLASH_SIZE; flash_size = MICROPY_HW_FLASH_SIZE;
flash_end = DEFINED(reserved_size) ? ((flash_start) + (flash_size - reserved_size)) : ((flash_start) + (flash_size)); flash_end = DEFINED(reserved_size) ? ((flash_start) + (flash_size - reserved_size)) : ((flash_start) + (flash_size));
flash_config_start = flash_start; flash_config_start = flash_start;
......
...@@ -31,7 +31,10 @@ ...@@ -31,7 +31,10 @@
#include "fsl_flexspi.h" #include "fsl_flexspi.h"
// #include BOARD_FLASH_CONFIG_HEADER_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 FLEXSPI1
#define BOARD_FLEX_SPI_ADDR_BASE FlexSPI1_AMBA_BASE #define BOARD_FLEX_SPI_ADDR_BASE FlexSPI1_AMBA_BASE
#else #else
......
...@@ -27,9 +27,13 @@ ...@@ -27,9 +27,13 @@
#define MICROPY_INCLUDED_MIMXRT_HAL_FLEXSPI_NOR_FLASH_H #define MICROPY_INCLUDED_MIMXRT_HAL_FLEXSPI_NOR_FLASH_H
#include "fsl_flexspi.h" #include "fsl_flexspi.h"
#include "mpconfigboard.h"
#include BOARD_FLASH_CONFIG_HEADER_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 FLEXSPI1
#define BOARD_FLEX_SPI_ADDR_BASE FlexSPI1_AMBA_BASE #define BOARD_FLEX_SPI_ADDR_BASE FlexSPI1_AMBA_BASE
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment