cancel
Showing results for 
Search instead for 
Did you mean: 

FATfs Writing Data to Created Files Issue

evans
Associate
Posted on July 31, 2012 at 15:05

Greetings,

I have been working with implementing FATfs for reading and writing to a microSD card. This is being done on an STM32L discovery board in the IAR Embedded Workbench environment.

The issue that I am having is that although the files are being created on the disk, the data that I am trying to write rarely appears in the files, though I have had a few successes. I believe that my setup for the disk write and read routines are correct as I can write and read raw bytes to and from the SD card, as well as my SPI and card connections as initialization and communication of the card can be achieved. I am using a general mount-open-write-close-demount format to attempt these writes.

I'm inquiring if anyone might have any thoughts on why these writes would not consistently happen or some other testing that I might be able to do in order to understand this problem. Stepping through the ff.c code for f_write and f_sync do not go to any obvious error paths and I am unsure what else to try.

#stm32l---discovery #fatfs #microsd
4 REPLIES 4
Posted on July 31, 2012 at 15:33

What size is the SD Card?

Consider also instrumenting the routines in diskio.c so you can understand what's going on in there, and perhaps do some analysis of the FAT structures so you can confirm it is doing the right thing, or where it might be putting the data.

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

Hi, 

I'm trying to do pretty much the same thing. 

Could I see your code ?

Here is my mail: mp634@york.ac.uk

We should be able to do it !!

Thanks,

Mickael.

Posted on August 06, 2012 at 16:27

I'm not using IAR or the STM32L1xx, but I have SD and FatFs working on several other STM32 devices and boards.

This thread might be worth a review, runs 2 pages

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/ST32f4discovery%2Bsdcard%2Bfatfs problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=597]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FST32f4discovery%2Bsdcard%2Bfatfs%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=597

The source

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Attachments/23511/fsfatdemo4disc_rev2.zip

The makefile needs fixing so HSE_VALUE=8000000, but the code might prove of interest despite the different chip and tool chain.

For the L152 you might want to go dig through the example code for the EVAL board provided in the assorted firmware library releases.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Wood.Andy
Associate III
Posted on September 12, 2012 at 15:25

Hi Clive

Thanks for adding your example code, got it working on Atollic in no time at all, saved me a load of time 😉

Thanks

Andy.