cancel
Showing results for 
Search instead for 
Did you mean: 

USB MSC and FatFS on the same mass storage device

JAlth
Associate

Hi,

for my current project, I like to use the FatFS library to read/write data to an SD card, connected to a STM32F429 through SDIO interface. This generally works and I can create/read/write files on the SD card.

In addition, I like to use USB mass storage mode to expose the SD card to a Host system (PC) as mass storage. This generally works as well. The PC detects the SD card with the correct size and shows up the file contents.

Now there is the problem, that a FAT file system must not have more than one "masters", which would obviousely apply to my case, as both the STM as well as the host PC try to be the master over the FAT file system.

It would be totally ok, if the STM looses his "master" role, while the controller is connected to an USB host PC. But I could not get this working so far. I even tried this scheme "Link FS to SDIO, mount drive, modifie file, unmount drive, unlink FS from SDIO" on every single file access. But it does not work, as I can still produce file system corruptions and other strange errors during connection to a PC.

Now the question is: how to deal with that? What are my options to provide both FatFS to my SD card along with USB MSC mode?

Best regards,

Joachim

Edit:

I also tried to use the USB connect interrupt to completely unmount/unlink and the USB disconnect interrupt to link/mount the file system locally. I thought that would be a good place for that, but this does also not work...

Edit 2:

I generated the basic initialization code blocks with CubeMX

0 REPLIES 0