Increase RAM1 Size

Micha

New member
Hello together,
for free up space in RAM1 I use FLASHMEM very often at my Teensy 4.1. Even with this adjustment my RAM 1 went out of space. The usage of "DMAMEM" and "PROGMEM" free up very little space. My RAM 2 is nearly empty. Due to the i.MX RT1060 1 MB On-Chip-FlexRAM design there should be an opportunity to increase RAM 1 and decrease RAM 2. Do someone know which adjustments in the linker skript "imxrt1062_t41.ld" and the other scripts are required to achieve this?

Or is there another clever way to put more data in flash memory or RAM 2?

For now I am limited in my project to the RAM 1 size und would verly love to add more features in my project.

ErrorProgramExceedsMemorySpace.png
 
Both RAM1 and RAM2 are fixed sizes of 512KB each. FlexRAM only refers to how RAM1 can be divided for code (ITCM) and data (DTCM), the overall size can't be changed.
 
Do you have any large arrays?

Even if all your global / static variables are 32 bits, 300K without arrays would mean 75,000 small variables.
 
Do you have any large arrays?

Even if all your global / static variables are 32 bits, 300K without arrays would mean 75,000 small variables.
Yes there are arrays, but I think they are not very large. Probably there are bigger arrays in the libraries being used. All my functions in the main code use FLASHMEM.

I tried the imxrt1062_t41f.ld-File from Frank in the thread "FLASHMEM for all functions in a file". This seems to place the functions from the used libraries into flash memory and it compiles successfully (free for local variables: 190236). Unfortunately, the Teensy’s light flashes red after uploading:

CompileResult.png


A reason might be the opportunity to put the librarys in the flash without writing "FLASHMEM" in front of each library function. But I don't know a way to do this. Speed of the code is not that important for me. My used librarys:

UsedLibs.png
 
Arduino IDE compiles your code in a hidden temporary folder. Usually you can discover the location by turning on verbose output in File > Preferences (or maybe Arduino > Settings on MacOS) and then look through the huge amount of extra info in the console panel for the pathnames where it's creating the compiled files.

If figure out what's using so much memory, you want the .sym file.
 
Without doing a deep dive into your code, I would recommend you use the constexpr keyword on your variables that will never change during runtime. The keyword marks them as const for runtime but also tells the compiler that it can do more analysis of it to give you better diagnostics and also change where it is stored. Generally speaking, constexpr (and const) arrays and variables will be embedded directly into the text section. It will still allow you to take the address of the thing if desired, you just can't modify it. If some of the variables are classes then you need to make sure the constructor is marked constexpr (and all that comes along with that).

If using constexpr generates a compile time error then try using const instead.

I encounter issues with program bloat at work all the time (trying to run applications that have been instrumented with multiple coverage modes is an art form when it comes to embedded targets). So here is what I am guessing is going on: Something in your program (or libraries) is telling the compiler that it needs all of this extra writable space to do _something_. I am not sure what but it is something.
 
Back
Top