cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4Discovery FAT FS

hillpatrickb
Associate II
Posted on May 04, 2013 at 06:01

I am trying to implement at FAT FS on the STM32F4 Discovery board...the firmware package provided by st supplies third party files.  But are these files enough to implement the FAT FS on the STM32F4 board? Or is there more files that I need to write myself?

#sdcard-stm32f4-sdio-fatfs #stm32f4
6 REPLIES 6
Posted on May 04, 2013 at 06:29

You might have to do some porting, and modifying the pin utilization to match how you wired it up. But generally the files are what you need.

Been there, done that. [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32%20sdio%20sdhc%204gb%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=102]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32%20sdio%20sdhc%204gb%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=102
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hillpatrickb
Associate II
Posted on May 09, 2013 at 04:16

Thank you for your quick response I appreciate the example...I was able to compile my code and now I am working through a new problem.  I am multiple functions that are using the f_open, f_write and f_close to write data onto my sd card.  These functions are called based upon the state of my system and that state is what I am sending to the sd card.  But when I run my tests of different states of the system then take the sd card and put it into my computer, only the final system state is saved on the sd card.  Do you why this could be happening?

AvaTar
Lead
Posted on May 09, 2013 at 16:38

Try calling

f_sync()

after each write operation, equivalent to

fflush

() on OS based code.

hillpatrickb
Associate II
Posted on May 09, 2013 at 23:15

I was told that if I f_open, f_write and f_close then if I try to f_open, f_write and f_close again the code will overwrite the old data.  So I am trying to just f_mount and f_open the file once and f_write in other areas of my code.  But by doing this my code is getting stuck in the diskio file trying to get the status of the sd card...do I need to have the f_write function right after the f_open function?

Posted on May 10, 2013 at 00:34

I was told that if I f_open, f_write and f_close then if I try to f_open, f_write and f_close again the code will overwrite the old data.

 

By whom? The documentation for FatFs is reasonably through, and not too dissimilar to STDIO.

f_open() doesn't have to overwrite the file, it's quite easy to f_open(),f_lseek(),f_write(), and f_close() to incrementally add to a log file.

If you keep the file open over a long period, you'll have to be sure the card isn't removed, reset or powered down. I would stick to the former method.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Writing%20on%20USB-Memory&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=85]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FWriting%20on%20USB-Memory&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=85

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hillpatrickb
Associate II
Posted on May 14, 2013 at 04:45

Thank you for your help Clive1...I got it all working. You're the best.