/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / FAT32 Optimized

Username:     
Password:     
             

Forum

# 1   2010-07-08 08:32:25 FAT32 Optimized

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

FAT32 Optimized

I'm working on the optimized version of FAT32 support for Primer2. I have a small question for anyone who worked with existing DosFS driver in CircleOS.

$1

Any comments appreciated. Currently i already wrote and tested a new Seek function and Read is almost complete. Unlike existing version my implementation uses less program space and faster due to removed division-with-reminder operation.

Expected release date - 12.06.10.
Stay tuned.

Last edited by ntrf.zns (2010-07-08 08:34:15)

Offline

 

# 2   2010-07-12 07:07:35 FAT32 Optimized

mdce
Member
Registered: 2009-09-25
Posts: 25

Re: FAT32 Optimized

Hi,
With class 6 microSD and some optimizations I get 1.2 MB/s of sustained read speed (not really satisfactory).
Can you obtain better results ?

Offline

 

# 3   2010-07-12 12:47:06 FAT32 Optimized

diabolo38
Member
Registered: 2010-03-12
Posts: 50

Re: FAT32 Optimized

i use the offset and filelen field to implemant kind of standard ftell  and feof;

Code:

u32 my_ftell(MY_FILE *stream)
{
    return stream->pointer;
}

/*
 not robust for over than "read only" mode opened !
 */
int my_feof(MY_FILE *stream)
{
    return stream->pointer>=stream->filelen;
}

I can  changed that easily of required .

about perf,  troughput is one thing but  acess time is another one i'm certainly even more concerned about. I did only few test but did already find that  write access time (1st one after file create) is quite bad (seen more 0.13sec), i guess it is certainly due to first time cluster alocation and fat update ?
I had to  changed my application file strategi due to this (save data about 3 time/sec to a single file rather than numbered file  )

Last edited by diabolo38 (2010-07-12 12:48:25)

Offline

 

# 4   2010-07-12 12:48:14 FAT32 Optimized

repzak
Member
Registered: 2008-03-05
Posts: 170

Re: FAT32 Optimized

Hello,

Will you also look into the SD card driver, because i think there are some issues, like when it transfers DMA it has a waile(finish) loop just afterwards, but is there coming and error, and the flag is not set, the driver will stock sad

Offline

 

# 5   2010-07-12 16:52:00 FAT32 Optimized

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: FAT32 Optimized

Sorry, everyone. Release is delayed for one day because my PC requires an urgent repair. I'm writing this using my notebook.

About performance: I think the primary issue is that FAT table is read too often. For example if file was written on an empty disk (or no files were previously deleted) numbers in FAT will be sequential and instead of reading FAT entry after each cluster you only need to read it once (well almost) and then read sequental sectors. I won't implement this in the first version but it's not too hard to do afterwards.

SD Card driver requires fixing to be able to read more than 4GB cards. This is because sdector number is multiplied in both FAT driver and USB-Mass-Store driver and then divided back in SD Card dirver. I'm not sure if this will introduce some incompatibilities with existing code but it affects performance.

One issue i already dealed with is unneded usage of division-with-remainder (DivMod) operation. It's replaced with additions and comparsions. No divisions involved anymore.

I haven't tried to use DMA mode for SD Card reading yet. If successful it will increase performance and allow async updates.

About write performance: writes are not trivial in FAT. Current implementation is stateless and it searches free clusters. But it could be done much more efficiently - instead of reading FAT sector for every fat entry (!) one can read FAT sector and analyse it (only FAT12 will have some problems). So i guess it realy can be optimized (about 128 times less SDCard readts per cluster).

The ultimate solution for FAT speed is to cache it. But this is additional 512 bytes of RAM used without any warning. So far i've considedred this solution as inappropriate as it would mess up with existing applications.

Last edited by ntrf.zns (2010-07-12 16:52:50)

Offline

 

# 6   2010-07-26 01:21:41 FAT32 Optimized

logictechs
Member
Registered: 2009-05-07
Posts: 68

Re: FAT32 Optimized

Is this optimization going to solve the writting problems I've been experiencing for a very long time now?

Offline

 

# 7   2010-07-30 01:40:31 FAT32 Optimized

logictechs
Member
Registered: 2009-05-07
Posts: 68

Re: FAT32 Optimized

Ok, I may have solved my file write problem.  I was tinkering with the dos.c file and found that if I change line 1389 from this:

if (DFS_div(fileinfo->pointer, SECTOR_SIZE).rem) {

to this:

if (DFS_div(fileinfo->pointer, SECTOR_SIZE).quot) {

things seem to work well.

Any input about this would be greatly appreciated!

What is the difference between .rem and .quot?

Offline

 

Board footer