<?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: Lighweight memory pool in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Lighweight-memory-pool/m-p/254386#M7455</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi vines,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The source code for this can be found in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;${MQX_ROOT}\mqx\source\kernel\lwmem.c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LWMEM_POOL_INVALID is returned from _lwmem_alloc_ functions() or from _lwmem_test(). Condition looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_13697153586767490 jive_text_macro jive_macro_code" jivemacro_uid="_13697153586767490"&gt;
&lt;P&gt;if (mem_pool_ptr-&amp;gt;VALID != LWMEM_POOL_VALID)&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; _task_set_error(MQX_LWMEM_POOL_INVALID);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (NULL);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } /* Endif */&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the VALID bit in the LWMEM_POOL_STRUCT is not correct. You don't indicate which function would cause this. (during allocation, either from the system pool or from a private pool ? or is this during runtime call to lwmem_test() ?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this occurs in runtime, in order to debug this, you can put data watchpoint to the address of the pool_ptr-&amp;gt;VALID. CPU would enter debug mode upon a CPU write access to this address. This is important note - only if &lt;STRONG&gt;CPU&lt;/STRONG&gt; store instruction writes to this address. As there exist more crossbar switch master ports on Kinetis (like usb controller, DMA) it is also possible, that one of these masters writes data to the address of pool_ptr-&amp;gt;VALID. For example, you schedule a usb transaction, for which you have allocated statically an application buffer of size 100 bytes, but the usb will receive 200 bytes. As it is 100 bytes off it is overwriting some other memory.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 May 2013 04:32:42 GMT</pubDate>
    <dc:creator>Martin_</dc:creator>
    <dc:date>2013-05-28T04:32:42Z</dc:date>
    <item>
      <title>Lighweight memory pool</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Lighweight-memory-pool/m-p/254385#M7454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This might seem basic to everyone. But what can cause the problem LWMEM_POOL_INVALID? Eg memory not enough in heap, stack, etc. I hope I don't get a reply "read the manual". I did, I guess my comprehension is not that good (sorry). Anyway, I will appreciate it if you could explain this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 14:48:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Lighweight-memory-pool/m-p/254385#M7454</guid>
      <dc:creator>vines</dc:creator>
      <dc:date>2013-05-23T14:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Lighweight memory pool</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Lighweight-memory-pool/m-p/254386#M7455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi vines,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The source code for this can be found in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;${MQX_ROOT}\mqx\source\kernel\lwmem.c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LWMEM_POOL_INVALID is returned from _lwmem_alloc_ functions() or from _lwmem_test(). Condition looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_13697153586767490 jive_text_macro jive_macro_code" jivemacro_uid="_13697153586767490"&gt;
&lt;P&gt;if (mem_pool_ptr-&amp;gt;VALID != LWMEM_POOL_VALID)&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; _task_set_error(MQX_LWMEM_POOL_INVALID);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (NULL);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } /* Endif */&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the VALID bit in the LWMEM_POOL_STRUCT is not correct. You don't indicate which function would cause this. (during allocation, either from the system pool or from a private pool ? or is this during runtime call to lwmem_test() ?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this occurs in runtime, in order to debug this, you can put data watchpoint to the address of the pool_ptr-&amp;gt;VALID. CPU would enter debug mode upon a CPU write access to this address. This is important note - only if &lt;STRONG&gt;CPU&lt;/STRONG&gt; store instruction writes to this address. As there exist more crossbar switch master ports on Kinetis (like usb controller, DMA) it is also possible, that one of these masters writes data to the address of pool_ptr-&amp;gt;VALID. For example, you schedule a usb transaction, for which you have allocated statically an application buffer of size 100 bytes, but the usb will receive 200 bytes. As it is 100 bytes off it is overwriting some other memory.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 May 2013 04:32:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Lighweight-memory-pool/m-p/254386#M7455</guid>
      <dc:creator>Martin_</dc:creator>
      <dc:date>2013-05-28T04:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Lighweight memory pool</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Lighweight-memory-pool/m-p/254387#M7456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Martin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just for info&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem was I forgot to remove a free() function where as the malloc was already remove. Thus it is trying to free up memory to a space that is not even allocated. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 12:53:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Lighweight-memory-pool/m-p/254387#M7456</guid>
      <dc:creator>vines</dc:creator>
      <dc:date>2013-06-07T12:53:55Z</dc:date>
    </item>
  </channel>
</rss>

