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
tomas239955_stm1_st
Associate II
Posted on December 03, 2011 at 12:14

I use efsl system and before i eject the card i need to flush the caches by calling proper function, and after they are all data correct on my SD card.

Has your Chan system something similiar?

enturk
Associate II
Posted on December 03, 2011 at 21:20

Hi Tomas,

Thanks for your replying.

I write two files at same time, each file size is 300 MB, but meaningfull data of them is 240 MB. I can't write data more than 480 MB. ( Size of SD Card used is 1GB ). I think there is a limitation on Chan FATFs. ( I use FAT32. ). When i wrote one file which size is 700 MB, There is a meaningful data that size is 480 MB. So i try to find a solution for this problem. 

Thanks for your interest.

infoinfo989
Associate III
Posted on December 03, 2011 at 23:10

I write two files at same time, each file size is 300 MB, but meaningfull data of them is 240 MB. I can't write data more than 480 MB. ( Size of SD Card used is 1GB ). I think there is a limitation on Chan FATFs. ( I use FAT32. ).

Just for you, I did a test, and wrote two 1.5 GB files to a 4 GB card (chanfs fat32). No problems - both files are fine.

enturk
Associate II
Posted on December 03, 2011 at 23:22

Hi Frank,

Thanks alot.

I know, i take your time, sorry.

DMA confg. is below:

  SDDMA_InitStructure.DMA_Channel = SD_SDIO_DMA_CHANNEL;

  SDDMA_InitStructure.DMA_PeripheralBaseAddr = (u32)SDIO_FIFO_ADDRESS; // 0x40012C80

  SDDMA_InitStructure.DMA_Memory0BaseAddr = (u32)BufferSRC;

  SDDMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;

  SDDMA_InitStructure.DMA_BufferSize = 0;

  SDDMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

  SDDMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;

  SDDMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; 

  SDDMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;

  SDDMA_InitStructure.DMA_Mode = DMA_Mode_Normal; 

  SDDMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;

  SDDMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;

  SDDMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;

  SDDMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_INC4;

  SDDMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_INC4;

  DMA_Init( SD_SDIO_DMA_STREAM, &SDDMA_InitStructure );

  DMA_FlowControllerConfig( SD_SDIO_DMA_STREAM, DMA_FlowCtrl_Peripheral );

  /* DMA2 Stream3  or Stream6 enable */

  DMA_Cmd( SD_SDIO_DMA_STREAM, ENABLE );

Do you use same confg.? Could i learn it?

Thank you very much.

enturk
Associate II
Posted on December 04, 2011 at 17:20

Hi Frank;

Thanks for your replying.

 

I realised that there is no problem when i use SanDisk SD card(1GB). But i face the problem using Kingston SD card (1GB). 

Kingston: Erase Sector Size=128;

SanDisk: Erase Sector Size=32;

Does it cause the data loss?

Could you say to me what change I must do to use 2GB SD cards in Chan Fat32, pls?

Thanks for your help. Thanks alot.

infoinfo989
Associate III
Posted on December 05, 2011 at 21:59

The erase sector size should not affect anything except performance. On large cards the erase sector size can be quite large, however it is still fine to read and byte in units of 512 bytes for example. It can be useful to align the FAT32 filesystem on an erase block boundary to improve performance (write performance in particular) - Chan FatFS supports this ability.

I said it before but I'll say it again: look through this forum for other threads regarding SDIO. Your question about 2 GB cards is answered in another thread in here somewhere.

Everything I've found and tripped over with this processor, and the SDIO in particular, I've documented here:

http://www.frankvh.com/stm32-information.html

enturk
Associate II
Posted on December 20, 2011 at 09:48

Hi Frank,

Thanks for your replying. I couldn't write for along time.

The problem i faced is because of the fake Kingston SD cards. Bcz others are working.

Thanks alot.

damien2399
Associate II
Posted on January 09, 2012 at 10:24

Hi Frank,

Have you got a downloadable example using SDIO+FatFs on this chip ?

Thanks.