cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 sdio sdhc 4gb problem

yigit
Associate II
Posted on September 13, 2012 at 08:37

Hello,

I've a problem with sdhc used with sdio in stm32f4-discovery platform. I've tried 2 versions of fat file system and sd driver, but I am not able to run sdhc properly.

The things I tried;

1) Nemui's sdio implementation with chan's fat version 0.09a.

2) stm324xg-eval implementation with also chan's fat 0.09.(which is used from stm32-demonstration builder)

Both codes are working perfectly with standard sdsc card (which are below 2gb) but when I insert a FAT32 formated sdhc card, the following occur.

1) SD_init() returns OK

2) f_mount() returns OK

3) f_open with create new file option returns OK

4) f_write returns OK with byteswritten value returned as expected.

5) f_sync returns OK

but when I connect the sdhc card to pc there seems nothings has been written.

Also there exists only one file in sdhc named as ''audio.wav'', f_open to this file returns FR_NO_FILE

the standard sdsc versions are working perfectly, the init sequence seems to support sdhc but there must be something I forget.

Can you please help me ?

Regards,

Yigit

#stm32-sdio-sdhc #sdio-sdhc-stm32 #stm32-sdio-sdhc #stm32-sdio-wide-mode-sdhc
30 REPLIES 30
amol
Associate II
Posted on July 16, 2013 at 06:38

https://docs.google.com/open?id=0B7OY5pub_GfIaUozb1VsY3Flb1E

Hi Clive,

 I m new in interfacing sd with stm32 could u suggest me how to add F_open & other files in sd card eg. also some documentation regarding sd card library

Thanks

Amol

Posted on July 16, 2013 at 13:30

http://elm-chan.org/fsw/ff/en/appnote.html

http://elm-chan.org/fsw/ff/00index_e.html

STM32F4xx_DSP_StdPeriph_Lib_V1.1.0\Project\STM32F4xx_StdPeriph_Examples\SDIO\SDIO_uSDCard
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
romybompart
Associate II
Posted on December 13, 2013 at 16:46

Hello Shannon Could you help with this.. 

    I am trying to understand what to do with the code that clive1 had attached. Please send me what you did to make it works. I will be so grateful.

Thanks beforehand.  

Posted on December 13, 2013 at 19:27

The code as presented is an end-to-end demonstration of FAT access from a Micro SD Card.

On the STM32F4-Discovery this requires you to wire up a socket to the board, or use a base board like the STM32F4-DIS-BB with one provided. For the BB implementation you'd just need to modify the Card Detect pin the software uses by default, as I had used a different pin on the prototype I built.

The question would then be what have you done, and why isn't it working for you?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jdcowpland
Associate II
Posted on December 17, 2013 at 15:11

Hi Clive,

I've just tried to implement your code on my STM32F4 discovery with a SD Card connector (minus the detect pin) and for some reason, it's failing to send CMD0 and so gets a timeout error everytime. I know it's nothing to do with my card or connections as I have them working with code I've used before (without fatfs). Any idea what might be going wrong? I've commented out any code I can find to do with the detect pin.

jdcowpland
Associate II
Posted on December 17, 2013 at 15:31

Not quite sure what's different about my system, but I added in a few millisecond delays around the SD Init phase, and that seemed to fix the problem.

jdcowpland
Associate II
Posted on December 17, 2013 at 15:42

By the way, whereabouts in the code do we define if we want FAT12,16, or 32?

Posted on December 17, 2013 at 15:45

By the way, whereabouts in the code do we define if we want FAT12,16, or 32?

Wouldn't that be a function of what's in the MBR/BPB?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jdcowpland
Associate II
Posted on December 17, 2013 at 15:53

So does fatfs extract that information from the MBR and then just work in that format? What if I wanted to let's say format the card from the STM into a different format. Is that possible with fatfs? (I can't see anything about formatting in the docs)

Posted on December 17, 2013 at 16:07

The partition table in the MBR define the nature of the partition, the FAT's BPB actually defines the file systems geometry.

http://elm-chan.org/fsw/ff/en/mkfs.html

I personally haven't used it, I've built my own more industrial formatters in the past. But, again you really have some relatively limited control, the size of the media determines the appropriate maximum, 2GB being the limit for 32 KB clusters in FAT16. Microsoft has some rules about how this is done ''optimally'', SD Cards also have VERY specific needs for ALL structures to be aligned on Erase Block boundaries (perhaps 128 KB, but check stats returned by card) otherwise performance takes a hideous hit. Unless you have some specific insight into file systems and block devices you probably want to tread carefully.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..