ST Nucleo L011K4 - region `RAM' overflowed


During linking I receive error caused by:

> .pioenvs\nucleo_l011k4\firmware.elf section ._user_heap_stack' will not fit in regionRAM’
> region `RAM’ overflowed by x bytes.

In file I see that:

> .data.impure_data 0x20000000 0x428 c:/users/bzc8jx/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/lib/thumb/v6-m\libc.a(lib_a-impure.o) .data.__atexit_recursive_mutex

that is taking almoust 1k of RAM so heap and stack cannot fit (I’m using standard linker script).
How to fix it?


I too would be interested in this - the linker script for this µC with such limited memory resources probably needs to be adjusted.

UPDATE - I worked around this by editing this file: ~/.platformio/packages/framework-stm32cube/platformio/ldscripts/STM32L011K4_DEFAULT.ld

Lowering the values from 0x200/0x400 to 0x100/0x100 respectively:

_Min_Heap_Size = 0x100;      /* required amount of heap  */
_Min_Stack_Size = 0x100;     /* required amount of stack */

And then a simple blink build works.

(but I couldn’t quite figure out where that file can be found on GitHub)