STM32L011D4 / Arduino_Core_STM32 / platformIO : region `RAM' overflowed
Posted: Fri Sep 05, 2025 6:46 pm
When I try to build the firmware for an L011D4 (16kB flash/2kB RAM) I get a "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 demanding 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 linesto
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.
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 demanding 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
Code: Select all
"extra_flags": "-DSTM32L0 -DSTM32L031xx",
"mcu": "stm32l031k6t6",
"product_line": "STM32L031xx",
"variant": "STM32L0xx/L031K(4-6)T_L041K6T"
Code: Select all
"extra_flags": "-DSTM32L0 -DSTM32L011xx",
"mcu": "stm32l011d4p6",
"product_line": "STM32L0x1",
"variant": "STM32L0xx/L011D(3-4)P_L021D4P"