Skip to content

Commit 7d8dac9

Browse files
committed
Refine iMX RT memory layout and add three boards
Introduces a way to place CircuitPython code and data into tightly coupled memory (TCM) which is accessible by the CPU in a single cycle. It also frees up room in the corresponding cache for intermittent data. Loading from external flash is slow! The data cache is also now enabled. Adds support for the iMX RT 1021 chip. Adds three new boards: * iMX RT 1020 EVK * iMX RT 1060 EVK * Teensy 4.0 Related to #2492, #2472 and #2477. Fixes #2475.
1 parent 85c7317 commit 7d8dac9

Some content is hidden

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

82 files changed

+2717
-530
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ jobs:
113113
- "hallowing_m0_express"
114114
- "hallowing_m4_express"
115115
- "imxrt1010_evk"
116+
- "imxrt1020_evk"
117+
- "imxrt1060_evk"
116118
- "itsybitsy_m0_express"
117119
- "itsybitsy_m4_express"
118120
- "itsybitsy_nrf52840_express"
@@ -163,6 +165,7 @@ jobs:
163165
- "stm32f411ve_discovery"
164166
- "stm32f412zg_discovery"
165167
- "stringcar_m0_express"
168+
- "teensy40"
166169
- "teknikio_bluebird"
167170
- "trellis_m4_express"
168171
- "trinket_m0"

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@
110110
url = https://github.com/adafruit/Adafruit_MP3
111111
[submodule "ports/mimxrt10xx/sdk"]
112112
path = ports/mimxrt10xx/sdk
113-
url = https://github.com/arturo182/MIMXRT10xx_SDK
113+
url = https://github.com/adafruit/MIMXRT10xx_SDK

lib/tinyusb

Submodule tinyusb updated 108 files

ports/mimxrt10xx/Makefile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ INC += \
7171
-Isdk/CMSIS/Include \
7272
-Isdk/devices/$(CHIP_FAMILY) \
7373
-Isdk/devices/$(CHIP_FAMILY)/drivers \
74+
-Isdk/devices/$(CHIP_FAMILY)/xip \
7475

7576
# NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt.
7677

@@ -114,14 +115,19 @@ CFLAGS += \
114115
-mfpu=fpv5-sp-d16 \
115116
-DCPU_$(CHIP_VARIANT) \
116117
-DDEBUG \
118+
-DIMXRT10XX \
117119
-DXIP_EXTERNAL_FLASH=1 \
118120
-DXIP_BOOT_HEADER_ENABLE=1 \
119121
-D__START=main \
120122
-Os -g3 -Wno-unused-parameter \
121123
-ffunction-sections -fdata-sections -fstack-usage \
122124
-D__STARTUP_CLEAR_BSS
123125

