This thread appears to have a life of its own! Here is my 2 cents worth... Probably worth about that much:
Of course it's only possible if they are const data.
Compilation will fail if the code size is larger than RAM1.
If your arrays are initialized as part of the build process and are larger than can fit into RAM1 and as such you need to put them into PSRAM,
or DMAMEM or EXTMEM, you will need to mark them as PROGMEM and as such const. Otherwise, it is first going to try to download the
data to RAM1. If the data is changeable, you will then need to copy it out of PROGMEM to your desired memory region.
Note: Not sure which of these memory regions are faster: Flash, PSRAM, ... All of which other than RAM1 will use the cache.
Putting stuff on the stack - works, unless you do too much of it. If you look at the memory section of the product page.
https://www.pjrc.com/store/teensy41.html#memory
And there is no warning.
Note: the local Variables in the diagram is the stack, which grows from the top down... If you use too much it will start to
overwrite other variables. Which can lead to very unpredictable code. Have had a few sketches where I ran into this and with some of
them we put in code, that did things like, initialize the whole stack to some known state and at times would walk the stack trying to
figure out, how much of it was used up....
Dynamic memory - As mentioned, malloc uses RAM2, extmem_malloc uses the PSRAM,
It has been a while since I tried it, but I believe you can also create one or more heaps in RAM1 as well.
Using SMALLOC code that is in the core. This is used for extmem_malloc.
For example, you could create a global array of some size, that is placed in DTCM. And then create a heap using this memory...
Also I don't remember if it worked to create a heap into the wasted space of ITCM.
That is RAM1 is actually made up in 32kb chucks.
If your code for example in ITCM is 32K + 1 byte it will use up two chunks or 64K and the ITCM is then 512K - 64K in size.
That is shown in a build like:
Code:
Memory Usage on Teensy 4.1:
FLASH: code:96416, data:32248, headers:8548 free for files:7989252
RAM1: variables:53568, code:86952, padding:11352 free for local variables:372416
RAM2: variables:12416 free for malloc/new:511872
So if you can shrink the code by enough to reduce it to fit into one less chunk you will have more space for data.
At one point I think a few of use
@defragster? tried creating a heap within the wasted space?
Try it - If it were me, I would try out some of the different approaches and hopefully one works.
Good luck