Skip to content

Commit 04a76b3

Browse files
author
Jamie Smith
authored
Refactor MIMXRT105x target labels and linker script, locate general data in DTCM memory instead of OCRAM for improved performance (#157)
1 parent 9c65ad9 commit 04a76b3

File tree

191 files changed

+94
-29
lines changed

Some content is hidden

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

191 files changed

+94
-29
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ add_subdirectory(TARGET_IMX EXCLUDE_FROM_ALL)
55
add_subdirectory(TARGET_LPC EXCLUDE_FROM_ALL)
66
add_subdirectory(TARGET_LPC54114 EXCLUDE_FROM_ALL)
77
add_subdirectory(TARGET_MCU_LPC546XX EXCLUDE_FROM_ALL)
8-
add_subdirectory(TARGET_MIMXRT1050 EXCLUDE_FROM_ALL)
8+
add_subdirectory(TARGET_MIMXRT105x EXCLUDE_FROM_ALL)
99
add_subdirectory(TARGET_MIMXRT1170 EXCLUDE_FROM_ALL)
1010
add_subdirectory(middleware/TARGET_USB EXCLUDE_FROM_ALL)
1111

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/CMakeLists.txt renamed to targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_EVK/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ target_include_directories(mbed-mimxrt1060-evk
3434

3535
target_sources(mbed-mimxrt1060-evk
3636
INTERFACE
37-
fsl_phy.c
3837
fsl_flexspi_nor_boot.c
3938

4039
TARGET_1060_EVK/xip/evkbmimxrt1060_flexspi_nor_config.c
Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,38 @@ MEMORY
6363
#if MIMXRT105X_BOARD_HAS_EXTERNAL_RAM
6464
/* Use the external RAM as main memory */
6565
m_data (RW) : ORIGIN = 0x80000000, LENGTH = MIMXRT105X_EXTERNAL_RAM_SIZE
66+
67+
/* DTCM memory.
68+
Startup code configures size to 256k (stealing space from OCRAM). */
69+
m_dtcm (RW) : ORIGIN = 0x20000000, LENGTH = 0x00040000
6670
#else
67-
/* Use OCRAM as main memory. */
68-
m_data (RW) : ORIGIN = 0x20200000, LENGTH = 0x00040000
71+
/* Use DTCM as main memory (significantly faster than OCRAM).
72+
Startup code configures size to 256k (stealing space from OCRAM). */
73+
m_dtcm (RW) : ORIGIN = 0x20000000, LENGTH = 0x00040000
74+
75+
/* No external data memory, store data in DTCM */
76+
#define m_data m_dtcm
77+
6978
#endif
7079

80+
/* ITCM bank -- used for functions that need to execute from RAM
81+
(which is faster than having to load them from flash).
82+
Startup code configures size to 128k. */
7183
m_itcm (RX) : ORIGIN = 0x00000000, LENGTH = 0x00020000
72-
m_dtcm (RW) : ORIGIN = 0x20000000, LENGTH = 0x00020000
84+
85+
/* OCRAM bank -- extra RAM, available for misc storage but slower to access.
86+
Startup code configures size to 128k.
87+
Note that address is different on the 105x and the 106x. */
88+
#if MBED_TARGET_MIMXRT1050
89+
m_ocram (RW) : ORIGIN = 0x20200000, LENGTH = 0x00020000
90+
#else /* MIMXRT1060 */
91+
m_ocram (RW) : ORIGIN = 0x20280000, LENGTH = 0x00020000
92+
#endif
93+
94+
#if MBED_TARGET_MIMXRT1060
95+
/* OCRAM2 bank -- extra RAM, available on MIMXRT106x only. */
96+
m_ocram2 (RW) : ORIGIN = 0x20200000, LENGTH = 0x00080000
97+
#endif
7398
}
7499

75100
/* Define output sections */
@@ -234,6 +259,8 @@ SECTIONS
234259

235260
__NDATA_ROM = __ram_function_flash_start + SIZEOF(.ram_function);
236261

262+
/* Always store noncacheable data (e.g. DMA descriptors) in DTCM, since this memory
263+
does not use a cache. */
237264
.ncache.init :
238265
{
239266
__noncachedata_start__ = .; /* create a global symbol at ncache data start */
@@ -298,14 +325,16 @@ SECTIONS
298325
__heap_limit = .; /* Add for _sbrk */
299326
} > m_data
300327

328+
/* Reserve space for stack (even though stack is always at the end of DTCM regardless
329+
of where this section is located) */
301330
.stack :
302331
{
303332
. = ALIGN(8);
304333
. += STACK_SIZE;
305-
} > m_data
334+
} > m_dtcm
306335

307336
/* Initializes stack on the end of block */
308-
__StackTop = ORIGIN(m_data) + LENGTH(m_data);
337+
__StackTop = ORIGIN(m_dtcm) + LENGTH(m_dtcm);
309338
__StackLimit = __StackTop - STACK_SIZE;
310339
PROVIDE(__stack = __StackTop);
311340

@@ -318,7 +347,5 @@ SECTIONS
318347
#elif defined(TARGET_TEENSY_41)
319348
_teensy_model_identifier = 0x25;
320349
#endif
321-
322-
ASSERT(__StackLimit >= __HeapLimit, "Stack, heap, and globals exceed main RAM size!")
323350
}
324351

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,27 @@ __isr_vector:
295295
.type Reset_Handler, %function
296296
Reset_Handler:
297297
cpsid i /* Mask interrupts */
298+
299+
/* Update FlexRAM configuration to:
300+
- 128kiB OCRAM
301+
- 256kiB DTCM
302+
- 128kiB ITCM
303+
See AN12077 from NXP for info about this register value. */
304+
.equ IOMUXC_GPR16_ADDR, 0x400AC040
305+
.equ GPR16_LOAD_VALUE, 0x00200007
306+
.equ IOMUXC_GPR17_ADDR, 0x400AC044
307+
.equ GPR17_LOAD_VALUE, 0x5AAFFAA5
308+
309+
/* First, update FlexRAM configuration in GPR17 */
310+
ldr r0, =IOMUXC_GPR17_ADDR
311+
ldr r1, =GPR17_LOAD_VALUE
312+
str r1, [r0]
313+
314+
/* Now, use GPR16 to select the configuration in GPR17 instead of the one in the fuses */
315+
ldr r0, =IOMUXC_GPR16_ADDR
316+
ldr r1, =GPR16_LOAD_VALUE
317+
str r1, [r0]
318+
298319
.equ VTOR, 0xE000ED08
299320
ldr r0, =VTOR
300321
ldr r1, =__isr_vector

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/mbed_overrides.c renamed to targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/mbed_overrides.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,44 @@ void BOARD_ConfigMPU(void)
9393
MPU->RBAR = ARM_MPU_RBAR(3, 0x00000000U);
9494
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1GB);
9595

