AnsweredAssumed Answered

Can you access a SD card through USB MSC and FATFs at the same time?

Question asked by David Harrison on Jun 2, 2017
Latest reply on Jun 3, 2017 by David Harrison

I have a STM32F746NG Discovery board on which I have implemented a USB Composite device with MSC and custom HID classes. I also want to run Elm-Chan's FATFS to read and write files locally on the micro-SD card whilst the USB is still connected.


I have read that you can't have two file systems accessing the SD card at the same time. Superficially this does make sense. However I have successfully implemented exactly this scheme on a PIC32 device which has successfully been in production for the last five years. However the PIC32 USB device stack is completely different from the STM32 one and is implemented totally differently so the two are not comparable.

 

I tried adding a low level lock to the SDcard ReadBlocks and WriteBlocks functions to make sure they could not be accessed from the FATFs and USB MSC at the same time, but the application just locks up.

 

If I don't have the locks in place the SD card gets corrupted and I have to reformat it each time.

 

Has anyone successfully done this and if so, how?


Thanks.

Outcomes