You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "jlaitine (via GitHub)" <gi...@apache.org> on 2026/10/01 12:46:29 UTC

[PR] Enable itcm dtcm on imxrt118x [nuttx]

jlaitine opened a new pull request, #20430:
URL: https://github.com/apache/nuttx/pull/20430

   ## Summary
   
   When running larger application on the imxrt118x, I quickly run out of performance while running from XIP on
   NOR flash.
   
   Imxrt PX4 configurations for imxrt1176 place all the hot functions into ITMC. This patchset enables the same for imxrt118x, with the addition to placing .bss, .data and initial heap on DTCM + more heap to OCRAM.
   
   - Imxrt118x has ECC for TCM memories (enabled by default). To prevent ECC from causing faults on ECC, initialize the TCM memories very early in the boot. These are ARMV7-M, not imxrt specific, so I added the initialization loops behind two new configuration macros ARMV7M_ITCM_ECC and ARMV7M_DTCM_ECC, and added assembly coded enabling and loops to initialize both with 64-bit writes.
   - The imxrt118x eDMA supports transferring directly to/from M7 DTCM, but the access needs to be done via separate memory address/port. This adds support into imxrt eDMA driver for address translation for any source/destination address which lands in the DTCM. In practice this enables using the existing drivers which have DMA buffers in .bss directly with imxrt118x also with eDMA.
   - Change the imxrt1180-evk:nsh configuration to use all these features as and example of optimized performance configuration.
   
   ## Impact
   
   No impact on other than imxrt platform; enables high performance on imxrt118x.
   
   ## Testing
   
   Tested on external application (PX4 on imxrt1189, 3 IMUs, 3 EKF instances). Running only from qSPI NOR as XIP, the configration doesn't run at all. With hot functions placed in ITCM, CPU load is ~85 %. With also .data, .bss and heap in DTCM, the load drops to ~66%, with 2 mavlink instances as well, one at high rate on USB ttyacm:
   
   ```
    PID COMMAND                   CPU(ms) CPU(%)  USED/STACK PRIO(BASE) TSLICE FD
      0 Idle_Task                    8822 32.925   620/ 4016   0 (  0)      0  3
      5 wq:manager                      0  0.000   700/ 1176 255 (255)     20  4
      6 wq:lp_default                   0  0.406  1840/ 1840 205 (205)     20  4
    985 mavlink_rcv_if0                 0  0.296  1548/ 5064 175 (175)     20  4
     27 wq:hp_default                   0  0.149   876/ 2720 237 (237)     20  4
    271 wq:SPI2                        45 21.343  1980/ 2488 252 (252)     20  4
    268 wq:I2C3                         1  0.621  1124/ 2256 244 (244)     20  4
    378 wq:nav_and_controllers         20  9.917  1532/ 2160 242 (242)     20  4
    381 wq:rate_ctrl                    9  4.340  2328/ 3064 255 (255)     20  4
    382 wq:INS0                        13  6.170  3916/ 5920 241 (241)     20  4
    387 wq:INS1                        12  5.692  3916/ 5920 240 (240)     20  4
    391 wq:INS2                        10  5.156  3916/ 5920 239 (239)     20  4
    393 commander                       4  2.105  1744/ 3128 140 (140)     19  4
    874 gps                             0  0.297  1308/ 1872 205 (205)     20  4
    910 mavlink_if0                     6  3.296  1952/ 2648 100 (100)     12  4
    927 navigator                       1  0.796  2184/ 2184 105 (105)     14  3
    979 logger                          0  0.281  2928/ 3544 230 (230)     16  3
   1009 top                             0  0.104  2580/ 4000 237 (237)     20  3
   1003 mavlink_if1                    11  5.233  2036/ 2736 100 (100)      7  5
   1008 mavlink_rcv_if1                 0  0.139  1356/ 5064 175 (175)     20  5
   
   Processes: 20 total, 5 running, 15 sleeping
   CPU usage: 66.34% tasks, 0.73% sched, 32.92% idle
   Uptime: 21.181s total, 8.822s idle
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm: enable itcm dtcm on imxrt118x [nuttx]

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on code in PR #20430:
URL: https://github.com/apache/nuttx/pull/20430#discussion_r4158587507


##########
arch/arm/src/armv7-m/arm_vectors.c:
##########
@@ -58,12 +58,62 @@
 
 extern void __start(void);
 
+#if defined(CONFIG_ARMV7M_ITCM_ECC) || defined(CONFIG_ARMV7M_DTCM_ECC)
+static void start(void) __attribute__((naked, no_instrument_function));
+#endif
+
 static void start(void)
 {
   /* Zero lr to mark the end of backtrace */
 
+#if defined(CONFIG_ARMV7M_ITCM_ECC) || defined(CONFIG_ARMV7M_DTCM_ECC)
+  /* Run without a stack until TCM ECC is initialized. */
+
+  __asm__ __volatile__(
+    "cpsid i\n\t"
+    "mov  lr, #0\n\t"
+    "movs r0, #7\n\t"          /* EN | RMW | RETEN */
+#ifdef CONFIG_ARMV7M_ITCM_ECC
+    "ldr  r3, =0xe000ef90\n\t" /* ITCMCR */
+    "str  r0, [r3]\n\t"

Review Comment:
   We can actually make a purely imxrt1180 solution, and put the m7 tcm ecc massaging entirely in m33 side. This is exactly as what the nxp sdk does. The m7 dtcm is accessible to m33 via the same address space as what the edma uses. This has the advantage that then m33 can release m7 to run directly from tcm. I can do this tomorrow, I think this feature will be anyhow needed. Then we can drop the added configs and avoid touching the generic armv7-m.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm: enable itcm dtcm on imxrt118x [nuttx]

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on code in PR #20430:
URL: https://github.com/apache/nuttx/pull/20430#discussion_r4158587507


##########
arch/arm/src/armv7-m/arm_vectors.c:
##########
@@ -58,12 +58,62 @@
 
 extern void __start(void);
 
+#if defined(CONFIG_ARMV7M_ITCM_ECC) || defined(CONFIG_ARMV7M_DTCM_ECC)
+static void start(void) __attribute__((naked, no_instrument_function));
+#endif
+
 static void start(void)
 {
   /* Zero lr to mark the end of backtrace */
 
+#if defined(CONFIG_ARMV7M_ITCM_ECC) || defined(CONFIG_ARMV7M_DTCM_ECC)
+  /* Run without a stack until TCM ECC is initialized. */
+
+  __asm__ __volatile__(
+    "cpsid i\n\t"
+    "mov  lr, #0\n\t"
+    "movs r0, #7\n\t"          /* EN | RMW | RETEN */
+#ifdef CONFIG_ARMV7M_ITCM_ECC
+    "ldr  r3, =0xe000ef90\n\t" /* ITCMCR */
+    "str  r0, [r3]\n\t"

Review Comment:
   We can actually make a purely imxrt1180 solution, and put the m7 dtcm ecc massaging entirely in m33 side. This is exactly as what the nxp sdk does. The m7 dtcm is accessible to m33 via the same address space as what the edma uses. This has the advantage that then m33 can release m7 to run directly from tcm. I can do this tomorrow, I think this feature will be anyhow needed. Then we can drop the added configs and avoid touching the generic armv7-m.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm: enable itcm dtcm on imxrt118x [nuttx]

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on code in PR #20430:
URL: https://github.com/apache/nuttx/pull/20430#discussion_r4158142666


##########
arch/arm/src/armv7-m/arm_vectors.c:
##########
@@ -58,12 +58,62 @@
 
 extern void __start(void);
 
+#if defined(CONFIG_ARMV7M_ITCM_ECC) || defined(CONFIG_ARMV7M_DTCM_ECC)
+static void start(void) __attribute__((naked, no_instrument_function));
+#endif
+
 static void start(void)
 {
   /* Zero lr to mark the end of backtrace */
 
+#if defined(CONFIG_ARMV7M_ITCM_ECC) || defined(CONFIG_ARMV7M_DTCM_ECC)
+  /* Run without a stack until TCM ECC is initialized. */
+
+  __asm__ __volatile__(
+    "cpsid i\n\t"
+    "mov  lr, #0\n\t"
+    "movs r0, #7\n\t"          /* EN | RMW | RETEN */
+#ifdef CONFIG_ARMV7M_ITCM_ECC
+    "ldr  r3, =0xe000ef90\n\t" /* ITCMCR */
+    "str  r0, [r3]\n\t"

Review Comment:
   ECC is enabled by default, so then it should be disabled first; i didn't check if that is possible. Also smaller than 64 bit writes seem to trigger ecc fault ( perhaps it does 64 bit rmw internally and the initial 64-bit read fails already?), so initializing .data / zeroing .bss with 32 bit writes fault if ecc is not initialized. Full zero-initialize with 64-bit writes initially seemed simplest and it is quick operation (about half ms). The zero initialization is actually what the nxp's MCUXpresso SDK does as well, so I followed that pattern.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm/imxrt: enable itcm dtcm on imxrt118x [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #20430:
URL: https://github.com/apache/nuttx/pull/20430


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm: enable itcm dtcm on imxrt118x [nuttx]

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on PR #20430:
URL: https://github.com/apache/nuttx/pull/20430#issuecomment-6031850117

   I re-based this, and moved the helper address translation functions imxrt_dma_transfer_address and imxrt_dma_cpu_address into an own header for future use by other drivers. Kept them inline, and 118x specific so that they get completely optimized away for other imxrt targets, keeping the existing functionality for them intact.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm: enable itcm dtcm on imxrt118x [nuttx]

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on PR #20430:
URL: https://github.com/apache/nuttx/pull/20430#issuecomment-6014665714

   I just found out that the function "imxrt_dma_address" is common functionality needed also by other drivers. I just enabled also sdcard driver, and realized that the uSDHC DMA needs to do exactly the same address translation as the eDMA. So I could still break the address translation for M7 DTCM into an own header in this PR. Or, I can do this in a follow up PR when enabling the SD card, if that is preferred. What do you think @xiaoxiang781216 ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm: enable itcm dtcm on imxrt118x [nuttx]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20430:
URL: https://github.com/apache/nuttx/pull/20430#issuecomment-5931894861

   <!-- membrowse-pr-comment -->
   ## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
   
   *No memory changes detected for:*
   - [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=2eb8d83e3ce17d129a08fd428bb632cfea387f8f&base=1dfa028808454c8d256678e585af5293200bb2ef)
   - [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=2eb8d83e3ce17d129a08fd428bb632cfea387f8f&base=1dfa028808454c8d256678e585af5293200bb2ef)
   - [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=2eb8d83e3ce17d129a08fd428bb632cfea387f8f&base=1dfa028808454c8d256678e585af5293200bb2ef)
   - [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=2eb8d83e3ce17d129a08fd428bb632cfea387f8f&base=1dfa028808454c8d256678e585af5293200bb2ef)
   - [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=2eb8d83e3ce17d129a08fd428bb632cfea387f8f&base=1dfa028808454c8d256678e585af5293200bb2ef)
   - [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=2eb8d83e3ce17d129a08fd428bb632cfea387f8f&base=1dfa028808454c8d256678e585af5293200bb2ef)
   - [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=2eb8d83e3ce17d129a08fd428bb632cfea387f8f&base=1dfa028808454c8d256678e585af5293200bb2ef)
   - [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=2eb8d83e3ce17d129a08fd428bb632cfea387f8f&base=1dfa028808454c8d256678e585af5293200bb2ef)
   - [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=2eb8d83e3ce17d129a08fd428bb632cfea387f8f&base=1dfa028808454c8d256678e585af5293200bb2ef)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm: enable itcm dtcm on imxrt118x [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #20430:
URL: https://github.com/apache/nuttx/pull/20430#discussion_r4157356726


##########
arch/arm/src/armv7-m/arm_vectors.c:
##########
@@ -58,12 +58,62 @@
 
 extern void __start(void);
 
+#if defined(CONFIG_ARMV7M_ITCM_ECC) || defined(CONFIG_ARMV7M_DTCM_ECC)
+static void start(void) __attribute__((naked, no_instrument_function));
+#endif
+
 static void start(void)
 {
   /* Zero lr to mark the end of backtrace */
 
+#if defined(CONFIG_ARMV7M_ITCM_ECC) || defined(CONFIG_ARMV7M_DTCM_ECC)
+  /* Run without a stack until TCM ECC is initialized. */
+
+  __asm__ __volatile__(
+    "cpsid i\n\t"
+    "mov  lr, #0\n\t"
+    "movs r0, #7\n\t"          /* EN | RMW | RETEN */
+#ifdef CONFIG_ARMV7M_ITCM_ECC
+    "ldr  r3, =0xe000ef90\n\t" /* ITCMCR */
+    "str  r0, [r3]\n\t"

Review Comment:
   but why not postpone ECC enable after the normal bss/data finish the initialization



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm: enable itcm dtcm on imxrt118x [nuttx]

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on PR #20430:
URL: https://github.com/apache/nuttx/pull/20430#issuecomment-5947157695

   This was quick; @arikimari in our team actually had some code ready for initializing the M7 DTCM from M33. So I now dropped the generic M7 TCM ECC initialization, and added Ari's code for M33 bootloader, to do TCM initialization before the M7 release. Testeed again on imxrt1180-evk:bl + imxrt1180-evk:nsh combination, as well as with my PX4 configuration.  All work fine.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm: enable itcm dtcm on imxrt118x [nuttx]

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on PR #20430:
URL: https://github.com/apache/nuttx/pull/20430#issuecomment-6052989115

   I think this needs another reviewer to proceed. Any volunteers? @jerpelea , @simbit18 , someone else? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org