Skip to main content
daniele2
Associate
May 19, 2014
Question

STM32F103 + SDIO + FatFS

  • May 19, 2014
  • 23 replies
  • 6334 views
Posted on May 19, 2014 at 15:36

Hi all,

I've a problem with my STM32F103. I need to use fat filesystem on SD card to read/write/create files.

I've connected the SD card to the SDIO interface and 4 wires mode with 47Kohm pull-up on cmd and data pins.

I tried to use Chan FatFs module but it didn't working.

When I debug the f_open(), inside the check_fs() function can't retrieve 0xAA55 on boot sector, and the function returns NO_FILE_SYSTEM.

I've tried different SD card but the result was always the same. The clock of the board is 72MHz. I've read other discussions on this forum without luck.

Can someone help me?

Thanks.

Update1: The check_fs() method call the low level SD_ReadBlock() and here, where the code try to set the block size for the card, it returns SD_CMD_RSP_TIMEOUT.

#stm32f103-fat-sdio
This topic has been closed for replies.

23 replies

guillaumefaye
Associate II
September 29, 2014
Posted on September 29, 2014 at 18:09

Thanks Clive

I write first sector with low level fonction , not with fatfs  files access.

when i try to write and read another sector , i just read an empy buffer (they are only a litle .txt file in sd card)so i try to write first sector and after read this : if the MBR was not overwriting then low level don't work.The problem: this low level fonction work fine with unformat card.

Tesla DeLorean
Guru
September 29, 2014
Posted on September 29, 2014 at 19:40

The problem: this low level function work fine with unformat card.

Well that's odd to a point that defies logic.

What pin allocations do you have on your board for the SD card, card detect and USART? Perhaps I can port my

http://www.st.com/web/en/resource/technical/document/user_manual/CD00246066.pdf

example

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
guillaumefaye
Associate II
September 29, 2014
Posted on September 29, 2014 at 20:03

I use standard stm3210e_eval pin for SDIO and Uart: PC.08, PC.09, PC.10, PC.11, PC.12 pin: D0, D1, D2, D3, CLK pin ,Tx (PA.09),Rx (PA.10)

Idon't use uart to display read buffer, i use watch  capability on µvision with ulink debugger .

 

Tesla DeLorean
Guru
September 29, 2014
Posted on September 29, 2014 at 22:03

Assuming the Card Detect isn't connected. Pull-Ups as diagrammed above. This should output via USART1 115200 8N1

________________

Attachments :

SDIO-FAT-PORT103V.HEX : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzQ0&d=%2Fa%2F0X0000000bLg%2Fsyt0Pi2vHy7PA9Z9vLev0T.AHftDDp2n8Rh78qIGlSE&asPdf=false
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
guillaumefaye
Associate II
September 29, 2014
Posted on September 29, 2014 at 23:07

card detect and pull up are wired .why use uart?

Tesla DeLorean
Guru
September 30, 2014
Posted on September 30, 2014 at 03:57

It's convenient for me, I already have the code, I could use SWV/SWO. If I start from known working software, we can decide if your issue is sw or hw related.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
guillaumefaye
Associate II
September 30, 2014
Posted on September 30, 2014 at 06:58

card detec pin is D3, and the just diffrence, i have 10k pullup resistor insted your 47k.

i attached sd shematique and my code.

thanks for help.

________________

Attachments :

Micro_SD_Storage_Board_SCH.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzPv&d=%2Fa%2F0X0000000bLe%2FIJi.aQu5kblErNO8QwE.VHxJoQXwH4VYSJGX94HlVYw&asPdf=false

STM32F10x_StdPeriph_sdio.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzPq&d=%2Fa%2F0X0000000bLd%2FdW90kTR0ea4iCwzZDC5cCqkKswfHA.2qs2KfDdMwO7o&asPdf=false
Tesla DeLorean
Guru
September 30, 2014
Posted on September 30, 2014 at 16:42

Please indicated results observed with previously attached .HEX

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
guillaumefaye
Associate II
September 30, 2014
Posted on September 30, 2014 at 17:26

I just see attached .EXE

so result:

FatFs Testing - PORT103V Port

res = 1 f_open MESSAGE.TXT

res = 1 f_open DIR.TXT

Done

CRC32 BCA93E87 Memory Image

res = 1 f_open COUNTER.TXT

res = 1 f_open COUNTER.TXT

CRC32 FFFFFFFF COUNTER.TXT

Sanity check fails

res = 1 f_open COUNTER.TXT

res = 1 f_open COUNTER.TXT

Done

Tesla DeLorean
Guru
September 30, 2014
Posted on September 30, 2014 at 18:01

Card detect in this context is not D3, it's the switch providing the -CD signal.

So the output is indicative that your hardware is not connected up correctly, or you have some pin contention on your board.
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..