Skip to content

Commit 0d7366c

Browse files
committed
mimxrt: Rework flash configuration.
- Moves definition of BOARD_FLASH_SIZE and other header files related to flash configuration into the Makefile. - Adds board specific clock_config.h. - Adds board.h, pin_mux.h, and peripherals.h as they are required by NXP MCU SDK in order to use our own clock_config.h. - Renames board specific FlexSPI configuration files. - Updates flash frequency of MIMXRT1020_EVK - Creates separated flash_config files for QSPI NOR and QSPI Hyper flash. - Unifies VFS start address to be @ 1M for 1010 and 1020 boards. - Unifies 1050EVK boards - Adds support to both NOR and HyperFlash on boards with both capabilities. - Adds automatic FlexRAM initialization to start-up code based on linker script and NXP HAL. - Applies code formatting to all files in mimxrt port. With this change the flash configuration is restructured and organized. This simplifies the configuration process and provides a better overview of each board's settings. With the integration of clock_config.h, board.h, pin_mux.h, and peripherals.h we gain better control of the settings and clock configurations. Furthermore the implementation of an explicit FlexRAM setup improves the system performance and allows for performance tuning. Signed-off-by: Philipp Ebensberger
1 parent 426785a commit 0d7366c

82 files changed

Lines changed: 4830 additions & 3633 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ports/mimxrt/Makefile

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ endif
1313
include ../../py/mkenv.mk
1414
include $(BOARD_DIR)/mpconfigboard.mk
1515

16+
# Set optional flash configuration variables
17+
BOARD_FLASH_RESERVED ?=
18+
19+
LD_MEMORY_CONFIG_DEFINES += \
20+
BOARD_FLASH_TYPE=$(BOARD_FLASH_TYPE) \
21+
BOARD_FLASH_SIZE=$(BOARD_FLASH_SIZE)
22+
23+
ifdef $(BOARD_FLASH_RESERVED)
24+
LD_MEMORY_CONFIG_DEFINES += BOARD_FLASH_RESERVED=$(BOARD_FLASH_RESERVED)
25+
endif
26+
1627
# Qstr definitions (must come before including py.mk)
1728
QSTR_DEFS = qstrdefsport.h
1829
QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h
@@ -28,9 +39,10 @@ include $(TOP)/py/py.mk
2839
GIT_SUBMODULES = lib/tinyusb lib/nxp_driver
2940

3041
MCU_DIR = lib/nxp_driver/sdk/devices/$(MCU_SERIES)
31-
LD_FILES = boards/$(BOARD)/$(BOARD).ld boards/$(MCU_SERIES).ld boards/common.ld
42+
LD_FILES = boards/$(MCU_SERIES).ld boards/common.ld
3243

3344
MAKE_PINS = boards/make-pins.py
45+
MAKE_FLEXRAM_LD = boards/make-flexram-config.py
3446
BOARD_PINS = $(BOARD_DIR)/pins.csv
3547
AF_FILE = boards/$(MCU_SERIES)_af.csv
3648
PREFIX_FILE = boards/mimxrt_prefix.c
@@ -39,18 +51,19 @@ GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
3951
GEN_PINS_QSTR = $(BUILD)/pins_qstr.h
4052
GEN_PINS_AF_CONST = $(HEADER_BUILD)/pins_af_const.h
4153
GEN_PINS_AF_PY = $(BUILD)/pins_af.py
54+
GEN_FLEXRAM_CONFIG_SRC = $(BUILD)/flexram_config.s
4255

4356
# mcu driver cause following warnings
4457
#CFLAGS += -Wno-error=float-equal -Wno-error=nested-externs
4558
CFLAGS += -Wno-error=unused-parameter
4659

4760
INC += -I.
61+
INC += -Ihal
4862
INC += -I$(BOARD_DIR)
4963
INC += -I$(BUILD)
5064
INC += -I$(TOP)
5165
INC += -I$(TOP)/$(MCU_DIR)
5266
INC += -I$(TOP)/$(MCU_DIR)/drivers
53-
INC += -I$(TOP)/$(MCU_DIR)/project_template
5467
INC += -I$(TOP)/lib/cmsis/inc
5568
INC += -I$(TOP)/lib/oofatfs
5669
INC += -I$(TOP)/lib/tinyusb/hw
@@ -67,10 +80,20 @@ CFLAGS += -DXIP_EXTERNAL_FLASH=1 \
6780
-D__STARTUP_CLEAR_BSS \
6881
-D__STARTUP_INITIALIZE_RAMFUNCTION \
6982
-D__START=main \
70-
-DCPU_HEADER_H='<$(MCU_SERIES).h>'
83+
-DCPU_HEADER_H='<$(MCU_SERIES).h>' \
84+
-DBOARD_FLASH_SIZE=$(BOARD_FLASH_SIZE) \
85+
-DBOARD_FLASH_CONFIG_HEADER_H=\"$(BOARD)_flexspi_nor_config.h\"
86+
87+
ifeq ($(BOARD_FLASH_TYPE), qspi_nor)
88+
CFLAGS += -DBOARD_FLASH_OPS_HEADER_H=\"hal/flexspi_nor_flash.h\"
89+
else ifeq ($(BOARD_FLASH_TYPE), hyperflash)
90+
CFLAGS += -DBOARD_FLASH_OPS_HEADER_H=\"hal/flexspi_hyper_flash.h\"
91+
endif
92+
7193
ifeq ($(MICROPY_PY_MACHINE_SDCARD),1)
7294
CFLAGS += -DMICROPY_PY_MACHINE_SDCARD=1
7395
endif
96+
7497
CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
7598