96-
/* Region 4 setting: Memory with Normal type, not shareable, outer/inner write back */
96+
/* Region 4 setting: Memory with Normal type, not shareable, outer/inner write back [ITCM] */
9797
MPU->RBAR = ARM_MPU_RBAR(4, 0x00000000U);
9898
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);
9999

100-
/* Region 5 setting: Memory with Normal type, not shareable, not cacheable */
101-
/* DTCM is set to non-cacheable so that we can use it for things like Ethernet and
102-
* USB DMA buffers which will not work if they are cached. */
100+
/* Region 5 setting: Memory with Normal type, not shareable, outer/inner write back [DTCM] */
103101
MPU->RBAR = ARM_MPU_RBAR(5, 0x20000000U);
104-
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_128KB);
102+
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB);
103+
104+
#if MBED_TARGET_MIMXRT1050
105105

106-
/* Region 6 setting: Memory with Normal type, not shareable, outer/inner write back */
106+
/* Region 6 setting: Memory with Normal type, not shareable, outer/inner write back [OCRAM] */
107107
MPU->RBAR = ARM_MPU_RBAR(6, 0x20200000U);
108-
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB);
108+
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);
109+
110+
#else // MIMXRT1060
111+
112+
/* Region 6 setting: Memory with Normal type, not shareable, outer/inner write back [OCRAM] */
113+
MPU->RBAR = ARM_MPU_RBAR(6, 0x20280000U);
114+
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);
115+
116+
/* Region 7 setting: Memory with Normal type, not shareable, outer/inner write back [OCRAM2] */
117+
MPU->RBAR = ARM_MPU_RBAR(7, 0x20200000U);
118+
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_512KB);
119+
120+
#endif
121+
122+
109123

