<?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>topic Re: K60 RAM allocation issue when adding a thread in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188182#M2093</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kevin,&lt;/P&gt;&lt;P&gt;one explanation could be that your task uses a lot of RAM.&lt;/P&gt;&lt;P&gt;Could you check the RAM allocations in map-file.&lt;/P&gt;&lt;P&gt;~Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Dec 2011 01:36:27 GMT</pubDate>
    <dc:creator>MarkP_</dc:creator>
    <dc:date>2011-12-08T01:36:27Z</dc:date>
    <item>
      <title>K60 RAM allocation issue when adding a thread</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188181#M2092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I started with the TWR-K60N512_Quick_Start_Demo. I added a thread to TASK_TEMPLATE_STRUCT MQX_template_list:&lt;/P&gt;&lt;P&gt;&amp;nbsp; { MC_TIME_TASK,&amp;nbsp; time_task,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 800,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "mcTime",&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 },&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Doing this causes MQX to "blow up" and restart when _mqx() calls:&lt;/P&gt;&lt;P&gt;&amp;nbsp;_mem_zero((pointer)kernel_data, (_mem_size)sizeof(KERNEL_DATA_STRUCT));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Investigation shows that before I add the thread to MQX_template_list, kernel_data is at address 0x1FFF0960-0x1FFF0C80. After I add the thread, kernel_data is at address 0x2000FEF0-0x20010210. There is no RAM past 0x2000FFFF.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before adding thread:&lt;/P&gt;&lt;P&gt;MQX_init_struct -&amp;gt; START_OF_KERNEL 0x1FFF0960&lt;/P&gt;&lt;P&gt;MQX_init_struct -&amp;gt; END_OF_KERNEL &amp;nbsp; &amp;nbsp; 0x2000FFF0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After adding thread:&lt;/P&gt;&lt;P&gt;MQX_init_struct -&amp;gt; START_OF_KERNEL 0x2000FEF0&lt;/P&gt;&lt;P&gt;MQX_init_struct -&amp;gt; END_OF_KERNEL &amp;nbsp; &amp;nbsp; 0x00000411&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What caused&amp;nbsp;MQX_init_struct to have invalid addresses for the START_OF_KERNEL and END_OF_KERNEL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 01:21:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188181#M2092</guid>
      <dc:creator>kfranz</dc:creator>
      <dc:date>2011-12-07T01:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: K60 RAM allocation issue when adding a thread</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188182#M2093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kevin,&lt;/P&gt;&lt;P&gt;one explanation could be that your task uses a lot of RAM.&lt;/P&gt;&lt;P&gt;Could you check the RAM allocations in map-file.&lt;/P&gt;&lt;P&gt;~Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2011 01:36:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188182#M2093</guid>
      <dc:creator>MarkP_</dc:creator>
      <dc:date>2011-12-08T01:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: K60 RAM allocation issue when adding a thread</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188183#M2094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, it's a small simple task. If I delete one of the tasks in the TWR-K60N512_Quick_Start_Demo which use more stack space than the task I wish to create (for example,&amp;nbsp;sdcard_task) and replace it with my task everything is okay.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been doing embedded development for many years on other platforms using an RTOS. So, I have a good understanding of the process. The plan is for us to port all of our products to Kinetis. I just have to figure out Kinetis and MQX, &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My guess is that something is getting placed at an absolute address and when I add my task I am crossing a boundary or exceed an allocation. The question is what boundary or allocation? and, how do I fix it? I looked at the Lightweight Memory. It says I have 16K free at 0x1fffbe10 and 65k free at 0x20000004.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any other ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2011 03:57:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188183#M2094</guid>
      <dc:creator>kfranz</dc:creator>
      <dc:date>2011-12-08T03:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: K60 RAM allocation issue when adding a thread</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188184#M2095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;what values map file shows for these segments:&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1FFF8000 00014C9C 00001210 .main_application_data ram&lt;BR /&gt;&amp;nbsp; 1FFF9210 1FFF9210 00001B10 .main_application_bss ram&lt;BR /&gt;&amp;nbsp; 1FFFAD20 1FFFAD20 00000000 .kernel_data ram&lt;BR /&gt;&amp;nbsp; 20007FE0 20007FE0 00000000 .end_of_kernel_data end_of_kd&lt;/P&gt;&lt;P&gt;(Those values are for K10, it has only 64k RAM)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a discontinuity in RAM at address 0x20000000, hidden in init_bsp.c:&lt;/P&gt;&lt;P&gt;uint_32 _bsp_enable_card(void) ﻿&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Memory splitter - prevent accessing both ram banks in one instruction */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _mem_alloc_at(0, (void*)0x20000000);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;~Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2011 15:21:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188184#M2095</guid>
      <dc:creator>MarkP_</dc:creator>
      <dc:date>2011-12-08T15:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: K60 RAM allocation issue when adding a thread</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188185#M2096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using the IAR Embedded Workbench compiler version 6.30.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have traced the problem to the initialization of MQX_init_struct before main() is called.&lt;BR /&gt;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; /* Start MQX */&lt;BR /&gt;&amp;nbsp; _mqx( (MQX_INITIALIZATION_STRUCT_PTR) &amp;amp;MQX_init_struct );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;__iar_data_init3 is an assembler function which appears to be initializing RAM constants. It is provided by IAR and there is no source code for it. When this function executes, MQX_init_struct gets set to values which are not correct. At this point I think I need to contact IAR.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2011 02:02:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-RAM-allocation-issue-when-adding-a-thread/m-p/188185#M2096</guid>
      <dc:creator>kfranz</dc:creator>
      <dc:date>2011-12-09T02:02:49Z</dc:date>
    </item>
  </channel>
</rss>

