/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / SDIO dosfs writefile problem

Username:     
Password:     
             

Forum

# 1   2009-04-18 08:31:58 SDIO dosfs writefile problem

ingenius
Member
From: Belgium
Registered: 2009-02-26
Posts: 10

SDIO dosfs writefile problem

Hello all,

When preforming mutch file writes to a ascii text file on the SD-card some lines get corrupted. It seems I get into trouble when passing the sector size limit of 512 bytes.
What is wrong here?
This is my writing code:

   sprintf(strMessage, "%04x %02x %02x %02x %02x %02x %02x %02x %02x 02x\r\n", RxMessage.StdId, RxMessage.DLC,RxMessage.Data[0],RxMessage.Data[1],RxMessage.Data[2],
RxMessage.Data[3],RxMessage.Data[4],RxMessage.Data[5],RxMessage.Data[6],RxMessage.Data[7]);

   for(y=0; y<500; y++)
   {
      if (!SDCardfault)
      {
        if (FS_WriteFile(&file_info,strMessage,&count,strlen(strMessage))
        {
          SDCardfault = 1;
        }
      }
    }

This is actually writen into the file:
The lines that jump out are wrong.
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00  00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
00000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 0 00 00 00 00 000000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00
0000 00 00 00 00 00 00 00 00 00

Offline

 

# 2   2009-04-19 03:19:50 SDIO dosfs writefile problem

FR4
Member
Registered: 2008-11-09
Posts: 26

Re: SDIO dosfs writefile problem

seems to be a problem of FS_SEEK. Have a look to this post:

http://www.stm32circle.com/forum/viewtopic.php?id=609

Offline

 

# 3   2009-04-27 19:17:44 SDIO dosfs writefile problem

ingenius
Member
From: Belgium
Registered: 2009-02-26
Posts: 10

Re: SDIO dosfs writefile problem

Hello All,

The FS_SEEK bug didn't provide a solution for the writefile problem.

Stream writefile smaller than the sector size (<512bytes) will corrupt the file. In my case some lines will not be saved correct. I think that the problem lies in the writefile function of DOSFS.

Apparently writefile of an incomplete sector will result is a sector read, buffer and then a sector write? I suspect that the error happens there.

Can anyone confirm/report this behavior?

For now I use a workaround. I only write in blocks of a complete sector (=512 bytes). This works fine.

bye

Offline

 

# 4   2009-04-28 09:53:29 SDIO dosfs writefile problem

Saulis
Member
From: Lithuania
Registered: 2009-04-09
Posts: 34

Re: SDIO dosfs writefile problem

physically, sd card hols nand flash memory, wich has pages in size of at least 512bytes, bigger flash's have pages in size of 1k(writing 2 times by 512byte at once) 2k(4 times 512bytes or 2 times 1k, or all at once)

Offline

 

Board footer