cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 can't create second FreeRTOS task.

Frak.1
Associate II

Hi,

I'm using STM32H745 and CM4 core runs with RTOS. I am not able to create the second task because xtaskcreate() does not return pdPASS. It seems like it can't allocate enough memory. I tried to create 2 tasks with stack depth equal to 1024. If I reduced the size to 2x 512, the task runs properly.

What is the reasons of this behavior? The stack is too small? Can I somehow fix this behaviour and create more tasks?

Ragards,

7 REPLIES 7
MM..1
Chief II

How is your HEAP SIZE in rtos conf ? You need increase it ...

the configTOTAL_HEAP_SIZE in FreeRTOSConfig.h is defined as ((size_t)15360).

MM..1
Chief II

We can help quick when you show code, have you default task + 2? When yes how size is defalt task stack ?

Set TOTAL%HEAP to 32768 dont help ?

???

Frak.1
Associate II

I have default task that starts other tasks and then it is deleted. The stack of the default task is 512. I tried to start 2 taks with 1024 inside the default task. I will try to increase total heap size but it seems to be enough for this 2 tasks.

MM..1
Chief II

Im not expert on rtos, but idea create task in other task after osStart and then delete creator task is maybe source of your troubles.

My usag eis exactly in main prepare all tasks, then start OS , and leave all task do jobs.

Frak.1
Associate II

It can't be. It is common used technique to keep your code clean when you have to start a lot of tasks.

I debug more deeply and I realized that I'm going out of the defined total heap sized as you said. I didn't expect this behavior because on the nucleo-f103rb the total heap was defined much less and everything worked fine. On stm32h7 even 15360 for 2 task 1024 is not enough. This problem is fixed but unfortunatelly that core hangs somewhere where I am trying to take semaphore. After reducing stack size again to 512 everything start working fine.

For now thanks for your engagement.

Ragards,

Heap size is in bytes when i right rememmber, and stack is words 32 then two task with 1024 need 8192 bytes HEAP, but as you say , dynamic creating tasks is possible, but need clean release resources. Maybe bug or bad setup rtos, but i dont help with this.😎