<?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: RTCS does not work when running in External Memory in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329414#M10528</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Carlos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I found the issue, and it is a bug in the MQX bsp.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In _bsp_pre_init() there is a section of code that intends to create a non-cachable SRAM memory pool for use by the Ethernet driver among others.&amp;nbsp; It does this by first _statically_ testing if the KERNEL is placed in internal or external SRAM, making the assumption that this is where the kernel heap is also placed.&amp;nbsp; If internal it allocates from the standard kernel memory pool.&amp;nbsp; If external it creates a new pool in non-cached memory and allocates from it.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However this function fails to handle the case where the kernel memory pool is extended at run-time via _mem_extend() with cached memory.&amp;nbsp; This is why if the memory is extended before initializing Ethernet it fails.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The logic is too convoluted.&amp;nbsp; It tries to make assumptions about where the memory pool is going to be rather than just actually testing where the memory pool is at the time the code is executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The logic needs to change to:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; - Test where the memory pool actually is (at run time)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; - If internal allocate from it&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; - If external allocate from an internal memory pool. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A better method might be just to allocate the Ethernet buffers unconditionally and statically with the linker section to a non-cached memory region.&amp;nbsp; This would eliminate a lot of convoluted logic and obscure #define's such as BSPCFG_HAS_SRAM_POOL and BSPCFG_ENET_SRAM_BUF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PMT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Jan 2015 21:03:08 GMT</pubDate>
    <dc:creator>pmt</dc:creator>
    <dc:date>2015-01-15T21:03:08Z</dc:date>
    <item>
      <title>RTCS does not work when running in External Memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329407#M10521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am running the latest MQX (4.1.1) on a K60 Tower BSP derivative platform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I start RTCS before adding an external memory pool (with _mem_extend() ) everything is fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I start RTCS after adding an external memory pool I can't ping or do a socket connection to the device, though DHCP client is able to get an address.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My external memory is fine.&amp;nbsp; It's is used for many other things.&amp;nbsp; In either case no MQX errors are reported, memory, stacks, tasks, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could this be some cache coherency issues (DMA related) in RTCS?&amp;nbsp; External memory is in a cache-able region.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PMT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 18:53:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329407#M10521</guid>
      <dc:creator>pmt</dc:creator>
      <dc:date>2015-01-08T18:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: RTCS does not work when running in External Memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329408#M10522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PMT,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What address are you using for the external memory? Have you tried non cacheable address range such as 0xA0000000?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2015 21:58:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329408#M10522</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2015-01-12T21:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: RTCS does not work when running in External Memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329409#M10523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am in the cache-able area: 0x60000000.&amp;nbsp; I will give the non-cache-able area a try for a data point, but ultimately I don't want to leave it that way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have narrowed it down.&amp;nbsp; If I call ipcfg_init_device() after extended the memory pool then ICMP and TCP don't work.&amp;nbsp; I think specifically the Ethernet buffer allocated under ENET_initialize_ex() are probably the culprit.&amp;nbsp; I think this a DMA cache coherency issue with the Ethernet Buffers.&amp;nbsp; Once these are allocated in external memory seems things stop working as they should.&amp;nbsp; Don't know how the DHCP client is managing to work however.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PMT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2015 22:41:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329409#M10523</guid>
      <dc:creator>pmt</dc:creator>
      <dc:date>2015-01-12T22:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: RTCS does not work when running in External Memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329410#M10524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I moved the external memory to non-cachable region (0xA0000000) and everything works like a champ.&amp;nbsp; However, this is not a good solution going forward.&amp;nbsp; That significantly sacrifices system performance.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems like the Ethernet buffers need to handle working from internal or external memory (with cache line flushes), or that they should be allocated statically so they can be tagged by the linker for internal memory (much like the USB buffers are allocated).&amp;nbsp; I know static allocation is not a good general solution since some systems will undoubtedly have multiple Ethernet devices, however it is a safe bet given that this Ethernet controller is captive to the K60.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PMT &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 13:40:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329410#M10524</guid>
      <dc:creator>pmt</dc:creator>
      <dc:date>2015-01-13T13:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: RTCS does not work when running in External Memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329411#M10525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PMT,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haver never made this test, but if you want to use the 0x60000000 cacheable area I would try flushing the cache before and after calling ipcfg_init_device().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 19:17:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329411#M10525</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2015-01-13T19:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: RTCS does not work when running in External Memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329412#M10526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Carlos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think this will do it.&amp;nbsp; The cache coherency is an issue not with the ARM core, but with DMA bypassing the cache.&amp;nbsp; So in this case I suspect it is the Ethernet peripheral DMA, which will be a problem on every Ethernet transfer, not just initialization.&amp;nbsp; To solve the issue (assuming that it is the issue) MQX would have to modify the Ethernet driver buffers to use statically allocated internal memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the MQX USB driver example.&amp;nbsp; There is a special section defined in the MQX provided linker file (USB_BDT) to allocate static non-cachable memory.&amp;nbsp; I think the Ethernet driver needs the same type of treatment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you confirm that the Ethernet driver was tested with cache-able memory regions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PMT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 20:17:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329412#M10526</guid>
      <dc:creator>pmt</dc:creator>
      <dc:date>2015-01-13T20:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: RTCS does not work when running in External Memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329413#M10527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Carlos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In MACNET_initialize there is a bit of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // TODO remake to using alloc_align fn&lt;/P&gt;&lt;P&gt;#if BSPCFG_HAS_SRAM_POOL &amp;amp;&amp;amp; BSPCFG_ENET_SRAM_BUF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; bd_ptr = (VENET_BD_STRUCT_PTR)_mem_alloc_system_zero_from(_BSP_sram_pool, (sizeof(ENET_BD_STRUCT)*(macnet_context_ptr-&amp;gt;NumRxBDs+macnet_context_ptr-&amp;gt;NumTxBDs))+MACNET_BD_ALIGNMENT);&lt;/P&gt;&lt;P&gt;#else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; bd_ptr = (VENET_BD_STRUCT_PTR)_mem_alloc_system_zero_uncached((sizeof(ENET_BD_STRUCT)*(macnet_context_ptr-&amp;gt;NumRxBDs+macnet_context_ptr-&amp;gt;NumTxBDs))+MACNET_BD_ALIGNMENT);&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that is supposed to allocate noncached memory.&amp;nbsp; This is not working for me, and probably why the Ethernet is failing.&amp;nbsp; Apparently this was not implemented in the K60 Tower BSP (since it doesn't have external memory by default), but does exist in a K70 version.&amp;nbsp; I'll try to get it this working the way it should and I think it will fix my issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PMT &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jan 2015 17:46:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329413#M10527</guid>
      <dc:creator>pmt</dc:creator>
      <dc:date>2015-01-15T17:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: RTCS does not work when running in External Memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329414#M10528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Carlos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I found the issue, and it is a bug in the MQX bsp.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In _bsp_pre_init() there is a section of code that intends to create a non-cachable SRAM memory pool for use by the Ethernet driver among others.&amp;nbsp; It does this by first _statically_ testing if the KERNEL is placed in internal or external SRAM, making the assumption that this is where the kernel heap is also placed.&amp;nbsp; If internal it allocates from the standard kernel memory pool.&amp;nbsp; If external it creates a new pool in non-cached memory and allocates from it.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However this function fails to handle the case where the kernel memory pool is extended at run-time via _mem_extend() with cached memory.&amp;nbsp; This is why if the memory is extended before initializing Ethernet it fails.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The logic is too convoluted.&amp;nbsp; It tries to make assumptions about where the memory pool is going to be rather than just actually testing where the memory pool is at the time the code is executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The logic needs to change to:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; - Test where the memory pool actually is (at run time)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; - If internal allocate from it&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; - If external allocate from an internal memory pool. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A better method might be just to allocate the Ethernet buffers unconditionally and statically with the linker section to a non-cached memory region.&amp;nbsp; This would eliminate a lot of convoluted logic and obscure #define's such as BSPCFG_HAS_SRAM_POOL and BSPCFG_ENET_SRAM_BUF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PMT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jan 2015 21:03:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329414#M10528</guid>
      <dc:creator>pmt</dc:creator>
      <dc:date>2015-01-15T21:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: RTCS does not work when running in External Memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329415#M10529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PMT,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your inputs, we really appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have already reported this to the MQX team.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jan 2015 18:55:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/RTCS-does-not-work-when-running-in-External-Memory/m-p/329415#M10529</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2015-01-19T18:55:55Z</dc:date>
    </item>
  </channel>
</rss>