7699
# Configure floating point support
@@ -88,7 +111,8 @@ endif
88111
SUPPORTS_HARDWARE_FP_SINGLE = 0
89112
SUPPORTS_HARDWARE_FP_DOUBLE = 0
90113

91-
LDFLAGS = $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref --print-memory-usage
114+
LDFLAGS = -Map=$@.map --cref --print-memory-usage
115+
LDDEFINES = $(addprefix -D, $(LD_MEMORY_CONFIG_DEFINES))
92116
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
93117

94118
# Tune for Debugging or Optimization
@@ -144,7 +168,6 @@ SRC_HAL_IMX_C += $(MCU_DIR)/drivers/fsl_usdhc.c
144168
endif
145169

146170
SRC_C += \
147-
$(BOARD_DIR)/flash_config.c \
148171
board_init.c \
149172
dma_channel.c \
150173
drivers/bus/softspi.c \
@@ -184,6 +207,18 @@ SRC_C += \
184207
$(SRC_TINYUSB_C) \
185208
$(SRC_HAL_IMX_C) \
186209

210+
ifeq ($(BOARD_FLASH_TYPE), qspi_nor)
211+
SRC_C += \
212+
hal/flexspi_nor_flash.c \
213+
$(BOARD_DIR)/qspi_nor_flash_config.c
214+
else ifeq ($(BOARD_FLASH_TYPE), hyperflash)
215+
SRC_C += \
216+
hal/flexspi_hyper_flash.c \
217+
$(BOARD_DIR)/qspi_hyper_flash_config.c
218+
else
219+
$(error Error: Unknown board flash type $(BOARD_FLASH_TYPE))
220+
endif
221+
187222
ifeq ($(MICROPY_FLOAT_IMPL),double)
188223
LIBM_SRC_C += $(addprefix lib/libm_dbl/,\
189224
__cos.c \
@@ -277,7 +312,9 @@ ifeq ($(MICROPY_FLOAT_IMPL),double)
277312
$(LIBM_O): CFLAGS := $(filter-out -Wdouble-promotion -Wfloat-conversion, $(CFLAGS))
278313
endif
279314

280-
SRC_SS += $(MCU_DIR)/gcc/startup_$(MCU_SERIES).S
315+
SRC_SS = \
316+
$(MCU_DIR)/gcc/startup_$(MCU_SERIES).S \
317+
hal/resethandler_MIMXRT10xx.S
281318

282319
SRC_S += shared/runtime/gchelper_m3.s \
283320

@@ -316,8 +353,10 @@ $(BUILD)/lib/tinyusb/src/device/usbd.o: CFLAGS += -Wno-missing-braces
316353
all: $(BUILD)/firmware.hex $(BUILD)/firmware.bin
317354

318355
$(BUILD)/firmware.elf: $(OBJ)
356+
$(ECHO) "PREPROCESS LINK $@"
357+
$(Q)$(CC) -E -x c $(LDDEFINES) $(LD_FILES) | grep -v '^#' > $(BUILD)/link.ld
319358
$(ECHO) "LINK $@"
320-
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
359+
$(Q)$(LD) -T$(BUILD)/link.ld $(LDFLAGS) -o $@ $^ $(LIBS)
321360
$(Q)$(SIZE) $@
322361

323362
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
@@ -326,17 +365,23 @@ $(BUILD)/firmware.bin: $(BUILD)/firmware.elf
326365
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf
327366
$(Q)$(OBJCOPY) -O ihex -R .eeprom $< $@
328367

329-
# Making OBJ use an order-only depenedency on the generated pins.h file
368+
# Making OBJ use an order-only dependency on the generated pins.h file
330369
# has the side effect of making the pins.h file before we actually compile
331370
# any of the objects. The normal dependency generation will deal with the
332371
# case when pins.h is modified. But when it doesn't exist, we don't know
333372
# which source files might need it.
334-
$(OBJ): | $(GEN_PINS_HDR)
373+
$(OBJ): | $(GEN_PINS_HDR) $(GEN_FLEXRAM_CONFIG_SRC)
335374

336375
# With conditional pins, we may need to regenerate qstrdefs.h when config
337376
# options change.
338377
$(HEADER_BUILD)/qstrdefs.generated.h: $(BOARD_DIR)/mpconfigboard.h
339378

379+
$(GEN_FLEXRAM_CONFIG_SRC):
380+
$(ECHO) "Create $@"
381+
$(Q)$(PYTHON) $(MAKE_FLEXRAM_LD) -d $(TOP)/$(MCU_DIR)/$(MCU_SERIES).h \
382+
-f $(TOP)/$(MCU_DIR)/$(MCU_SERIES)_features.h -l boards/$(MCU_SERIES).ld -c $(MCU_SERIES) > $(GEN_FLEXRAM_CONFIG_SRC)
383+
384+
340385
# Use a pattern rule here so that make will only call make-pins.py once to make
341386
# both pins_gen.c and pins.h
342387
$(BUILD)/%_gen.c $(HEADER_BUILD)/%.h: $(BOARD_PINS) $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)

ports/mimxrt/boards/MIMXRT1010_EVK/MIMXRT1010_EVK.ld

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)