<?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 Design StudioのトピックRe: heap and stack size</title>
    <link>https://community.nxp.com/t5/Kinetis-Design-Studio/heap-and-stack-size/m-p/470597#M5136</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi，&lt;/P&gt;&lt;P&gt;regarding to your comments,&lt;/P&gt;&lt;P&gt;for Heap:&lt;/P&gt;&lt;P&gt;no matter using or not using rtos, I suggest you NOT set heap size, even you think your code doesn't use malloc, it potentially called some low level system library functions that could use heap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for stack:&lt;/P&gt;&lt;P&gt;when use freeRTOS, the freeRTOS related codes are also part of project. the global variables and static variables&amp;nbsp; in freeRTOS are allocated in RAM; the local variables in freeRTOS are allocated in stack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;yes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jennie Zhang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 May 2016 09:29:37 GMT</pubDate>
    <dc:creator>ZhangJennie</dc:creator>
    <dc:date>2016-05-19T09:29:37Z</dc:date>
    <item>
      <title>heap and stack size</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/heap-and-stack-size/m-p/470594#M5133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to understand HEAP_SIZE&amp;nbsp; and STACK_SIZE in .ld file&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this file KDS find the RAM size&amp;nbsp; : 0x8000 for my KL17Z256VLH4 ; &lt;SPAN lang="en"&gt;why should we &lt;SPAN&gt;specify&lt;/SPAN&gt; KDS the size of stack and head&lt;SPAN&gt; ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&amp;gt;&amp;gt; Why compiler&lt;/SPAN&gt; and linker can not work with just the RAM &lt;SPAN&gt;size ? (&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN&gt;to optimize &lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN&gt;its use)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="almost_half_cell" style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV dir="ltr"&gt;&lt;SPAN class="short_text" lang="en"&gt;&amp;gt;&amp;gt; Is there a risk &lt;SPAN&gt;in defining &lt;/SPAN&gt;&lt;SPAN&gt;stack&lt;/SPAN&gt; &lt;SPAN&gt;and&lt;/SPAN&gt; &lt;SPAN&gt;heap to the maximum RAM size ? &lt;SPAN class="short_text" lang="en"&gt;if so, &lt;SPAN&gt;what is the mistake &lt;/SPAN&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV dir="ltr"&gt; &lt;/DIV&gt;&lt;DIV dir="ltr"&gt;&lt;P&gt;&lt;SPAN class="short_text" lang="en"&gt;/*for my KL17Z256*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;HEAP_SIZE&amp;nbsp; = DEFINED(__heap_size__)&amp;nbsp; ? __heap_size__&amp;nbsp; : 0x8000; /* defaut&amp;nbsp; 0x0400*/&lt;/P&gt;&lt;P&gt;STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x8000; /* defaut 0x0400*/&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* 0x8000 = RAM size */&lt;/P&gt;&lt;/DIV&gt;&lt;DIV dir="ltr"&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use Freertos (with en other heap specification : configTOTAL_HEAP_SIZE)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your &lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN&gt;explanations&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2016 17:01:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/heap-and-stack-size/m-p/470594#M5133</guid>
      <dc:creator>PO220</dc:creator>
      <dc:date>2016-05-13T17:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: heap and stack size</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/heap-and-stack-size/m-p/470595#M5134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it's necessary to allocate max heap and stack size in a project beforehand.&lt;/P&gt;&lt;P&gt;because:&lt;/P&gt;&lt;P&gt;stack is needed to allocate function parameters, local variables,etc&lt;/P&gt;&lt;P&gt;heap is needed if using mallo() to apply a memory.&lt;/P&gt;&lt;P&gt;global variables and static variables are allocate in RAM (not stack space, neither heap).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;normally a project (including called system files) need to use stack and heap anyway, so it's necessary to allocate them in linker file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jennie Zhang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 May 2016 10:07:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/heap-and-stack-size/m-p/470595#M5134</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2016-05-16T10:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: heap and stack size</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/heap-and-stack-size/m-p/470596#M5135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thank for your answer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;I understand &lt;SPAN&gt;a little better&lt;/SPAN&gt; since Friday and you end &lt;SPAN&gt;make me understand (I hope !)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm right ? :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Heap :&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;1&amp;gt;&amp;gt;When using FreeRTOS (I don't use malloc apart from freertos) the&lt;SPAN lang="en"&gt; &lt;SPAN&gt;heap&lt;/SPAN&gt; &lt;SPAN&gt;necessary&lt;/SPAN&gt; is that required &lt;SPAN&gt;by&lt;/SPAN&gt; &lt;SPAN&gt;FreeRTOS&lt;/SPAN&gt; &lt;SPAN&gt;only. (I can use &lt;SPAN style="font-family: Arial;"&gt;xPortGetFreeHeapSize() to optimise this)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;As freertos use malloc to allocate task stack, heap need to be large for a freertos application&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;2&amp;gt;&amp;gt; I&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="short_text" lang="en"&gt;f not using malloc or FreeRTOS ; heap can be set to zero (no dynamic allocation)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN lang="en"&gt;Stack :&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;3&amp;gt;&amp;gt;With freertos i need just allocate stack for &lt;SPAN class="short_text" lang="en"&gt;some variables that are outside FreeRTOS. The not stack or heap&amp;nbsp; space must be allocate for &lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;some global or static variables that are outside FreeRTOS.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;4&amp;gt;&amp;gt;Without FreeRTOs. I need to allocate the largest Stack, with just enough RAM (&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;not stack space, neither heap) for &lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;global or static variables.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="short_text" lang="en"&gt;5&amp;gt;&amp;gt; In any case I need to leave space in RAM for startup vector table copy.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm right ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 May 2016 10:49:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/heap-and-stack-size/m-p/470596#M5135</guid>
      <dc:creator>PO220</dc:creator>
      <dc:date>2016-05-16T10:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: heap and stack size</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/heap-and-stack-size/m-p/470597#M5136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi，&lt;/P&gt;&lt;P&gt;regarding to your comments,&lt;/P&gt;&lt;P&gt;for Heap:&lt;/P&gt;&lt;P&gt;no matter using or not using rtos, I suggest you NOT set heap size, even you think your code doesn't use malloc, it potentially called some low level system library functions that could use heap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for stack:&lt;/P&gt;&lt;P&gt;when use freeRTOS, the freeRTOS related codes are also part of project. the global variables and static variables&amp;nbsp; in freeRTOS are allocated in RAM; the local variables in freeRTOS are allocated in stack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;yes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jennie Zhang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 09:29:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/heap-and-stack-size/m-p/470597#M5136</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2016-05-19T09:29:37Z</dc:date>
    </item>
  </channel>
</rss>

