SAMV71 Xplained Ultra SD / FatFS not working with cache enabled

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Atmel community, 

 

I am trying to experiment with reading and writing data from the eval board's SD card slot (end goal being to try and stream .wav audio out to the codec).

However the project refused to get past the f_open call, which returned 13 (No file system). I know for a fact that this SD card has a valid file system on here as I formatted it as Fat32 for this endeavour.

I followed through the debugger to check_fs in ff.c, which failed at the following line:

if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55)

The debugger showed the values at offset 510 in fs->win to be 0x55AA, which given that the LD_WORD macro flips the bytes round, is correct. However by separating out this check to:

WORD sig = LD_WORD(&fs->win[BS_55AA]);

if (sig != 0xAA55)

sig was evaluated as 0x00.

 

This pointed toward some odd memory behaviour, and sure enough after disabling the I-Cache and D-Cache, the example ran as expected. I tried adding a SCB_CleanInvalidateDCache_By_Addr() call for the fs structure with the cache enabled (and aligning it to 32 bytes), but this did not work.

I find it very hard to believe that this example was not tested with the cache enabled, as it seems madness to not take advantage of the Arm core's cache for performance. 

Is there possibly a newer version of this example that has been modified for cache coherency? If not, could anyone point me int he direction of where to start / how to go about debugging what is failing in terms of cache coherency to that it can be fixed?

Any help would be greatly appreciated.
 

Last Edited: Mon. May 11, 2020 - 09:30 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also the ASF USB driver has the same issue. The ASF drivers currently do not provide the D-Cache coherency when DMA is used.
So, you have to disable either D-Cache or DMA.
The simplest way is to disable D-Cache by undefining  CONF_BOARD_ENABLE_CACHE  in ASF3 and calling  SCB_EnableICache()  to enable I-Cache only. ASF4 (Atmel START) does not have an option to enable cache at all.