Hello everyone,
I'm working on a Teensy 4.1 project and running into RAM usage issues due to the default behavior of placing most code in ITCM (RAM). I understand that, by default, functions are placed in RAM unless explicitly marked with FLASHMEM or PROGMEM.
However, instead of manually annotating every non-critical function, I'd like to reverse the default behavior:
To achieve this, I created a custom linker script that moves the default .text section to FLASH. My goal is to reduce ITCM usage significantly while preserving the normal behavior of FASTRUN, DMAMEM, and other sections like .bss and .data.
I’m encountering a few issues, and I’d appreciate any guidance:
Sorry if this has been asked before — I searched the forum but couldn’t find a thread discussing a similar custom linker setup.
Thanks in advance!
I'm working on a Teensy 4.1 project and running into RAM usage issues due to the default behavior of placing most code in ITCM (RAM). I understand that, by default, functions are placed in RAM unless explicitly marked with FLASHMEM or PROGMEM.
However, instead of manually annotating every non-critical function, I'd like to reverse the default behavior:
- All code should go to QSPI Flash by default
- Only functions marked with FASTRUN should go into ITCM
To achieve this, I created a custom linker script that moves the default .text section to FLASH. My goal is to reduce ITCM usage significantly while preserving the normal behavior of FASTRUN, DMAMEM, and other sections like .bss and .data.
Issues I'm Facing
I’m encountering a few issues, and I’d appreciate any guidance:
- Crashes or freezes when using DMAMEM arrays
- These sometimes cause reboots, or worse, a hard freeze that never recovers.
- I’m wondering if this could be caused by the combination of my linker script and TeensyThreads, which I’m using in my project.
- Possible instability from my linker script
- I don’t have much experience with linker scripts, so I’m not sure whether I’ve done something subtly wrong.
- I'd really appreciate if anyone has a known-good linker script that does what I'm aiming for — moving .text to Flash by default and keeping everything else (like FASTRUN, DMAMEM, etc.) working correctly.
What I'm Looking For
- Has anyone written a linker script for Teensy 4.1 that matches this layout and is known to work well?
- Is there a known issue when combining custom memory layouts with TeensyThreads and DMAMEM?
- Could the crash be caused by something subtle like misalignment or improper MPU region mapping?
Sorry if this has been asked before — I searched the forum but couldn’t find a thread discussing a similar custom linker setup.
Thanks in advance!