AnsweredAssumed Answered

SDIO demo code doesn't work with uSD ver. 1?

Question asked by Dave Jones on Mar 14, 2017
Latest reply on Mar 20, 2017 by avi_crak.videocrak

I have an STM32L476G-EVAL board and the STM32L4 firmware package. I took their application demo for FatFs which uses the SDIO interface and formats the uSD card, then writes a text file to it, then reads it, then sits in a loop, and I modified it. I changed it so it doesn't format the card. It simply reads the names of the files on the card and displays them on the LCD on the Eval board.


This works fine with HC uSD cards (greater than 2GB, FAT32). But it fails when I use uSD cards that are smaller non-HC cards (less than 2GB, FAT16). They are version 1 of the SD spec, as opposed to version 2 which the HC and above use. I tried with a 1GB card and a 1/2 GB card.


It looks like the HAL SD init code is wrongly identifying them as MMC cards and returning "invalid drive". They certainly are not MMC cards. They are uSD cards and clearly say SD on them.


I have another board, using a PIC24 and using SPI to talk to the cards, and using code libraries written by Microchip. That board has no problem reading the filenames off of any of the uSD cards I have, including all of the version 1 cards (the small ones). But the STM32 code is only working with the HC cards and failing with the smaller sized cards.


Has anybody else run into this? Does anybody know where the problem is, and know of a fix?


If you have a board working with the demo code or maybe with MX generated code, have you tested it with a uSD card less than 2GB? If not, do you happen to have one available to try it and see if it fails? My guess is that whoever wrote the L4 demo code, or the base code in the MX generator, was only testing using larger cards, since that's pretty much all you can buy in most places these days. You have to dig around on Amazon to even find the older smaller cards now.