<?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>MQX Software SolutionsのトピックRe: MQX memory alloc issue</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-memory-alloc-issue/m-p/393071#M13147</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dawei&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I copied your code in hello world project,&amp;nbsp; and Enabled MQX_USE_MEM, I didn't see the error.&lt;/P&gt;&lt;P&gt;I tested this code in TWR-K70F120M board.&lt;/P&gt;&lt;P&gt;&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/57310i2D0C57416EBFAE46/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;&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, 16 Sep 2015 06:15:09 GMT</pubDate>
    <dc:creator>danielchen</dc:creator>
    <dc:date>2015-09-16T06:15:09Z</dc:date>
    <item>
      <title>MQX memory alloc issue</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-memory-alloc-issue/m-p/393070#M13146</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;you know there are two memory management way in mqx, LWMEM or normal MEM,&lt;/P&gt;&lt;P&gt;below code could run correctly on LWMEM, and will fail to alloc memory under MEM(define different function call in small_ram_config.h)&lt;/P&gt;&lt;P&gt;PLS try and suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I debug the code, and could find the issue, issue occurs in step3, while alloc bigger memory after address_at, the previous memory's pointer to next block has not updated;&lt;/P&gt;&lt;P&gt;and I test on MQX4.0.2, 4.1, 4.2, all have this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// _mem_alloc_at will cause a malloc error, this routine will test it&lt;/P&gt;&lt;P&gt;void test_error_alloc_at()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void * tm;&lt;/P&gt;&lt;P&gt;&amp;nbsp; //int tm;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; volatile unsigned int address_at;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void * test_pointer;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get first data, it should be less than 0x2000 0010&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tm = malloc(256);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("step1: %x\r\n", tm);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // alloc_at the address &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; address_at=(unsigned int)tm+256+256;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; test_pointer = _mem_alloc_at(256, (void*)address_at);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("step2: %x, address_at=%x\r\n", test_pointer, address_at);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get a large data, it will be got after address_at&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tm = malloc(256);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("step3: %x\r\n", tm);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get a small data, it will be got before address_at&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tm = malloc(128);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("step4: %x\r\n", tm);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get a large data, it will be failure with MQX_CORRUPT_STORAGE_POOL_FREE_LIST&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tm = malloc(256);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("step5: %x\r\n", tm);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tm = malloc(0xe000);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("step6: %x\r\n", tm);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tm = malloc(0x100);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("step7: %x\r\n", tm);&amp;nbsp; &lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2015 15:43:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-memory-alloc-issue/m-p/393070#M13146</guid>
      <dc:creator>daweiyou</dc:creator>
      <dc:date>2015-08-24T15:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: MQX memory alloc issue</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-memory-alloc-issue/m-p/393071#M13147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dawei&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I copied your code in hello world project,&amp;nbsp; and Enabled MQX_USE_MEM, I didn't see the error.&lt;/P&gt;&lt;P&gt;I tested this code in TWR-K70F120M board.&lt;/P&gt;&lt;P&gt;&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/57310i2D0C57416EBFAE46/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;&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, 16 Sep 2015 06:15:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-memory-alloc-issue/m-p/393071#M13147</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2015-09-16T06:15:09Z</dc:date>
    </item>
  </channel>
</rss>