110124
/* The define sets the cacheable memory to shareable,
111125
* this suggestion is referred from chapter 2.2.1 Memory regions,
112126
* types and attributes in Cortex-M7 Devices, Generic User Guide */
113127
#if defined(SDRAM_IS_SHAREABLE)
114-
/* Region 7 setting: Memory with Normal type, shareable, outer/inner write back, write/read allocate */
115-
MPU->RBAR = ARM_MPU_RBAR(7, 0x80000000U);
128+
/* Region 8 setting: Memory with Normal type, shareable, outer/inner write back, write/read allocate */
129+
MPU->RBAR = ARM_MPU_RBAR(8, 0x80000000U);
116130
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 1, 1, 1, 1, 0, ARM_MPU_REGION_SIZE_32MB);
117131
#else
118-
/* Region 7 setting: Memory with Normal type, not shareable, outer/inner write back, write/read allocate */
119-
MPU->RBAR = ARM_MPU_RBAR(7, 0x80000000U);
132+
/* Region 8 setting: Memory with Normal type, not shareable, outer/inner write back, write/read allocate */
133+
MPU->RBAR = ARM_MPU_RBAR(8, 0x80000000U);
120134
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 1, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_32MB);
121135
#endif
122136

targets/targets.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5090,10 +5090,10 @@
50905090
"extra_labels": [
50915091
"NXP",
50925092
"MCUXpresso_MCUS",
5093-
"MIMXRT1050",
50945093
"IMX",
50955094
"NXP_EMAC",
5096-
"USB"
5095+
"USB",
5096+
"MIMXRT105X"
50975097
],
50985098
"macros": [
50995099
"CPU_MIMXRT1052DVL6B",
@@ -5158,7 +5158,8 @@
51585158
],
51595159
"extra_labels_add": [
51605160
"EVK",
5161-
"1050_EVK"
5161+
"1050_EVK",
5162+
"MIMXRT1050"
51625163
],
51635164
"supported_form_factors": [
51645165
"ARDUINO_UNO"
@@ -5186,7 +5187,8 @@
51865187
],
51875188
"extra_labels_add": [
51885189
"EVK",
5189-
"1060_EVK"
5190+
"1060_EVK",
5191+
"MIMXRT1060"
51905192
],
51915193
"supported_form_factors": [
51925194
"ARDUINO_UNO"
@@ -5208,7 +5210,8 @@
52085210
],
52095211
"extra_labels_add": [
52105212
"TEENSY_4X",
5211-
"TEENSY_40"
5213+
"TEENSY_40",
5214+
"MIMXRT1060"
52125215
],
52135216
"macros_add": [
52145217
"MIMXRT105X_BOARD_HAS_EXTERNAL_RAM=0",
@@ -5228,7 +5231,8 @@
52285231
],
52295232
"extra_labels_add": [
52305233
"TEENSY_4X",
5231-
"TEENSY_41"
5234+
"TEENSY_41",
5235+
"MIMXRT1060"
52325236
],
52335237
"macros_add": [
52345238
"MIMXRT105X_BOARD_HAS_EXTERNAL_RAM=0",

tools/cmake/mbed_ide_debug_cfg_generator.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ if(MBED_GENERATE_CLION_DEBUG_CFGS)
5858
endif()
5959

6060
# Escape quotes and ampersands
61-
string(REPLACE "\"" """ ELEMENT "${ELEMENT}")
6261
string(REPLACE "&" "&" ELEMENT "${ELEMENT}")
62+
string(REPLACE "\"" """ ELEMENT "${ELEMENT}")
6363

6464
if("${ELEMENT}" MATCHES " ")
6565
string(APPEND GDBSERVER_ARGS_STR ""${ELEMENT}"")

tools/cmake/upload_methods/UploadMethodJLINK.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ exit
6161
COMMAND ${JLINK}
6262
${JLINK_SELECT_ARG}
6363
${JLINK_NOGUI_ARG}
64-
-Device ${JLINK_CPU_NAME}
64+
-Device \"${JLINK_CPU_NAME}\"
6565
-Speed ${JLINK_CLOCK_SPEED}
6666
-if ${JLINK_UPLOAD_INTERFACE}
6767
-JTAGConf -1,-1
@@ -81,7 +81,7 @@ set(UPLOAD_GDBSERVER_DEBUG_COMMAND
8181
"${JLINK_GDBSERVER}"
8282
${JLINK_SELECT_ARG}
8383
${JLINK_NOGUI_ARG}
84-
-Device ${JLINK_CPU_NAME}
84+
-Device \"${JLINK_CPU_NAME}\"
8585
-Speed ${JLINK_CLOCK_SPEED}
8686
-endian little
8787
-if ${JLINK_UPLOAD_INTERFACE}

0 commit comments

Comments
 (0)