Closed begriffs closed 2 years ago
Is this the same as the issue raised in #3 ?
Yes, you simply need to define configISR_STACK_SIZE_WORDS...
I got it to compile using these changes:
// we'll use FreeRTOS with newlib for the C standard library,
// so be safe: https://nadler.com/embedded/newlibAndFreeRTOS.html
#define configUSE_NEWLIB_REENTRANT 1
// required for heap_useNewlib_ST.c
#define configISR_STACK_SIZE_WORDS 0x100
#define INCLUDE_xTaskGetSchedulerState 1
#undef STM_VERSION
-std=c99 -pedantic
from CFLAGS.-Xlinker --wrap=malloc -Xlinker --wrap=_malloc_r
to LDFLAGS.-lgcc
to LDLIBS.Exported symbols in my linker script:
/* WeAct "blackpill" STM32F411CEU6 */
MEMORY
{
rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
}
/* for heap_useNewlib_ST.c */
PROVIDE(__HeapBase = ORIGIN(rom) );
PROVIDE(__HeapLimit = ORIGIN(rom) + LENGTH(rom));
PROVIDE(__heap_size = LENGTH(rom));
PROVIDE(HEAP_SIZE = LENGTH(rom));
/* provided by libopencm3 */
INCLUDE cortex-m-generic.ld
However, now malloc()
crashes. I'm not even able to stop in it with a breakpoint. Not sure what to do, I guess I'll go without malloc()
, and avoid newlib functions that would try to call it internally.
OK, posting that code made me read it more closely, and it looks like I'm trying to put the heap in ROM, which obviously won't work so well. :man_facepalming:
I'll try it in RAM. Still an open question of where in there. I'll probably need to leave an offset from the start.
Look at the example LD file I provided. I try to put as much as possible in LD, and try avoid definitions in LD and also C source as inevitably they get out of sync and cause nasty bugs. Do make sure you understand positioning of ISR stack, FreeRTOS stacks, and heap, and document it clearly in your LD... Hope that helps!
Environment
I realize that my newlib is outside of the tested range (2.5 - 3.1), but some of these errors appear to be syntactical, and others are related to FreeRTOS identifiers. Do I simply need to define
configISR_STACK_SIZE_WORDS
?Compiler output
I copied
heap_useNewlib_ST.c
with the rest of theheap_
options in/usr/local/freertos-202012.04/portable/MemMang
.FreeRTOSConfig.h