I am using a STM32 F401CC blackpill.
If I am trying to allocate memory using malloc, my program hangs/crashes on the malloc command. But for bluepill STM32F103 malloc works fine.
My research into the problem led me to the memory heap settings in the file STM32F4/variants/blackpill_f401/ld/common.inc
Lines 152-153 of the file defines borders of the heap. Traditionally the heap is placed between msp and bss sections, but in this file it placed between msp_init and __data_end. But data_end is situated in FLASH, far from RAM area and not suitable for HEAP. It looks like a bug.
To fix this, I replaced in the line 152 data_end to bss_end__ :
`_lm_heap_start = DEFINED(_lm_heap_start) ? _lm_heap_start : bss_end__;`
and as result malloc on F401 blackpill now works fine.
I am using a STM32 F401CC blackpill. If I am trying to allocate memory using malloc, my program hangs/crashes on the malloc command. But for bluepill STM32F103 malloc works fine. My research into the problem led me to the memory heap settings in the file STM32F4/variants/blackpill_f401/ld/common.inc Lines 152-153 of the file defines borders of the heap. Traditionally the heap is placed between msp and bss sections, but in this file it placed between msp_init and __data_end. But data_end is situated in FLASH, far from RAM area and not suitable for HEAP. It looks like a bug. To fix this, I replaced in the line 152 data_end to bss_end__ : `_lm_heap_start = DEFINED(_lm_heap_start) ? _lm_heap_start : bss_end__;` and as result malloc on F401 blackpill now works fine.