124-
LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
126+
LD_FILES = $(wildcard boards/$(BOARD)/*.ld) $(addprefix linking/, flash/$(FLASH).ld chip_family/$(CHIP_FAMILY).ld common.ld)
127+
128+
LD_SCRIPT_FLAG := -Wl,-T,
129+
130+
LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib $(addprefix $(LD_SCRIPT_FLAG), $(LD_FILES)) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
125131
LIBS := -lgcc -lc -lnosys -lm
126132

127133
# Use toolchain libm if we're not using our own.
@@ -154,6 +160,7 @@ SRC_SDK := $(addprefix sdk/devices/$(CHIP_FAMILY)/, $(SRC_SDK))
154160
SRC_C = \
155161
background.c \
156162
boards/$(BOARD)/board.c \
163+
boards/$(BOARD)/flash_config.c \
157164
boards/$(BOARD)/pins.c \
158165
fatfs_port.c \
159166
lib/mp-readline/readline.c \
@@ -231,20 +238,23 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
231238

232239
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
233240

234-
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
241+
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.hex
235242

236-
$(BUILD)/firmware.elf: $(LD_FILE) $(OBJ)
243+
$(BUILD)/firmware.elf: $(OBJ) $(LD_FILES)
237244
$(STEPECHO) "LINK $@"
238-
$(Q)$(CC) -o $@ $(LDFLAGS) $(filter-out $<,$^) -Wl,--start-group $(LIBS) -Wl,--end-group
245+
$(Q)$(CC) -o $@ $(LDFLAGS) $(filter-out %.ld, $^) -Wl,--start-group $(LIBS) -Wl,--end-group
239246

240247
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
241248
$(STEPECHO) "Create $@"
242-
$(Q)$(OBJCOPY) -O binary -j .interrupts -j .text -j .ARM.exidx -j .data $^ $@
249+
$(Q)$(OBJCOPY) -O binary -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $^ $@
243250

244251
$(BUILD)/firmware.uf2: $(BUILD)/firmware.bin
245252
$(STEPECHO) "Create $@"
246253
$(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $^
247254

255+
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf
256+
$(Q)$(OBJCOPY) -O ihex -j .flash_config -j .ivt -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $< $@
257+
248258
include $(TOP)/py/mkrules.mk
249259

250260
# Print out the value of a make variable.

ports/mimxrt10xx/background.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "py/runtime.h"
3636
#include "shared-module/network/__init__.h"
37+
#include "supervisor/linker.h"
3738
#include "supervisor/shared/stack.h"
3839

3940
// TODO
@@ -51,7 +52,7 @@ void background_tasks_reset(void) {
5152
running_background_tasks = false;
5253
}
5354

54-
void run_background_tasks(void) {
55+
void PLACE_IN_ITCM(run_background_tasks)(void) {
5556
// Don't call ourselves recursively.
5657
if (running_background_tasks) {
5758
return;

ports/mimxrt10xx/boards/feather_mimxrt1011/board.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,8 @@
2727

2828
#include "boards/board.h"
2929
#include "mpconfigboard.h"
30-
#include "fsl_iomuxc.h"
3130

3231
void board_init(void) {
33-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B, 1U);
34-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1,1U);
35-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 1U);
36-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 1U);
37-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 1U);
38-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 1U);
39-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 1U);
40-
41-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B,0x10E1U);
42-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1, 0x10E1U);
43-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 0x10E1U);
44-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 0x10E1U);
45-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 0x10E1U);
46-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 0x10E1U);
47-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 0x10E1U);
4832
}
4933

5034
bool board_requests_safe_mode(void) {
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Copyright 2017 NXP
3+
* All rights reserved.
4+
*
5+
* SPDX-License-Identifier: BSD-3-Clause
6+
*/
7+
8+
#include "fsl_flexspi_nor_boot.h"
9+
#include "fsl_flexspi_nor_config.h"
10+
11+
12+
__attribute__((section(".boot_hdr.ivt")))
13+
/*************************************
14+
* IVT Data
15+
*************************************/
16+
const ivt image_vector_table = {
17+
IVT_HEADER, /* IVT Header */
18+
IMAGE_ENTRY_ADDRESS, /* Image Entry Function */
19+
IVT_RSVD, /* Reserved = 0 */
20+
(uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */
21+
(uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */
22+
(uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */
23+
(uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */
24+
IVT_RSVD /* Reserved = 0 */
25+
};
26+
27+
__attribute__((section(".boot_hdr.boot_data")))
28+
/*************************************
29+
* Boot Data
30+
*************************************/
31+
const BOOT_DATA_T boot_data = {
32+
FLASH_BASE, /* boot start location */
33+
FLASH_SIZE, /* size */
34+
PLUGIN_FLAG, /* Plugin flag*/
35+
0xFFFFFFFF /* empty - extra data word */
36+
};
37+
38+
__attribute__((section(".boot_hdr.conf")))
39+
// Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39
40+
const flexspi_nor_config_t qspiflash_config = {
41+
.memConfig =
42+
{
43+
.tag = FLEXSPI_CFG_BLK_TAG,
44+
.version = FLEXSPI_CFG_BLK_VERSION,
45+
.readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad,
46+
.csHoldTime = 1u,
47+
.csSetupTime = 2u,
48+
// Enable DDR mode, Wordaddressable, Safe configuration, Differential clock
49+
.deviceType = kFlexSpiDeviceType_SerialNOR,
50+
.sflashPadType = kSerialFlash_4Pads,
51+
.serialClkFreq = kFlexSpiSerialClk_60MHz, // 03
52+
.sflashA1Size = FLASH_SIZE,
53+
.lookupTable =
54+
{
55+
// FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1)
56+
// (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) |
57+
// FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))
58+
// Read LUTs
59+
FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18),
60+
FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),
61+
0,
62+
0,
63+
64+
0x24040405,
65+
0,
66+
0,
67+
0,
68+
69+
0,
70+
0,
71+
0,
72+
0,
73+
74+
0x00000406,
75+
0,
76+
0,
77+
0,
78+
79+
0,
80+
0,
81+
0,
82+
0,
83+
84+
0x08180420,
85+
0,
86+
0,
87+
0,
88+
89+
0,
90+
0,
91+
0,
92+
0,
93+
94+
0,
95+
0,
96+
0,
97+
0,
98+
99+
0x081804D8,
100+
0,
101+
0,
102+
0,
103+
104+
0x08180402,
105+
0x00002004,
106+
0,
107+
0,
108+
109+
0,
110+
0,
111+
0,
112+
0,
113+
114+
0x00000460,
115+
},
116+
},
117+
.pageSize = 256u,
118+
.sectorSize = 4u * 1024u,
119+
.ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz,
120+
.blockSize = 0x00010000,
121+
.isUniformBlockSize = false,
122+
};

ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
#define MICROPY_HW_BOARD_NAME "Feather MIMXRT1011"
22
#define MICROPY_HW_MCU_NAME "IMXRT1011DAE5A"
33

4-
//TODO
5-
//#define MICROPY_HW_LED_STATUS (&pin_PA27)
6-
74
#define MICROPY_HW_NEOPIXEL (&pin_GPIO_SD_05)
85

9-
// These are pins not to reset.
10-
// QSPI Data pins
11-
//#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 )
12-
// QSPI CS, and QSPI SCK
13-
//#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 )
14-
//#define MICROPY_PORT_C ( 0 )
15-
//#define MICROPY_PORT_D ( 0 )
16-
176
// If you change this, then make sure to update the linker scripts as well to
187
// make sure you don't overwrite code
198
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1-
LD_FILE = boards/mimxrt1011-bootloader-external-flash.ld
21
USB_VID = 0x239A
32
USB_PID = 0x8074
43
USB_PRODUCT = "Feather MIMXRT1011"
54
USB_MANUFACTURER = "arturo182"
6-
USB_DEVICES = "CDC,MSC,HID"
75

86
CHIP_VARIANT = MIMXRT1011DAE5A
97
CHIP_FAMILY = MIMXRT1011
10-
11-
INTERNAL_FLASH_FILESYSTEM = 1
12-
13-
CIRCUITPY_DISPLAYIO = 0
14-
CIRCUITPY_AUDIOIO = 0
15-
CIRCUITPY_AUDIOBUSIO = 0
16-
CIRCUITPY_FREQUENCYIO = 0
17-
CIRCUITPY_I2CSLAVE = 0
18-
CIRCUITPY_NVM = 0
19-
CIRCUITPY_ROTARYIO = 0
20-
21-
LONGINT_IMPL = MPZ
8+
FLASH = W25Q64JV

ports/mimxrt10xx/boards/feather_mimxrt1062/board.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,8 @@
2727

2828
#include "boards/board.h"
2929
#include "mpconfigboard.h"
30-
#include "fsl_iomuxc.h"
3130

3231
void board_init(void) {
33-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_06_FLEXSPIA_SS0_B, 1U);
34-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_07_FLEXSPIA_SCLK,1U);
35-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_08_FLEXSPIA_DATA00, 1U);
36-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_09_FLEXSPIA_DATA01, 1U);
37-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_10_FLEXSPIA_DATA02, 1U);
38-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_11_FLEXSPIA_DATA03, 1U);
39-
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_05_FLEXSPIA_DQS, 1U);
40-
41-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_06_FLEXSPIA_SS0_B,0x10E1U);
42-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_09_FLEXSPIA_DATA01, 0x10E1U);
43-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_10_FLEXSPIA_DATA02, 0x10E1U);
44-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_08_FLEXSPIA_DATA00, 0x10E1U);
45-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_07_FLEXSPIA_SCLK, 0x10E1U);
46-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_11_FLEXSPIA_DATA03, 0x10E1U);
47-
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_05_FLEXSPIA_DQS, 0x10E1U);
4832
}
4933

5034
bool board_requests_safe_mode(void) {

0 commit comments

Comments
 (0)