rtel wrote on Monday, October 08, 2018:
Sorry to hear you are having troubles. First I can confirm that, as a
general rule of thumb, you should not call FreeRTOS kernel API functions
that can block while the scheduler is either suspended or you are in a
critical section. That is to prevent logic errors - if a function needs
to block because, for example, you are reading from a queue with a block
time but the queue is empty then a context switch must be allowed to
happen otherwise the queue read function will return without either
timing out or receiving date.
Normally the C library malloc() and free() would only be used if you are
using other third party libraries that are using these functions,
otherwise heap_4.c is the preferred memory allocater
(https://www.freertos.org/a00111.html ). If you need to use the stand
library heap then you can use heap_3.c, which wraps the standard library
malloc() and free() to make them thread safe (somewhat crudely), and
then you can direct malloc() to pvPortMalloc() and free() to vPortFree()
(see the link already posted).
I’m not sure what configUSE_NEWLIB_MALLOC_LOCK does - I searched the
kernel source files and can’t find a reference to it.