cancel
Showing results for 
Search instead for 
Did you mean: 

FAT32 problem stm32f205

enturk
Associate II
Posted on November 30, 2011 at 08:45

Hi Everybody,

i m working on a project that needs data logging. I use FATFs ( Chan-FAT32 ) but i have a problem that described below:( I've formatted the SD card on PC with FAT32 )

I try to create a .txt file, and created correctly in STM32F205. I try to save long data ( about 700Mbytes ) on an SD card with 1 GB capacity. I plugged the SD card into my PC, there appears a .txt file in size of 700Mbytes, coreectly. But I opened the file in PC, 480 MB of 700 MB has meaningful data, the rest has null data. After that, i created two files on SD, one is 300 MB( first created ) the other is 400 MB ( second created ). I plugged the SD card into PC again. Total size is correct. File which first created(300MB) has meaningful data. 180 MB of second file (400MB) has meaningful data but rest of it has null data. 

As a result, i only write 480 MB meaningful data but rest is null data. I couldn't find any bug. Is there anybody who faces with the same problem? How can i overcome this problem?

Thank you very much.

#fat32-sdio-dma
17 REPLIES 17
domen23
Associate II
Posted on November 30, 2011 at 15:04

How do you generate your data?

Try writing some constant pattern, eg. ''abc\n''.
enturk
Associate II
Posted on November 30, 2011 at 15:37

I generate my patern with using known characters. For example ;

My patern starts with ''Dogum yeri\r\n'' and continues character 'E'. Length of the data 4096 bytes. I open the file, write this data for thousand times continuously

 until reaching the size of 700MB. Then i close the file.

infoinfo989
Associate III
Posted on November 30, 2011 at 17:50

I don't know what your problem is, but I can tell you I'm using the ChanFS code on a '205, and I'm writing multiple large files without problems. Chances are the Chan code per-se is not your problem.

You might want to start by writing data ''raw'' to the SD card using the basic SDIO write functions, then read it back to verify its correct. Once you're confident in the lower-level stuff you can then try again using the ChanFS code.

enturk
Associate II
Posted on November 30, 2011 at 19:40

Hi Frank,

Thanks for your reply. 

Did you make any change in FATFs code?

Have you ever written long size data in .txt file ( longer than 500 Mbytes ) using this FATfs?

Thank you very much.

infoinfo989
Associate III
Posted on November 30, 2011 at 20:55

I have not made any changes to the FatFS code. The only file that needs changing is the diskio.c file.

.txt is just a file extension, part of the filename - there is nothing special about a .txt extension versus anything else. The files I make are many MB in size.

enturk
Associate II
Posted on November 30, 2011 at 21:03

Hi,

I have tested the low level code ( sdio.c ), it s working. I wrote and read the SD card fully. No problem, but fatfs. I try to find a way to solve this problem.

Thanks for your interest.

infoinfo989
Associate III
Posted on December 01, 2011 at 05:03

Just keep in mind that the ChanFS code will ''hop around'' in its writing and reading of the SD card. Because it not only needs to write the data you're giving it, but it also needs to update the FAT tables and directory entries on the card as well. So when you're doing your low-level card reads and writes to test out your basic SD code, make sure you do this ''hopping around'' as well.

enturk
Associate II
Posted on December 01, 2011 at 12:44

Hi Frank;

Thanks for your reply.

Could you send me your DMA configurations, pls? I wanna compare with mine.

How many bytes do you write while using f_write command? Do you declare your buff as ''static'' in application layer? 

I realized that there occures an error after i write multiblocks data about 200MB. But single block writing has no problem.

Thank for your opnions.

infoinfo989
Associate III
Posted on December 03, 2011 at 00:21

Could you send me your DMA configurations, pls? I wanna compare with mine.

Just look at the ST code for the SDIO - I use the same DMA setup as ST does. There's not much to it anyway - for SDIO the peripheral is the DMA flow controller, so the SDIO does much of the work.

How many bytes do you write while using f_write command?

The amount of data we write varies a lot - anywhere between 4 bytes and 16 kB.

Do you declare your buff as ''static'' in application layer?

Yes and no - some buffers are declared as static, some as const, and some just uint8_t.

 

I realized that there occures an error after i write multiblocks data about 200MB. But single block writing has no problem.

That could very easily be true. There are many documented problems and limitations with the ST-supplied SDIO example code. Read the various threads on this forum.