We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Showing results for 
Search instead for 
Did you mean: 
Participant sjg69
Registered: ‎03-29-2012

FreeRTOS heap vs linker script heap

So, I'm running RHEL7 / Vivado 2016.1 SDK on a ZC706 board, and I've configured my stack to be 32MB, and my heap to be 512MB in the linker script, leaving some of the 1GB  left over for other things.


When I launch the main thread in main.c, vis...


        sys_thread_new("main_thrd", (void(*)(void*))main_thread, 0, 65536, DEFAULT_THREAD_PRIO);



... I run into the vApplicationMallocFailedHook() printf() which seems to indicate I'm not getting anywhere close to my desired stack/heap, so, question: Is there *any* relationship between the freeRTOS heap and the linker-script heap ?


Looking at FreeRTOSConfig.h in the libsrc/... directory tree, I can see 


        #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 65536 ) )


.. which would explain things, so do I have to change this to 512MB as well ? If I do so, does the right malloc() (or sbrk() I guess) automatically get called so I'm using the same 512MB of data I originally wanted to, or will different calls to malloc() fight over the heap space ?


Clearly, the 512MB heap request isn't being respected atm, so ought I just configure it in FreeRTOSConfig.h and forget about the one in the linker script ?


I guess I'm asking what's the best practice for malloc() when you're running FreeRTOS and want to allocate a lot of RAM for images etc.







0 Kudos
2 Replies
Participant sjg69
Registered: ‎03-29-2012

Re: FreeRTOS heap vs linker script heap

So, boosting the heap configure in the MSS file stopped my app from crashing - I'd still like some clarity over what the relevance of the linker-script parameters are, when using freeRTOS though, if possible.
0 Kudos
Observer richardbarry
Registered: ‎04-26-2008

Re: FreeRTOS heap vs linker script heap

It depends on which heap_n.c file you are using.  If you are using heap_3.c or heap_5.c then configTOTAL_HEAP_SIZE will not have any effect.  If you are generating your project using the SDK then you will most likely be using heap_5.  See the following link for more information and explanation.  http://www.freertos.org/a00111.html




+ 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...