<?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 Heap Allocation - Integrating MQX and PEG+ in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147370#M190</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have ported the BSP to my platform (K20) and worked through many of the MQX examples, which all work fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now trying to integrate PEG+ into the platform, I have got to the point of building my first GUI application.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But at the conclusion of the make I get a linker error telling me there is no heap allocated.&lt;/P&gt;&lt;P&gt;Warning[Lp012]: no sections with name HEAP included - special symbol HEAP$$Base (referenced from xgetmemchunk.o(dl7M_tln.a)) will&amp;nbsp; be zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the code, it drops into MQX-idle at the first point where the &lt;STRONG&gt;new&lt;/STRONG&gt; operator is called.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the icf provided with the MQX examples, which (as supplied) has neither stack nor heap. &amp;nbsp;This confused me a bit, since C-stack is usually the first thing set up by the RTL.&amp;nbsp; Therefore I assume that MQX handles stack and heap on its own.?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, I modified the icf from within IAR IDE to give myself a 64k heap, but still got the same linker error.&amp;nbsp; modified icf attached&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I really want to do is put all the GUI volatile stuff into an offchip SRAM which I have put on the board, leaving the On-chip memory for application stuff.&amp;nbsp; But for now, anything that gives me a heap section would be helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you suggest anything?&amp;nbsp; Which manuals should I read?﻿&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Jul 2011 15:29:00 GMT</pubDate>
    <dc:creator>OldNick</dc:creator>
    <dc:date>2011-07-08T15:29:00Z</dc:date>
    <item>
      <title>Heap Allocation - Integrating MQX and PEG+</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147370#M190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have ported the BSP to my platform (K20) and worked through many of the MQX examples, which all work fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now trying to integrate PEG+ into the platform, I have got to the point of building my first GUI application.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But at the conclusion of the make I get a linker error telling me there is no heap allocated.&lt;/P&gt;&lt;P&gt;Warning[Lp012]: no sections with name HEAP included - special symbol HEAP$$Base (referenced from xgetmemchunk.o(dl7M_tln.a)) will&amp;nbsp; be zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the code, it drops into MQX-idle at the first point where the &lt;STRONG&gt;new&lt;/STRONG&gt; operator is called.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the icf provided with the MQX examples, which (as supplied) has neither stack nor heap. &amp;nbsp;This confused me a bit, since C-stack is usually the first thing set up by the RTL.&amp;nbsp; Therefore I assume that MQX handles stack and heap on its own.?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, I modified the icf from within IAR IDE to give myself a 64k heap, but still got the same linker error.&amp;nbsp; modified icf attached&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I really want to do is put all the GUI volatile stuff into an offchip SRAM which I have put on the board, leaving the On-chip memory for application stuff.&amp;nbsp; But for now, anything that gives me a heap section would be helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you suggest anything?&amp;nbsp; Which manuals should I read?﻿&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2011 15:29:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147370#M190</guid>
      <dc:creator>OldNick</dc:creator>
      <dc:date>2011-07-08T15:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Heap Allocation - Integrating MQX and PEG+</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147371#M191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had the same problem, try something like this changing the value 0x0800 dependent﻿&amp;nbsp;upon your needs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;define block HEAP with size = 0x0800, alignment = 8{ };&lt;/P&gt;&lt;P&gt;place in RAM_region {block HEAP};﻿&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 14:25:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147371#M191</guid>
      <dc:creator>KJFPE</dc:creator>
      <dc:date>2011-07-11T14:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Heap Allocation - Integrating MQX and PEG+</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147372#M192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK...sorted now, got help from compiler tech support. &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;Did not need to define a heap...DID need to override the &lt;STRONG&gt;new&lt;/STRONG&gt; operator so that it uses mqx "_mem_alloc﻿"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Have also been advised to watch out for exception handling, but that depends on level of C++ selected.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 14:46:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147372#M192</guid>
      <dc:creator>OldNick</dc:creator>
      <dc:date>2011-07-11T14:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Heap Allocation - Integrating MQX and PEG+</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147373#M193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can I ask how you overode the new operator to use&amp;nbsp;mqx "_mem_alloc﻿"﻿&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 17:16:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147373#M193</guid>
      <dc:creator>KJFPE</dc:creator>
      <dc:date>2011-07-11T17:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Heap Allocation - Integrating MQX and PEG+</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147374#M194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;KJFPE wrote:&lt;BR /&gt;&lt;P&gt;can I ask how you overode the new operator to use&amp;nbsp;mqx "_mem_alloc﻿"﻿&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Somewhere in your cpp code, you need something like these two&lt;/P&gt;&lt;P&gt;void* operator new (unsigned int size)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void *p = _mem_alloc_system(size);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!p)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;//catch null response&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(p);&lt;BR /&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp; ﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void operator delete(void *p)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; uint_32 result = _mem_free(p);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (result != MQX_OK)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _task_set_error(result);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}&amp;nbsp;&amp;nbsp; ﻿&lt;/P&gt;&lt;P&gt;And of course, you may need the array versions as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The functions are provided as part of the graphics library, so I have had to mangle them slightly for this post.&amp;nbsp; I hope that gves you enough to get the general idea.&amp;nbsp; If you are using PEG+ there is a define in mqxpeg.hpp (PEG_NEW_DELETE﻿) which is commented out, and shouldn't be.&amp;nbsp; I think I have said all I ought to. &lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 18:51:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Heap-Allocation-Integrating-MQX-and-PEG/m-p/147374#M194</guid>
      <dc:creator>OldNick</dc:creator>
      <dc:date>2011-07-11T18:51:23Z</dc:date>
    </item>
  </channel>
</rss>

