Cortex-M7 platform FatFS Cache coherency Topic is solved
Posted: Tue May 23, 2017 8:46 pm
Hello,
- So after running into problems with the M7 cache coherency and my SPI driver (thanks to Giovanni for helping me with that!) I also found that the same problems occur when using the FatFS libary on the M7-platform.
- Currently I am using ChibiOS_16.1.8
- Compiled with gcc-arm-none-eabi-5_4-2016q2
- The board I have tested this on is the STM32F746G-DISCO in Eclipse.
- The problem occurs when trying to read from or write to the disk with FatFS and the FIL-variable passed to the read/write function is allocated from the heap. When using chHeapAlloc to allocate the FIL-variable nothing is returned when reading from and nothing is written when writing to the disk. This also occurs when creating a thread with 'chThdCreateFromHeap' and the FIL-variable is created in the thread, because then it is also allocated from the heap.
- The reason for the failure is that the FIL-variable isn't flushed to cache when writing and isn't being invalidated when reading from the disk.
- In the attachment I have included a fix for this in the fatfs_diskio.c file. The only thing I am not sure of, is if it's allowed to use the 'MMCSD_BLOCK_SIZE' define to determine the size of the buffer to flush/invalidate. I have tested this implementation for the SDC-interface and so far it works fine.
cpu20
- So after running into problems with the M7 cache coherency and my SPI driver (thanks to Giovanni for helping me with that!) I also found that the same problems occur when using the FatFS libary on the M7-platform.
- Currently I am using ChibiOS_16.1.8
- Compiled with gcc-arm-none-eabi-5_4-2016q2
- The board I have tested this on is the STM32F746G-DISCO in Eclipse.
- The problem occurs when trying to read from or write to the disk with FatFS and the FIL-variable passed to the read/write function is allocated from the heap. When using chHeapAlloc to allocate the FIL-variable nothing is returned when reading from and nothing is written when writing to the disk. This also occurs when creating a thread with 'chThdCreateFromHeap' and the FIL-variable is created in the thread, because then it is also allocated from the heap.
- The reason for the failure is that the FIL-variable isn't flushed to cache when writing and isn't being invalidated when reading from the disk.
- In the attachment I have included a fix for this in the fatfs_diskio.c file. The only thing I am not sure of, is if it's allowed to use the 'MMCSD_BLOCK_SIZE' define to determine the size of the buffer to flush/invalidate. I have tested this implementation for the SDC-interface and so far it works fine.
cpu20