<?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: malloc failure in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590972#M22141</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lifejoker on Mon Mar 10 18:28:30 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i checked the heap configuration inside applications\lpc18xx_43xx\tool_configs\iar_linker_scripts\lpc18xx_43xx_iflash_heap.icf.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;, it is 0x2000, and i tried 0x3000, the problem was still there .&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the heap_3. where is the main heap malloc ? &lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 19:16:27 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T19:16:27Z</dc:date>
    <item>
      <title>malloc failure</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590970#M22139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lifejoker on Mon Mar 10 01:38:57 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;hi,i download lpcopen_2_09_keil_iar_keil_mcb_4357 from here, and try to debug the project Freertos_tcpecho-iflash_keil_mcb_4357.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i use LPC4357 as the main CPU as the example, and also use DP83848 PHY. But everytime when it ran to &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sys_thread_new("receive_thread", vPacketReceiveTask, netif-&amp;gt;state,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; DEFAULT_THREAD_STACKSIZE, tskRECPKT_PRIORITY);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in lpc18xx_43xx_emac.c, there was a malloc mistake and went directly into vApplicationMallocFailedHook().&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it is my first time to use freertos and Lpc4357, i have no idea what happend. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;what should i do ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590970#M22139</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: malloc failure</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590971#M22140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by sundarapandian on Mon Mar 10 16:54:45 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Make sure you have allocated enough heap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For IAR lwip projects Heap is allocated inside &lt;/SPAN&gt;&lt;STRONG&gt;applications\lpc18xx_43xx\tool_configs\iar_linker_scripts\lpc18xx_43xx_iflash_heap.icf&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For Keil projects it is allocated inside &lt;/SPAN&gt;&lt;STRONG&gt;applications\lpc18xx_43xx\examples\lwip\startup_code\keil_startup_lpc18xx43xx.s&lt;/STRONG&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590971#M22140</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: malloc failure</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590972#M22141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lifejoker on Mon Mar 10 18:28:30 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i checked the heap configuration inside applications\lpc18xx_43xx\tool_configs\iar_linker_scripts\lpc18xx_43xx_iflash_heap.icf.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;, it is 0x2000, and i tried 0x3000, the problem was still there .&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the heap_3. where is the main heap malloc ? &lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590972#M22141</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: malloc failure</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590973#M22142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lifejoker on Mon Mar 10 19:45:23 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;i set the heap bigger enough, and it works. thanks again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590973#M22142</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: malloc failure</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590974#M22143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MagnusFogelberg on Thu May 08 07:18:34 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think a know what the problem is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You say you are using heap_3 and heap_3 is using the C library malloc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When the malloc is performed it is testing if the stack and the heap do not overwrite each other.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If your code is running in a thread you will have the stack defined for your thread and it will be in your thread context.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As you know stack is allocating top -&amp;gt; down and heap is bottom -&amp;gt; up. malloc will recognise an overwrite of the heap if the address is greater than the stack address.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now when you are running in a thread context the stack pointer is actually a allocation of the heap done when the thread was created. Any malloc of the heap done within a thread would fail because the stack pointer is lower than the heap pointer (if not a free block is found below the thread context). This is the case when using heap_3 model. Depending on your system etc. you could easily change to heap_2 model or check out the link below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fcontent%2Ffaq%2Fmalloc-failure-using-freertos-heap3c-lpcxpresso-tool-chain" rel="nofollow" target="_blank"&gt;http://www.lpcware.com/content/faq/malloc-failure-using-freertos-heap3c-lpcxpresso-tool-chain&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this makes sense&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Magnus&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590974#M22143</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: malloc failure</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590975#M22144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lifejoker on Thu May 08 23:44:44 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, I am using heap2.c now.it works well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it happend because i was using freeRTOS+LWIP, which both need big space.but the ram I choosed was just 40K.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I set LWIP and freeRTOS to different RAM sections, not it is fine .&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But i still want to use external SDRAM at the beginning of SystemInit, so i guess i need assembly code for clock and SDRAM initiation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;anywhere i could get it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/malloc-failure/m-p/590975#M22144</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:29Z</dc:date>
    </item>
  </channel>
</rss>

