<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Kinetis Software Development KitのトピックRe: Memory allocation error as we create multiple FreeRTOS tasks with Processor Expert in KSDK 1.3 for MKL25Z128</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478522#M4064</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco,&lt;/P&gt;&lt;P&gt;I increased the heap size as Daniel suggest but also did a few other things you might be interested in.&lt;/P&gt;&lt;P&gt;I had debugged the code and memory map to see that the FreeRTOS application is using the HEAP for alloc/free (heap_3.c) operations.&amp;nbsp; With the default Stack and Heap sizes, the Heap was crossing the two SRAM block boundary of 0x2000_0000.&amp;nbsp; This can cause issue is an access occurs across the boundary.&amp;nbsp; Also the Stack wasn't really be used much.&amp;nbsp; So I increased Heap and decreased Stack size.&lt;/P&gt;&lt;P&gt;I adjusted the heap and stack size in the PE CPU Component -&amp;gt; Build options tab as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/22759i64140BBCE7F72C6B/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Heap still had issue of crossing the SRAM boundary so after generating the linker file, I then un-checked the "Generate linker file" in the Build options tab and then modified the ProcessorExpert.ld linker file as shown below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; .stack :&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . += STACK_SIZE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; } &amp;gt; m_data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; .heap :&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(0x20000000);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __end__ = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROVIDE(end = .);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __HeapBase = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . += HEAP_SIZE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __HeapLimit = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp; } &amp;gt; m_data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This modification switched the Heap and Stack memory map locations so the "small" .stack was below 0x2000_0000 and .heap started at 0x2000_0000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then was able to add in more OS_Task and play around with increasing the stack size for them and get them to successfully run.&lt;/P&gt;&lt;P&gt;I learned that just initializing FreeRTOS before creating any user tasks uses up 2880 bytes (assuming I calculated correctly).&amp;nbsp; This leaves about 9400 bytes for user.&lt;/P&gt;&lt;P&gt;The overhead hidden tasks are IDLE, TmrSvc, along with their respective TCB structures.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached my modified version of the project for you.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 May 2016 18:56:13 GMT</pubDate>
    <dc:creator>DavidS</dc:creator>
    <dc:date>2016-05-18T18:56:13Z</dc:date>
    <item>
      <title>Memory allocation error as we create multiple FreeRTOS tasks with Processor Expert in KSDK 1.3 for MKL25Z128</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478519#M4061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;Hello, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;My customer is beginning a new project with MKL25Z128VLH4. The IDE used is KDS 3.x, KSDK 1.3 and he is using FreeRTOS. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;We both are new to FreeRTOS, so we are still facing some difficulties during this learning process. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;He created two tasks of same priority level through Processor Expert. For a test, we just increment two global variables. As we debug the project, we see that Task 1 is created, but Task 2 is not. Going&amp;nbsp; in deeper debugging, we found out that Task creation function returns a memory allocation error. If we increase the tasks stacks sizes from 1024 to 2048, not even Task 1 is created.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;When we decreased stacks sizes from 1024 to 512, both tasks run, but if we created the third task, this last one are not created, and returns the error I commented above.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;We don't know where we went wrong.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;I have attached our project for analysis. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;Thanks and best regards, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;Marco Coelho &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;Applications Engineer &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirLTStdLight, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;Siletec Eletronica&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-338771"&gt;teste7.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 21:18:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478519#M4061</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2016-05-17T21:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Memory allocation error as we create multiple FreeRTOS tasks with Processor Expert in KSDK 1.3 for MKL25Z128</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478520#M4062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco Coelho:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you need to increase the the heap size to a higher value.&lt;/P&gt;&lt;P&gt;You can change the value in this file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;teste7\teste7\Project_Settings\Linker_Files\ProcessorExpert.ld&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HEAP_SIZE&amp;nbsp; = DEFINED(__heap_size__)&amp;nbsp; ? __heap_size__&amp;nbsp; : 0x1000;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;change to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HEAP_SIZE&amp;nbsp; = DEFINED(__heap_size__)&amp;nbsp; ? __heap_size__&amp;nbsp; : 0x2000;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it will solve your issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 08:24:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478520#M4062</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2016-05-18T08:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Memory allocation error as we create multiple FreeRTOS tasks with Processor Expert in KSDK 1.3 for MKL25Z128</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478521#M4063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are correct, Daniel!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I lowered even more all tasks stacks sizes and increased the total heap size and everything is working now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; But I don't understand. When main_task stack size was 1024 bytes and the other three tasks stacks sizes were 512 bytes each, the third task was not created, because it could not allocate memory for it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; By my count, if total stack size is set to 0x1000 and the stack consumed by the tasks is 2560 bytes, we would still have 1536 bytes left, right? So, why the third task got out of memory allocation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; What is the heap for? Does it take RAM memory as the stack? What is the difference between heap and stack?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to know exactly how much each task is taking from RAM and Flash memory and how much is left?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thank you very much for your attention!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BIG&gt;Marco Aurelio P. Coelho&lt;/BIG&gt;&lt;/P&gt;&lt;P&gt;&lt;BIG&gt; Applications Engineer&lt;/BIG&gt;&lt;/P&gt;&lt;P&gt;&lt;BIG&gt; Siletec Eletronica&amp;nbsp; &lt;/BIG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 17:51:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478521#M4063</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2016-05-18T17:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Memory allocation error as we create multiple FreeRTOS tasks with Processor Expert in KSDK 1.3 for MKL25Z128</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478522#M4064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco,&lt;/P&gt;&lt;P&gt;I increased the heap size as Daniel suggest but also did a few other things you might be interested in.&lt;/P&gt;&lt;P&gt;I had debugged the code and memory map to see that the FreeRTOS application is using the HEAP for alloc/free (heap_3.c) operations.&amp;nbsp; With the default Stack and Heap sizes, the Heap was crossing the two SRAM block boundary of 0x2000_0000.&amp;nbsp; This can cause issue is an access occurs across the boundary.&amp;nbsp; Also the Stack wasn't really be used much.&amp;nbsp; So I increased Heap and decreased Stack size.&lt;/P&gt;&lt;P&gt;I adjusted the heap and stack size in the PE CPU Component -&amp;gt; Build options tab as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/22759i64140BBCE7F72C6B/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Heap still had issue of crossing the SRAM boundary so after generating the linker file, I then un-checked the "Generate linker file" in the Build options tab and then modified the ProcessorExpert.ld linker file as shown below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; .stack :&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . += STACK_SIZE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; } &amp;gt; m_data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; .heap :&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(0x20000000);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __end__ = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROVIDE(end = .);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __HeapBase = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . += HEAP_SIZE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __HeapLimit = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp; } &amp;gt; m_data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This modification switched the Heap and Stack memory map locations so the "small" .stack was below 0x2000_0000 and .heap started at 0x2000_0000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then was able to add in more OS_Task and play around with increasing the stack size for them and get them to successfully run.&lt;/P&gt;&lt;P&gt;I learned that just initializing FreeRTOS before creating any user tasks uses up 2880 bytes (assuming I calculated correctly).&amp;nbsp; This leaves about 9400 bytes for user.&lt;/P&gt;&lt;P&gt;The overhead hidden tasks are IDLE, TmrSvc, along with their respective TCB structures.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached my modified version of the project for you.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 18:56:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478522#M4064</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2016-05-18T18:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Memory allocation error as we create multiple FreeRTOS tasks with Processor Expert in KSDK 1.3 for MKL25Z128</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478523#M4065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may also consider using one of the heap implementations provided by freertos (particularly heap_4). Another tip is to use the FreeRTOS PX component published by MCUOnEclipse which allows for heap configuration via the component inspector like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Screen Shot 2016-05-18 at 6.00.15 PM.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/22673iE0BDC7DFF59408F7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2016-05-18 at 6.00.15 PM.png" alt="Screen Shot 2016-05-18 at 6.00.15 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://sourceforge.net/projects/mcuoneclipse/files/PEx%20Components/" title="https://sourceforge.net/projects/mcuoneclipse/files/PEx%20Components/"&gt;McuOnEclipse - Browse /PEx Components at SourceForge.net&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://mcuoneclipse.com/2015/07/08/tutorial-using-processor-expert-and-freertos-with-kinetis-sdk-v1-2/" title="https://mcuoneclipse.com/2015/07/08/tutorial-using-processor-expert-and-freertos-with-kinetis-sdk-v1-2/"&gt;https://mcuoneclipse.com/2015/07/08/tutorial-using-processor-expert-and-freertos-with-kinetis-sdk-v1-2/&lt;/A&gt;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 01:06:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478523#M4065</guid>
      <dc:creator>jacobjennings</dc:creator>
      <dc:date>2016-05-19T01:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Memory allocation error as we create multiple FreeRTOS tasks with Processor Expert in KSDK 1.3 for MKL25Z128</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478524#M4066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much, Jacob!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fantastic support! I tested your example and it is working fine now!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you just told me is a kind of bug or it is a feature of FreeRTOS KSDK library? Because we just made a test in CodeWarrior&amp;nbsp; 10 with MQX-Lite and this problem never happens and all this adjustment is not necessary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You taught me some more things I didn't know about FreeRTOS. I must confess I have too much to learn yet! So does the customer. I and the customer are still beginners in FreeRTOS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please&amp;nbsp; answer me some more questions that came to my mind?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noticed you kept the same stack size (512 bytes) as you first set in Processor Expert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you create a new task and set its stack size, this stack actually consumes heap and not stack from RAM memory?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't have words to thank you for your attention and help! I really appreciate it!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco Coelho&lt;/P&gt;&lt;P&gt;Applications Engineer&lt;/P&gt;&lt;P&gt;Siletec Eletronica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 15:05:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478524#M4066</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2016-05-19T15:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Memory allocation error as we create multiple FreeRTOS tasks with Processor Expert in KSDK 1.3 for MKL25Z128</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478525#M4067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco,&lt;/P&gt;&lt;P&gt;Correct me if wrong but I think you directed the questions to me (David)?&lt;/P&gt;&lt;P&gt;Assuming so my answers are below.&amp;nbsp; If I am wrong then stop reading and wait for Jacob to reply ;-)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not expert with FreeRTOS but learning everyday.&amp;nbsp; Glad to have helped and look forward to more.&amp;nbsp; Answers to the best of my ability follow:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Q1) What you just told me is a kind of bug or it is a feature of FreeRTOS KSDK library? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A1) Think more of a feature.&amp;nbsp; 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.&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;Q2) I noticed you kept the same stack size (512 bytes) as you first set in Processor Expert.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;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?&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;A2) FreeRTOS with heap_3 configuration is using the heap to alloc/free memory for the RTOS.&amp;nbsp; So as tasks are created, then request memory from the heap to use for tasks stacks and other resources.&amp;nbsp; 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.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;Q3) When you create a new task and set its stack size, this stack actually consumes heap and not stack from RAM memory?&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;A3) Correct!&amp;nbsp; But this is for the heap_3 case and I haven't played with the other heap options so they may differ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;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?&lt;/P&gt;&lt;P&gt;A4) &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Great question.&amp;nbsp; It really has been done by blood/sweat/tears and experimentation by setting stack size high to start and reducing it later to optimize.&amp;nbsp; Future tools will help to visually do this.&amp;nbsp; &lt;/SPAN&gt;&lt;A href="https://mcuoneclipse.com/2016/05/18/nxp-ftf-hands-on-with-freertos-task-aware-debugger/" style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Reference this great post (and sign up for it).&lt;/A&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;P&gt;PS&lt;/P&gt;&lt;P&gt;Another post to keep eye on: &lt;A href="https://community.nxp.com/thread/394196"&gt;heap and stack size&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 15:43:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478525#M4067</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2016-05-19T15:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Memory allocation error as we create multiple FreeRTOS tasks with Processor Expert in KSDK 1.3 for MKL25Z128</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478526#M4068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, my! I'm so sorry, David!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I comitted a mistake and I have to be fair.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My intention was directing my reply to you, David and not to Jacob! But I'd like to take the opportunity to thank you, Jacob for your tip!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider that my last message is directed to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really appreciate your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco Coelho&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 19:29:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Memory-allocation-error-as-we-create-multiple-FreeRTOS-tasks/m-p/478526#M4068</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2016-05-19T19:29:48Z</dc:date>
    </item>
  </channel>
</rss>

