errCOULD NOT ALLOCATE REQUIRED MEMORY

Hi,
Thank you very much for support and prompt reply.
I have created and tested few task successfully, but when I increased the number of task I am getting the below error.
errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY
I guess the required memory for all task is not sufficient.
At the initialization of first task the when “pvPortMalloc” gets call the xFreeBytesRemaining = 8184 as shown in fig, which gets reduced on each task initialization.

Can you please explain me the issue and its best possible solution?

when I just commented few of the task initialization it get stuck at

prefetchEntry
b prefetchEntry

What it means?

Capture

Regards,
Kishor

Any chance to increase configTOTAL_HEAP_SIZE in your FreeRTOSConfig.h accordingly (if you have enough RAM available) ? BTW you should also tell which heap implementation you’re using e.g. FreeRTOS heap_4.c.
Did you define configASSERT , enable stack overflow checking and maybe also configUSE_MALLOC_FAILED_HOOK along with an implementation of vApplicationMallocFailedHook for development/debugging ?

Thank you for reply,
How to check available RAM?
What is the recommended heap.c what’s the criteria for selecting?

Regards
Kishor

See here for information on the memory allocation scheme available and how to see how much heap remains: https://www.freertos.org/a00111.html You can also use functions such as RTOS - uxTaskGetSystemState() and uxTaskGetStackHighWaterMark() to see how much stack your tasks are actually using as you may be able to reduce their heap usage.

Its default heap size.
#define configTOTAL_HEAP_SIZE ( ( size_t ) 8192 )
os_heap_c is in use I hope this is what you wanted to know. In which kernekHeap is defined as below.
#pragma DATA_SECTION(ucHeap, “.kernelHEAP”)

Not sure what os_heap_c is, it’s not a file we provide, or at least if it is it has been renamed. Is it the file from Dave N linked to from this line: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/tasks.c#L309 - could you attach it to a post?

Yes sure please find the attachment.

os_heap.c (15.9 KB)

Regards,
Kishor

That looks like it is based of a really old version of heap_2.c. It has been modified to add in the #pragma you reference a few posts up. Did you put that in? In any case it looks like its intended to enable placing the heap at a location specified in a linker script. It still uses configTOTAL_HEAP_SIZE to dimension the heap.

Can I replaced it with any heap_x.c without any modification?
What is the max limit to configure total heap size? Can I put it as 50000?
#define configTOTAL_HEAP_SIZE ( ( size_t ) 8192 )

Regards,
Kishor

You should be able to switch to heap_4.c, but that won’t have the modification to get placed by the linker. The only limit on the heap size is the amount of RAM you have available.

I changed the heap size but now its getting stuck in “HL_sys_intvecs.asm” at below location.
prefetchEntry
b prefetchEntry

Can you please guide to fix it?
Regards,
Kishor

The available RAM is 4MB.

“won’t have the modification to get placed by the linker”
will it be an issue? Can I compare the current file with heap_4.c and fix it?

This looks like you should have set an interrupt. By default your interrupt is defined as a loop for ever:

prefetchEntry
       b prefetchEntry

Are you sure that the new heap space is all valid RAM?

Which chip are you using? It looks like you have hit a prefetch abort exception. How you debug that depends on your chip architecture.