cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H735 SDMMC Error FR_NO_FILESYS

HSamm.1
Associate II

I'm having trouble getting the on board SD card reader working properly. The board is the STM32H735G discovery kit.

When attempting to mount the disc it comes back with error FR_NO_FILESYSTEM. A closer investigation shows that when reading the first (or actually any) sector from disk, the first 12 bytes of the 512 byte sector are not transferred into memory. Whatever was in that place remains, the big rest of the sector comes inexactly like it is on disk.

I first thought it may be related to alignment of the buffer address, but it was 32-bit aligned and bringing it to a 64-bit alignment didn't change anything.

The read always completes without errors, it just fails as FATS cannot identify the filesystem missing the proper first 12 bytes. The signature at the sector end (55AA) is read correctly.

Tried several SD cards with no change. These cards also read fine on a different type of evaluation boards with sd_io.

The code for SDMMC was generated via CubeMX and I cannot find any settings that would cure the problem.

Any ideas?

5 REPLIES 5

Sounds like a cache coherency issue.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
HSamm.1
Associate II

Brilliant!! Turned off data cache and voila, it works! Thanks.

Do you think this means I cannot use the data cache at all, or should I selectively disable it while doing SD card IO?

No it means you need to make sure your DISKIO layer addresses this appropriately

ST has a "ENABLE_SD_DMA_CACHE_MAINTENANCE" define, but there implementation has been a bit rough at times.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
HSamm.1
Associate II

Thanks again! Turned on the macro and turned back on the data cache. This now results in a different error (FR_INT_ERR). But I'm sure I'll find out quickly what is going on, now that you put me on the right track. Wonderful to have smart and helpful folks around.

HSamm.1
Associate II

To conclude this thread, it is worth explaining why it still didn't work with the  "ENABLE_SD_DMA_CACHE_MAINTENANCE" set. The macro invalidates the cache of a 32-byte aligned address range and makes visible what has been transferred by DMA into the underlying memory and with the macro set, all data read from disk shows up properly. But now the inverse problem occurs, invalidating cache content that was not related to the transfer but part of the 32-byte aligned invalidation. The filesystem FATS structure has at its very end the window buffer for the last read sector, but the buffer doesn't start at an aligned address. So the invalidation reaches back into the preceding part of the structure and destroys recently updated variables.

A buffer allocation via malloc would be ok as it would allocate at 32 byte boundaries, but in this case it is just the beginning of the FATS struct that is aligned, the buffer at the end is not. For now I fixed it by putting some filler words into the struct, after the last variable and before the buffer declaration, this way pushing the buffer over to the next 32-byte boundary. The down site is that I need to save the modified ff.h before generating code with CubeMX and then restore it.