Task rpmsg on freertos firmware

Hi, i have a software in FreeRTOS running in M4 with ten tasks, but i have a problem with the rpmsg task. When i active only four tasks (rpmsg task and other three with any priority) it works, but when i active my ten tasks, all tasks works well except the rpmsg task. So the problem isnt the priority is the number of tasks and i dont know the reason.

My rpmsg task its based on the example rpmsg_echo_rtos. Maybe i should change some parameter or define??

Thank you, for your help.

Regars, Victor.

Dear @vmoya

You are probably running out of memory:

Available heap memory:

The heap size is configured in the linker configuration file. Which exact linker file is taken depends on your project setup. For me it is:


which defines

/* Sizes */
#if (defined(__stack_size__))
  #define Stack_Size                   __stack_size__
  #define Stack_Size                   0x0400

#if (defined(__heap_size__))
  #define Heap_Size                    __heap_size__
  #define Heap_Size                    0x0400

Required heap memory

There’s a lot of configuration options in FreeRTOS, but typically each task’s stack is allocated on the heap. If you trace into xTaskCreate(), you find the following call stack:

Here you see that the task’s stack is allocated on the heap.

By default, each task allocates 256 Bytes of task-stack (which is located on the heap), and only 1024 bytes of heap are available, so it is sufficient for exactly 4 tasks.


  1. You can increase the total available heap size in the linker configuration fiel (see above), or
  2. You can reduce the stack depth of individual tasks. The task depth is a parameter you provide when calling xTaskCreate()

A colleague of mine told me that he also had to increase the available stack size in the linker configuration file, but I did not find a simple explanation, why this should be required.

Regards, Andy

Hi, i was trying your solutions. i’m using the the next linker because our firmware is store in ddr memory: …\platform\devices\MCIMX7D\linker\gcc\MCIMX7D_M4_ddr.ld

We got 10 tasks with 256 Words for the stack depth of each task so i tried with this modification:

HEAP_SIZE = DEFINED(heap_size) ? heap_size : 0x0A00;

STACK_SIZE = DEFINED(stack_size) ? stack_size : 0x0400;

and my tasks doesn’t work, so i tried modifiying the stack size too like your colleague said you:

HEAP_SIZE = DEFINED(heap_size) ? heap_size : 0x0A00;

STACK_SIZE = DEFINED(stack_size) ? stack_size : 0x0A00;

and my tasks doesn’t work again. In our program the stack depth is in words, by deafult 256 words, maybe this is an important thing too. The stack and heap size is in words too??.

I was trying with less heap and stack size like 0x0800, and the result is the same. Maybe we should change another parameter like the maximun heap or stack size??

Related with the second solution, we tried reducing the size of individual tasks, for example, 128 Words, and it works partially, because some tasks doesn’t work. So we prefer to keep the size of the tasks to 256 words.

An important thing is that we only have problems with the rpmsg task because nine tasks (256 Words) with 0x400 in the linker file (stack size and heap size) works well. And with rpmsg task we got the problem.

Thank you for your help Andy.

Regards, Victor.

Dear @vmoya

Memory sizes in the linker file are given in Bytes. So it is still possible that you get a memory problem.
As you are using DRAM anyway, why not simply increasing heap and stack size massively (e.g. to 0xFFF0) at least for a test, so you can be sure that the problem is not related to a stack overflow.

If the problem persists, can you send me your project, so I could try to reproduce the problem here?

Regards, Andy

Dear @andy.tx

Working with 9 tasks + rpmsg task, we tried increasing heap ans stack size massively and doesn’t work. We checked reducing the individual size of the tasks and it’s work. But we want to keep the default task size.

Working with 9 tasks, we tested with 0x0400 for the heap and stack size and all it’s right. Obviusly 0x400 (1024 Bytes) is less than 9 x 256 Words. The parameters doesn`t have influence in our project and we don’t know the reason. We checked the map and it’s true that we are modifying the heap and stack in the project.

So, we think that we have a memory problem but only affect when rpmsg task is running. Do you know if we can check any parameter related with this task?

If we can’t find the solution, we can try to send you the project, but we need to change some things for confidentiality.

Thank you again.

Regards, Victor.

Depending on the heap configuration (e.g, heap_3) the parameters HEAP_SIZE and STACK_SIZE have no effect on the FreeRTOS heap (from where the stack for each task is allocated). Try to increase configTOTAL_HEAP_SIZE instead.

Hi @qojote

I have:

#define configTOTAL_HEAP_SIZE             ((size_t)(20 * 1024))

I think it’s enaugh but i will test increasing

Thank you.

Regards, victor.

Dear @qojote
You could also try to activate stack overflow checking in FreeRTOS.
Regards, Andy

It’s solved! I increased the configTOTAL_HEAP_SIZE from 20kB to 50kB and all tasks are working!

Thank you for your help.

Regards, Victor.