...'region RAM overflowed with stack'... error on Platformio not allowing compilation

So I have been working on a very long/complex project and was wondering if I could get some assistance on interpreting an error I have never encountered before and I am really confused on how I solved it.

The error has been screenshotted and posted below:

The program was compiling just fine last night and I literally did nothing besides turn off my computer after saving my file.

RAM overflow means your program is trying to use more RAM than is available on the microcontroller.

You also have an undefined reference to ainParameters, i.e. no .cpp / .c file defines this variable or implements that function.

What you can do is hack in the linkerscript to force compilation by giving it more RAM. The location of this .ld script can be seen in the verbose linker command (-L <path> -T <linkerscript filename>), visible with project tasks → Advanced → Verbose Build. That forced build won’t be runnable, but you can throw it into https://github.com/ARMmbed/mbed-os-linker-report or add build flags to generate the .map file and throw that into e.g. amap. That will allow you to see the memory usage of every symbol in your firmware, and unusually large or larger than you’ve expected parameters might stand out.

Well if it compiled before the reboot with all the same file contents and now it doesn’t, something is fundamentally wrong or something was changed after all.

Even minute changes like calling a function can cause a huge increase in RAM and FLASH if that function and all the buffers / objects it was working on were previously uncalled + optimized out.

Thank you for teaching me that, this will be a helpful procedure to implement in the future. I was able to get it to compile by changing an array size from 10000 to 8000. Would this be a software or hardware limitation?

Depends, if the software is making use of the array space in the most efficient way and it can’t be done in any other way other than using that (much) memory, then the software is not at fault and it’s a hardware limitation that only x amount of RAM is available. If the software was doing wasteful things (not using the most memory efficient algorithm / solving the problem in a wrong way), I’d declare it a software limitation.

1 Like