Am I running out of memory?

colingd wrote on Tuesday, June 12, 2018:

Hi all,

So I ported FreeRTOS. Tested the tick frequency with an oscilloscope. All fine but it seems I still have something to figure out.
I’m trying to test the demos found in the common directory. I’m taking for reference the official port to AT91SAM9XE. There are good news. All the demos work perfectly one running on their own. Then I have them run concurrently it seems the I’m running out of memory when vTaskStartScheduler is called.
The main starts by calling the functions that start the demos, creates a task that checks that the other tasks are runing and starts the scheduler.
I’m trying to debug this and when I call vTaskStartScheduler it will get stuck here eventually :
814 xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;; in the task.c file.
I’m using heap_2.c .
And you can have a look at my repo here : https://gitlab.in2p3.fr/colingd/freertos-template

Thanks in advance!

Colin

rtel wrote on Tuesday, June 12, 2018:

Yes, it would seem you are running out of memory.

If you are using heap_2 then the amount of heap you have is defined by
configTOTAL_HEAP_SIZE. You can set that up until your application will
no longer link, the you know how much total heap you have. Be careful
to also remove any heap that is being allocated by your C run time (the
heap that is used when malloc() is called instead of pvPortMalloc()) -
otherwise it will just consume space that is never used.

You can then look at tuning the sizes of the stacks allocated to the
tasks. You can use the API or kernel aware plug-ins to see how much
task stack remains unused, and tune accordingly.

colingd wrote on Wednesday, June 13, 2018:

Mr. Barry,

Thanks for answering! The answer nows seems obvious, I should have been more careful whilst reading the documentation and known better. I will look into this. However, the demo now works! I tried to publish my repo link to freertos interactive but I’m having issues with logging in freertos interactive.

Thanks for your time, it is greatly appreciated!

Colin González