2019-05-02 06:50 AM
Hello Community,
I'm using an ST Nucleo-F767ZI and I create my project, for Atollic True Studio, with Cube32MX.
In my project I included FreeRTOS v10.
I'm in troubled with the malloc function, because this function return a NULL pointer.
I have several tasks, and I'm not able to allocate memory inside a task.
If I invoke the malloc function in the main.c, the function returns a pointer.
I don't know why this happens.
Thanks for the help.
Federico
2019-09-16 09:52 AM
I've just tried creating an STM32F767VI FreeRTOS project with the STM32CubeMX in STM32CubeIDE (V1.0.2) rather than the standalone STM32CubeMX (V5.3.0). With this project the offending _sbrk function is in sysmem.c instead of syscalls.c.
Memory allocation in FreeRTOS tasks still fails with this function as is, and works with it renamed / deleted.
I still don't know whether the default _sbrk function (the one that gets used if the sysmem.c / syscalls.c one is renamed / deleted) along with heap_4.c is satisfactory, or whether a solution such as Dave Nadler's one (heap_useNewlib.c) is required.
ST, please advise.
2019-09-18 07:25 AM
Thank you, very useful info.
> I don't understand why the "<_sbrk>" is in such a bizarre place.
This looks like just an artifact of disassembly.
-- pa
2019-12-17 10:28 PM
Seems like the exact issue. This saved us lot of time.
2019-12-18 08:00 AM
If you expect malloc to work with FreeRTOS, use the code and options described on my web page:
2021-01-27 03:22 PM
Hi guys,
Maybe it can help someone with the same issue.
Just using
pvPortMalloc(size);
and
vPortFree(ptr);
works inside a thread with Heap 4 scheme.
Please read more at https://embeddedartistry.com/blog/2018/01/15/implementing-malloc-with-freertos/ .
Thank you.