2020-08-06 11:34 AM
Hello!
Stm32CubeIde generated _sbrk(int incr) function for me. Also I need to use FreeRtos.
_sbrk checks heap not to overcome stack pointer.
if (heap_end + incr > stack_ptr)
{
errno = ENOMEM;
return (caddr_t) -1;
}
But FreeRtos allocates stacks for every task from the heap. So eventually some stack pointer of a task that is going to allocate memory, will be smaller than the heap_end.
I know how to deal with it. But as this file is auto-generated, I ask you to repair this in the next releases of Stm32CubeIDe.
I use stm32F22RET6 MCU.
Stm32CubeIde 1.4.0
2020-08-06 12:37 PM
> Is _sbrk generated by stm32cubeide incompatible with FreeRtos?
Yes, unless something has changed with a recent version:
2020-08-06 02:42 PM
You see, neither sbrk nor mallloc and its friends are part of FreeRTOS API.
FreeRTOS has its own allocation functions.
So you actually request ST to provide integration of FreeRTOS with the C library (newlib) malloc.
-- pa
2020-08-07 01:19 AM
Pavel,
The realization of sbrk in Stm32CubeIde is a copy from newlib doumentation. https://sourceware.org/newlib/libc.html#index-sbrk
So it can be considered to be integrated with newlib per the documentation. :)
But it doesn't help when you deal with FreeRtos.
2020-08-07 01:25 AM
TDK,
Thank you for reference!