cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L011D4 / Arduino_Core_STM32 / platformIO : region `RAM' overflowed

Lupin
Visitor

When I try to build the firmware for a L011D4 (16kB flash/2kB RAM) I get an "section `._user_heap_stack' will not fit in region `RAM'" and "region `RAM' overflowed" error even on an empty project (empty Arduino setup() and loop() functions).

What do I need to do to get around this? I can't believe an empty project already fills up 2kB of RAM just for the Arduino core. If there really IS something using that much RAM, how could I find out what it is? I know there's also the ldscript.ld file, but I don't dare yet to change anything there, because I don't know what I'm doing ;) .

In the end the MCU should just react to two buttons, control two LEDs, read two ADC channels and control a PWM output based on that. I also need a calibration value, which is why I chose the L011D4 in the first place (it's one of the few with an EEPROM). The L011D4 should be plenty for that.

 

My project is configured as follows. I am using Visual Studio Code with platformIO for all my MCU (STM32, AVR, ESP32) programming, usually always with the Arduino framework. platformIO does not have a board definition for a generic L011D4, so I created a custom one based the "nucleo_l031k6" board. I just changed the lines
"extra_flags": "-DSTM32L0 -DSTM32L031xx",
"mcu": "stm32l031k6t6",
"product_line": "STM32L031xx",
"variant": "STM32L0xx/L031K(4-6)T_L041K6T"
to
"extra_flags": "-DSTM32L0 -DSTM32L011xx",
"mcu": "stm32l011d4p6",

"product_line": "STM32L0x1",
"variant": "STM32L0xx/L011D(3-4)P_L021D4P"

I also created the respective board variant folder to define custom clock settings. For that I copied the "variants/STM32L0xx/L011D(3-4)P_L021D4P" of Arduino_Core_STM32 and made changes to "WEAK void SystemClock_Config(void)" (code created with CubeMX) and then pointed platformIO to that directory (essentially overriding the variant-line in the board definition file). I know this procedure works, because I've done the same with a F103CB to create a board variant that uses the internal oscillator.

1 ACCEPTED SOLUTION

Accepted Solutions

@TDK wrote:

Not many people here using Arduino.


Indeed.

@Lupin the place for STM32Duino (the Arduino STM32 core) questions is: https://www.stm32duino.com/

Or, for general Arduino questions, the main Arduino forums: https://forum.arduino.cc/

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

View solution in original post

4 REPLIES 4
TDK
Super User

Not many people here using Arduino.

You can look at the map file to see how RAM is split up. STM32CubeIDE has a Build Analyzer tab that allows you to browse this.

2k RAM isn't a lot.

If you feel a post has answered your question, please click "Accept as Solution".
Ozone
Principal II

The stack contains non-global data.
Perhaps you can play around with optimisation settings, or removing libraries from the project your don't need.

But 2kB/16kB might be the lower limit, consider a device with more resources - or switch to less profligate environment / toolchain like plain C/C++.


@TDK wrote:

Not many people here using Arduino.


Indeed.

@Lupin the place for STM32Duino (the Arduino STM32 core) questions is: https://www.stm32duino.com/

Or, for general Arduino questions, the main Arduino forums: https://forum.arduino.cc/

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

@Andrew Neil wrote:

Indeed.

@Lupin the place for STM32Duino (the Arduino STM32 core) questions is: https://www.stm32duino.com/

Or, for general Arduino questions, the main Arduino forums: https://forum.arduino.cc/


Thank you. That also explains why I had a hard time deciding what the right sub-forum here was as I didn't find many similar questions. I didn't know about the stm32duino forum. Off I am then!