Hi Marco,
Correct me if wrong but I think you directed the questions to me (David)?
Assuming so my answers are below. If I am wrong then stop reading and wait for Jacob to reply ;-)
I am not expert with FreeRTOS but learning everyday. Glad to have helped and look forward to more. Answers to the best of my ability follow:
Q1) What you just told me is a kind of bug or it is a feature of FreeRTOS KSDK library?
A1) Think more of a feature. As the PE and KSDK team create and test they are doing the best they can and probably assume that if the tools/examples work for a larger device (K64 with 1MB flash and 256KB SRAM) then they should scale and work with smaller memory devices. In your case with KL25 is pretty SRAM constrained and think the memory map needed the tweaks I added to make it work more reliably. But I will ask our team to review and see if they might take this tweak into consideration.
Q2) I noticed you kept the same stack size (512 bytes) as you first set in Processor Expert.
What is the difference between heap and stack? I noticed that the sum of heap and stack sizes must not surpass the total RAM size, right?
A2) FreeRTOS with heap_3 configuration is using the heap to alloc/free memory for the RTOS. So as tasks are created, then request memory from the heap to use for tasks stacks and other resources. I think the stack (512) is only used for getting system started but I am not 100% sure and need to dig into this myself.
Q3) When you create a new task and set its stack size, this stack actually consumes heap and not stack from RAM memory?
A3) Correct! But this is for the heap_3 case and I haven't played with the other heap options so they may differ.
Q4) How can I manage all this to know how much heap and stack each task is consuming and how much stack I must set in the tasks creation?
A4) Great question. It really has been done by blood/sweat/tears and experimentation by setting stack size high to start and reducing it later to optimize. Future tools will help to visually do this. Reference this great post (and sign up for it).
Regards,
David
PS
Another post to keep eye on: heap and stack size