How to adjust stack and heap
Hello,
You can increase minimal heap and stack by modifying _Min_Heap_Size and _Min_Stack_Size figuring within “STM32F401****_FLASH.ld”
_Min_Heap_Size = 0x200;; /* required amount of heap */
_Min_Stack_Size = 0x400;; /* required amount of stack */
TIP: These values are only to force linker to generate an error if the RAM usage exceeds the real RAM size.
If this does not work for you (99% of cases ), ensure that you have syscalls.c in your project.
If you cannot find this file in your project:
you can borrow it from “...\STM32Cube_FW_F4_V1.10.0\Projects\STM32F401RE-Nucleo\Examples\UART\UART_Printf\SW4STM32”
and include this file in your project. After that you have to remove “-specs=nosys.specs” from Project Properties > C/C++ Build > Settings > Tool Settings > MCU GCC Linker > Miscellaneous > Linker flags
Explanation: the syscalls.c contains the implementation of _sbrk() used by malloc and manage heap and stack collision ........
the usage of nosys.specs is enough (we do not need syscalls.c) if we do not use printf or dynamic memory allocation