cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
fltr
Visitor
Visitor
10,262 Views
Registered: ‎05-19-2016

FreeRTOS and Heap and Memory Management

Jump to solution

Hi at all,

 

The Question:

What is the best way to configure the heap and stack sizes with FreeRTOS, or better should the HEAP size from the linker script should match the "total_heap_size" setting of FreeRTOS BSP?

Does FreeRTOS use the declared heap or, lets say its own?

 

Greatings,

Flo

Tags (3)
1 Solution

Accepted Solutions
richardbarry
Observer
Observer
16,738 Views
Registered: ‎04-26-2008

If you are using the SDK to create a FreeRTOS BSP on a Zynq then it is likely you are building heap_4.c, in which case the heap used by FreeRTOS is a char array that is dimensioned by the total_heap_size setting (which sets the side of the configTOTAL_HEAP_SIZE constant in the generated FreeRTOSConfig.h).  As this char array is statically declared inside heap_4.c it is not dependent on the heap setting in the linker script.  In fact, unless your application or another library is calling malloc(), you don't need the linker to create a heap at all. Memory is allocated from the heap declared in heap_4.c using pvPortMalloc() and freed again using vPortFree() - both functions have the same semantics as the standard library malloc() and free().

 

See http://www.freertos.org/a00111.html for more information.

 

Regards,
Richard.

+ http://www.FreeRTOS.org
The de facto standard, downloaded every 4.2 minutes during 2015.

+ http://www.FreeRTOS.org/plus
IoT, Trace, Certification, TCP/IP, FAT FS, Training, and more...

View solution in original post

2 Replies
richardbarry
Observer
Observer
16,739 Views
Registered: ‎04-26-2008

If you are using the SDK to create a FreeRTOS BSP on a Zynq then it is likely you are building heap_4.c, in which case the heap used by FreeRTOS is a char array that is dimensioned by the total_heap_size setting (which sets the side of the configTOTAL_HEAP_SIZE constant in the generated FreeRTOSConfig.h).  As this char array is statically declared inside heap_4.c it is not dependent on the heap setting in the linker script.  In fact, unless your application or another library is calling malloc(), you don't need the linker to create a heap at all. Memory is allocated from the heap declared in heap_4.c using pvPortMalloc() and freed again using vPortFree() - both functions have the same semantics as the standard library malloc() and free().

 

See http://www.freertos.org/a00111.html for more information.

 

Regards,
Richard.

+ http://www.FreeRTOS.org
The de facto standard, downloaded every 4.2 minutes during 2015.

+ http://www.FreeRTOS.org/plus
IoT, Trace, Certification, TCP/IP, FAT FS, Training, and more...

View solution in original post

fltr
Visitor
Visitor
10,158 Views
Registered: ‎05-19-2016

Ah great, I understand. Thanks for this detailed answer.

0 Kudos