EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: marcelogadotti on April 01, 2019, 02:56:42 pm

Title: Error when using vPortFree(ptr) CMSIS-RTOS on STM32F4
Post by: marcelogadotti on April 01, 2019, 02:56:42 pm
I will need to handle dynamic memory using malloc and free. Looking on FreeRTOS documentation, I found pvPortMalloc(size) and vPortFree(ptr) , pvPortMalloc(size) works fine. When try to release memory using vPortFree(ptr) inside a Thread, the code hangs on that call.

I'm using heap_4 for CMSIS-RTOS on TrueStudio.
Title: Re: Error when using vPortFree(ptr) CMSIS-RTOS on STM32F4
Post by: ehughes on April 01, 2019, 11:13:34 pm
Is the pointer you are freeing NULL?     Did you single step to see what is happening?   You have the source code so it should be pretty straight forward.

Also,   I am not sure what the CMSIS layer does with freeRTOS but it is only an API layer.   There might be some goofiness going on here.  (I would not recommend using an API layer, it is generally a waste).

Lastly,  what are you FreeRTOS config settings?

Title: Re: Error when using vPortFree(ptr) CMSIS-RTOS on STM32F4
Post by: marcelogadotti on April 02, 2019, 05:20:23 pm
I did solve the problem, it happens when increment the pointer and try to free after this operation.