<?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 DMA, FEC and D-cache coherency in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133592#M1273</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We are using the MCF5475 with the Freescale supplied example code for using the FEC and DMA. With data cache disabled it works fine. When the cache is enabled it fails (not surprisingly) because cache coherency is not maintained during DMA.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can see two possible solutions to this problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Invalidate the cache after DMA to memory and flush it after DMA reads.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Place the buffer memory in non-cached memory.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can see how to do 2. I can't work out from looking at the Freescale code (fec.c fecbd.c) where to flush and invalidate the data cache. Somebody must have been here before surely?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All suggestions welcome.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TW&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Oct 2006 00:40:45 GMT</pubDate>
    <dc:creator>tedwood</dc:creator>
    <dc:date>2006-10-20T00:40:45Z</dc:date>
    <item>
      <title>DMA, FEC and D-cache coherency</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133592#M1273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We are using the MCF5475 with the Freescale supplied example code for using the FEC and DMA. With data cache disabled it works fine. When the cache is enabled it fails (not surprisingly) because cache coherency is not maintained during DMA.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can see two possible solutions to this problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Invalidate the cache after DMA to memory and flush it after DMA reads.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Place the buffer memory in non-cached memory.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can see how to do 2. I can't work out from looking at the Freescale code (fec.c fecbd.c) where to flush and invalidate the data cache. Somebody must have been here before surely?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All suggestions welcome.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TW&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Oct 2006 00:40:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133592#M1273</guid>
      <dc:creator>tedwood</dc:creator>
      <dc:date>2006-10-20T00:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: DMA, FEC and D-cache coherency</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133593#M1274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hej.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I've a similar problem. Like you say, using a non-cached area is one solution (just yesterday I found out how to partion the SDRAM in a cached and non-cached part).&lt;/DIV&gt;&lt;DIV&gt;Invalidating the cache has the big disadvantge that ALL data is gone, that'll slow all other code fetching data down too.&lt;/DIV&gt;&lt;DIV&gt;The best would be to just invalidate those cache lines which refer to the DMA'd data, but there seems to be no way to do that. I've written to Freescale about this, no answer yet.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Rik.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Oct 2006 16:38:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133593#M1274</guid>
      <dc:creator>Rik</dc:creator>
      <dc:date>2006-10-20T16:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: DMA, FEC and D-cache coherency</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133594#M1275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;same problem here... but on a MCF5234, using split cache configuration.&lt;BR /&gt;&lt;BR /&gt;I'am trying to invalidate the corresponding D-cacheline with CPUSHL.&lt;BR /&gt;The problem is, CPUSHL is badly documented... 'til now i'm getting&lt;BR /&gt;only trap 11 :smileysad:&lt;BR /&gt;&lt;BR /&gt;cheers, Thomas&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2006 19:06:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133594#M1275</guid>
      <dc:creator>thz</dc:creator>
      <dc:date>2006-10-25T19:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: DMA, FEC and D-cache coherency</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133595#M1276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a solution for anyone still searching.&amp;nbsp; FlushDataCacheRegion uses CPUSHL to flush only those data cache lines that could contain data from a specified memory region. I use this on the 5475 to flush tx buffers from the cache prior to setting the ready bit in the buffer descriptor and to flush rx buffers from the cache prior to setting the empty bit in the buffer descriptor.&amp;nbsp; The buffers must be 16-byte aligned, and the size of the buffers must be evenly divisible by 16.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt;&amp;nbsp;* Flush and Invalidate specified memory from data cache&lt;BR /&gt;&amp;nbsp;*&lt;BR /&gt;&amp;nbsp;* Flushes (and invalidates by virtue of CACR[DDPI]=0) specified&lt;BR /&gt;&amp;nbsp;* memory range from cache. This operation loops the memory range,&lt;BR /&gt;&amp;nbsp;* calling CPUSHL for each 16 byte line to flush and invalidate for&lt;BR /&gt;&amp;nbsp;* each of the 4 "ways" of the data cache.&lt;BR /&gt;&amp;nbsp;*&lt;BR /&gt;&amp;nbsp;* @param pMem points to the starting address of the region to be flushed&lt;BR /&gt;&amp;nbsp;* from the data cache. If this address is not 16 byte aligned, this function&lt;BR /&gt;&amp;nbsp;* will "back-up" to the nearest 16 byte boundary and start flushing from there.&lt;BR /&gt;&amp;nbsp;*&lt;BR /&gt;&amp;nbsp;* @param len_bytes specifies the size of the region in bytes.&lt;BR /&gt;&amp;nbsp;*/&lt;BR /&gt;void FlushDataCacheRegion( void *pMem, unsigned long len_bytes )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; asm{&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MOVE.L&amp;nbsp; pMem,D0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* fetch start address */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MOVEA.L D0,A1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* calculate stop address */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDA.L&amp;nbsp; len_bytes,A1&amp;nbsp;&amp;nbsp; ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLR.L&amp;nbsp;&amp;nbsp; D1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* init way counter */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ANDI.L&amp;nbsp; #0xFFFFFFF0,D0 ;/* calculate aligned start address */&lt;BR /&gt;&amp;nbsp; FlushDataCacheRegion_wayloop:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MOVE&amp;nbsp;&amp;nbsp;&amp;nbsp; D0,A0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* initialize A0 */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDA.L&amp;nbsp; D1,A0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* set way index */&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; FlushDataCacheRegion_innerloop:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CPUSHL&amp;nbsp; DC,(A0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* flush and invalidate the cache line */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADD.L&amp;nbsp;&amp;nbsp; #0x10,A0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* increment to next cache line */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CMPA.L&amp;nbsp; A0,A1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* done with region? */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BGT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FlushDataCacheRegion_innerloop;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDQ.L&amp;nbsp; #1,D1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* increment way counter */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDQ.L&amp;nbsp; #1,A1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* update stop address to reflect new way value */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CMPI.L&amp;nbsp; #4,D1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;/* check if all cache ways have been flushed */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BNE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FlushDataCacheRegion_wayloop;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2010 05:27:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133595#M1276</guid>
      <dc:creator>KenJohnson</dc:creator>
      <dc:date>2010-01-28T05:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: DMA, FEC and D-cache coherency</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133596#M1277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;tedwood wrote:&lt;BR /&gt;We are using the MCF5475 with the Freescale supplied example code for using the FEC and DMA. With data cache disabled it works fine. When the cache is enabled it fails (not surprisingly) because cache coherency is not maintained during DMA.&lt;BR /&gt;&lt;BR /&gt;I can see two possible solutions to this problem.&lt;BR /&gt;&lt;BR /&gt;1. Invalidate the cache after DMA to memory and flush it after DMA reads.&lt;BR /&gt;2. Place the buffer memory in non-cached memory.&lt;BR /&gt;&lt;BR /&gt;I can see how to do 2. I can't work out from looking at the Freescale code (fec.c fecbd.c) where to flush and invalidate the data cache. Somebody must have been here before surely?&lt;BR /&gt;&lt;BR /&gt;All suggestions welcome.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;TW&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here's some more options.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We've found that our code runs FASTER if the cache is configured as WRITETHROUGH than it is when configured as COPYBACK. That solves the problems of transmitting data through the FEC or DMA. You can also use CACR/CINVA with WRITETHROUGH without losing data, but I'm pretty sure CINVA with WRITEBACK would lose writes to memory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need to use cached memory for receiving, then you'll need to invalidate the cache lines that the receive buffers are in before starting the hardware. A simpler solution is to use buffers in STATIC RAM to receive into. You could even have a "quick hack" that receives into SRAM and then let the CPU copy it to where you really want in in cached RAM.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The most universal solution is to use CPUSHL in INVALIDATE mode for RECEIVE buffers (mode doesn't matter for transmitting).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fun, isn't it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Feb 2010 20:16:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/DMA-FEC-and-D-cache-coherency/m-p/133596#M1277</guid>
      <dc:creator>TomE</dc:creator>
      <dc:date>2010-02-02T20:16:45Z</dc:date>
    </item>
  </channel>
</rss>

