cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS Heap - CubeMx Bug?

JAN R
Associate III

Dear,

In CubeMx I have 3 statically allocated tasks wit stack size 256 words for each one, and also I have some Heap for dynamic allocation.

My Question:

Why in Cube I can not set TOTAL_HEAP_SIZE for example to 1000 (for my dynamic allocation pvPortMalloc) and stacks with size 256? The TOTAL_HEAP_SIZE should not affect to stack size is not it?

Also you can check problem on short video there: https://www.youtube.com/watch?v=ookcCYnF4k4&feature=youtu.be

If I know statically allocated memory, by definition, does not come out of the heap. The amount of memory available for use as the heap is the total memory available, minus statically allocated memory (minus the .data section, etc.).

6 REPLIES 6

FreeRTOS dynamically-allocated stacks and pvPortMalloc come from single pool TOTAL_HEAP_SIZE.

static stacks etc. not from this pool.

Can you clarify your question??

Are you saying CubeMX doesn't work properly for this case?

Warning: Using heap via malloc-functions in FreeRTOS tasks with STM-provided sbrk function always fails (pvPortMalloc OK);

see http://www.nadler.com/embedded/newlibAndFreeRTOS.html

FCR
Associate III

​Hi,

Maybe just a reminder:

Meaning:

  • a total heap size of 1000 Bytes, is equivalent to 250 Words (of 32bits)
  • the stack size of a task then can only have a value between configMINIMAL_STACK_SIZE (frequently 128) and configTOTAL_HEAP_SIZE/4 (here 1000/4=250)

It may help in the current example.

Regards,

Fred

This is the main problem with ST's software developers - absolutely blatant incompetency.

Go learn what a "static allocation" means...

https://www.freertos.org/Static_Vs_Dynamic_Memory_Allocation.html

FCR
Associate III

​Sorry for my previous post, completely out of scope. My mistake.

For sure, what I wrote only applies to dynamic tasks, it should in fact, as it is not right now: CubeMx Is wrongly applying that limit linked to the heap size to static tasks, while it should not, as analysed in the original post of JAN R.

This is a bug to be corrected in the next CubeMx release.

Now You're acting like You should! =)

Though "statically allocated tasks" were among the first words in the first sentence of original post and "statically allocated memory" repeated twice further down...

JAN R
Associate III

Thank you very much,

Do you have any estimate for date of release next CubeMX?