cancel
Showing results for 
Search instead for 
Did you mean: 

SD Card Access while in USB MSC mode

holeygaurav
Associate II
Posted on June 18, 2014 at 15:01

Dear All,

I am implementing a solution where I have to read file when device is in usb mass storage mode and after reading I have to delete the file.

I have implemented USB Mass Storage device based on STM32F105 and I am using emfile - emb OS from segger.

When device in MSC, I am stuck at SD_Readbyte flag. My doubts are :

1. Is USB blocking access to SD Card/SPI lock?

2. At what point I should be able to access the SD Card?

    - After completion of USB MSC Initialization?

Please revert ASAP.

Thanking you in anticipation.

Best Regards,

hgaurav
3 REPLIES 3
Posted on June 18, 2014 at 17:06

You have to disconnect the USB, or have it present that the media is ejected, changed, not present, and/or not ready. If you don't do this the contention/coherency issues are practically impossible to overcome, as you don't control enough of the software in the system.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
holeygaurav
Associate II
Posted on June 24, 2014 at 09:35

Dear Clive,

How it is handled in USB based Card Reader....How is the implementation? Accessing the files through USB... I am bit confused regarding this?

Please revert.

Thanking you in anticipation.

Best Regards,

Gaurav Holey

Posted on June 24, 2014 at 16:10

The card reader will basically take the read, write, control functions passed as MSC/SCSI commands, and turn them into card access commands. It does this at a sector/block level.

If you have code on the STM32 that you want to access the card and files on it, you need an access layer/driver, and a file system, like FatFs.

What is very difficult to do is allow a PC and STM32 access the card at the same time, you are likely to corrupt the content of the card as you have different views on what is current.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..