Teensy 4.1, put code in FLASHMEM by default instead of RAM1

jerry20091103

New member
Hello,

I'm building a portable synth with teensy 4.1, which includes a touch screen GUI built with LVGL graphics library.
The code became really large as the project grew, it's now more than 250K and does not fit in RAM1.
I understand that all functions are treated as FASTRUN by default, so they are copied to RAM1.
Is there a way to only put them in Flash by default? I have tried tinkering with the linker file but had no luck.

Thanks!
 
Putting "FLASHMEM" as a prefix to the function prototype will have it reside in FLASH.

This example from PJRC's Startup.c for example:
Code:
FLASHMEM void configure_external_ram()
{
...
}

Start with any one time use or non critical code and see what else is needed.

Looking at the console build output will give an idea of how far away the next 32KB boundary is based on the padding present for the ITCM region.

More info on memory on the PJRC T_4.1 product page
 
Thanks for the reply.

Most of the code size comes from the libraries I used, not the code I wrote. I know I can put the FLASHMEM prefix to library functions, but libraries like LVGL are so large that it would not be feasible to do that. Is there a way to put them in FLASH by default?
 
The .ld file edits did not work. The code compiles, but the teensy will crash right at startup.

However, I did use the memory inspection tool in platformIO and moved some large variables in the libraries into DMAMEM. Also moved some one-time use functions into FLASHMEM. Now the code fits! Thanks for the help.
 
Back
Top