cancel
Showing results for 
Search instead for 
Did you mean: 

Access SD Card via USB (MSC) results in "Please insert a disc into USB Drive"

JDonn.1
Associate II

I have an STM32L4R5ZI-P board. I have a SD Card connected via a 4-bit SDMMC (I'm using a Pmod SD Card Module).

I can successfully read and write to the SD Card using FatFS.

I have set up the USB_DEVICE and USB_OTG_FS as described here https://controllerstech.com/stm32-usb-msc/

When I connect the micro USB connector at the bottom of the board to my Windows PC I get a "Please insert a disc into USB Drive (F:).". It doesn't look like any memory size, or anything is passed to my PC.

The example worked without any other modification on the video.

Any ideas?

7 REPLIES 7

Perhaps talk to the people on that site?

Not sure I like his wiring diagram. The boards look to have pull-ups, no circuit diagram found

https://digilent.com/reference/_media/pmod:pmod:pmodSD_rm.pdf

If it doesn't see media, perhaps you should look at how you've got the Card Detect pin of the socket wired, and how that's handled on the STM32 side. Typically these switch to ground when the cards are inserted, but you should check/confirm what this design does.

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

Hi @Community member​,

I have pull-ups on Data0, Data1, Data2, Data3 and CMD for the SDMMC (took a while to figure out why it wasn't working). Chip Select is connected to GND currently and I can read/write in the main code using FatFS.

Ok, but the message is that on the PC side it's receiving a "MEDIUM NOT READY/PRESENT" type sense code from the MSC. The MSC Class tends to expect "Removable Media" devices to be attached.

You need to look at how that's plumbed and coded, end-to-end.

Like I said, the Card Detect pins on the sockets tend to be switches, you wire these to a GPIO, and the code in the STM32 checks the state of the GPIO to establish if a card is in the socket, or not.

You shouldn't need pull-ups if they are already soldered on the back side of the adapter board.

0693W00000Kc9blQAB.jpg

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

Chip Select should be SDIO-D3

Card Detect should be a GPIO

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

Hi @Community member​ ,

It's wired for 4-bit so my Chip Select is Data3. Write Protect is at GND and Card Detect is on GPIO_Input (Although I'm not sure what to do with it).

My confusion comes in that I can read/write to/from the SD card but it can't pick up on it when connecting through USB. I figured the hardware setup was correct in this regard.

If I do not interact with the SD card at all i.e. do not mount, read/write - then I get the "Please insert disc..." error.

However, if I do read/write the SD card or call HAL_SD_Init() then it gets stuck in HAL_SD_ReadBlocks() in stm32l4xx_hal_sd.c in the "/* Poll on SDMMC flags */" section (line 777). It gets stuck here and doesn't return to the main loop. Then after a little while Windows says the USB Device Not Recognised.

Thanks for your help.

Hello, 

I think I have quite the same issue, did you find a solution ? 

Best,

Instrument your code so you can get a real-time understanding of what's happening without the debugger getting in the way. Understand the flow and expectations, and error handling paths.

Determine how it checks for card availability and reports that as a SCSI SENSE CODE

Test the code for the SDIO/SDMMC operation outside of USB MSC

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