06-06-2016 10:33 PM
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.
06-07-2016 09:31 AM
06-07-2016 10:04 AM
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