cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO and SD fat access example?

natblist
Associate
Posted on February 09, 2012 at 01:06

Hi Chaps,

Going slowly mad trying to get Chan Fat working with the sdio libs on a stm32f4.

I'm using the most recent (1.0.0) library for the F4, and the low level access demo within that library builds and (at least appears to ) work OK. 

I've spent many, many hours attempting to patch in 0.9 version of fatfs from chan (thks chan, you're a hero) - but I can't get it to work.

If possible, I'd really really appreciate a demo project/source (or direction to - though I've scoured the web and can't find anything that works!)

I'll post separately about the current problems I'm having with the my current build, but a working example would sort it.

Many thanks,

nat.

#hse-sdio-stm32 #stm32-fat-chanfat-fatfs-sdio #sdcard-stm32f4-sdio-fatfs #sdcard-stm32f4-sdio-fatfs
84 REPLIES 84
aambreen
Associate II
Posted on October 17, 2012 at 06:38

Hi

I have the same problem....Kindly give me sample MDK ARM project to use sdio driver with chan fatfs library....I have initialized sd card using SDIO peripheral...my card is functional now i want to store an image on sd card using FATFs..Kindly tell me what to do and how to do

dmakhrov9
Associate II
Posted on October 17, 2012 at 14:10

There is a simple trick to avoid using FS and still have your data stored in a file.

Pre-format an empty card by putting a big file onto it. Find out where the file starts and start writing from this sector.

Posted on October 17, 2012 at 16:19, updated link 6-May-2024

This is my Keil project for SDCard and FatFs on the STM32F4-Discovery

FATFS-DBG_Keil.zip

https://drive.google.com/file/d/0B7OY5pub_GfIa2k2MmFzelZFR1U/view?usp=sharing&resourcekey=0-b3etL_5Hvm1a2SU1uMgISQ

Unpack under project directory of Discovery library

Keil\ARM\Examples\ST\STM32F4-Discovery_FW_V1.1.0\Project\FATFS-DBG

This expects a suitably wired MicroSD socket (refer to other STM32F4-Discovery SDIO projects I've posted), and a serial port connected via USART2

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dmakhrov9
Associate II
Posted on October 17, 2012 at 16:27

Many thanks!

aambreen
Associate II
Posted on October 18, 2012 at 10:31

The project you shared is quite helpful but can you tell me where disk initialization function is being called?

Posted on October 18, 2012 at 13:35

It is called by FatFs and flagged within it's structures.

Use grep, or Find-In-Files to locate it's usage.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
aambreen
Associate II
Posted on October 22, 2012 at 12:15

@Clive

sorry for asking same questions again and again......as i already told you that i am a newbie so i am unable to comprehend your project in detail......i am running your code but it is neither initializing the card nor it is creating any file on sd card. I am using stm32f4 discovery board and i have excluded detect pin from my circuit.

Can you please tell me how should i go? the SD_Init() code you are using is not initializing my card :( i don't know why :(

russdx
Associate II
Posted on October 22, 2012 at 13:20

Sorry to butt in, Clive1 have you got any other stm32f4discovery projects available we could have a look at? id love to have a play with some of them :)

Posted on October 22, 2012 at 16:38

Can you please tell me how should i go? the SD_Init() code you are using is not initializing my card :( i don't know why :(

There are many reasons things can fail, you might want to break out the debugger and step through things, or review the error codes return. I'm using Micro SD cards, with a socket specifically wired, the system is going to be rather intolerant of this being done incorrectly. If you don't use the card detect, or move it to a different pin, you will need to adjust the code to accommodate the changes. The SD_Init() routines are called from within the diskio routines, along with all the other code that ties FatFs to the particular platform.

The SD Slot/Socket is expected to be wired as follows
CARDDETECT = PC2 (Retargetable)
CLK = PC12
CMD = PD2
D0 = PC8
D1 = PC9
D2 = PC10
D3 = PC11
VDD = 3V
VSS = GND
PC10 (SCLK) and PC12 (SDIN) potentially conflict with the CS43L22
The CMD, D0, D1, D2, D3 pins should have 33K or 47K pull up resistors.

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