Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Write Throughput

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> KokkeKat FAT-free SD card lib
View previous topic :: View next topic  
Author Message
twesthoff

Bascom Member



Joined: 16 Dec 2005
Posts: 6

usa.gif
PostPosted: Wed Jul 13, 2011 2:08 am    Post subject: Write Throughput Reply with quote

Niclas,
Have you done any testing to determine how fast (bytes per second) it will write a file to the SD card?
For example, how long does it take to write a 10Mbyte file?

I would be interested in your thoughts as to make writing as fast as possible, even if using a lot of RAM.
I have read about a block write mode where up to 32Kbytes can be written at one time. I do not totally understand how this works, but am interested in optimizing the write speed as much as possible.

Writing one byte at a time seems to be slow way to do it.
Tom
Back to top
View user's profile
KokkeKat

Bascom Member



Joined: 08 May 2011
Posts: 59
Location: Stockholm

sweden.gif
PostPosted: Wed Jul 13, 2011 4:09 pm    Post subject: Reply with quote

Hi Tom

I think that your questions and goal are relevant and interesting, but I haven't done any performance testing. I'm afraid I won't have time to write the code, but it should be reasonably simple to do.

Please notice that the current functionality is doing 512-byte sector writing to the card, so it's not that bad. Each time you call Sdwritebyte, it increments the array pointer, checks if it needs to save to the card (because of sector boundary crossing), stores the byte in the 512-byte array, and increments the file size counter. It is a number of operations, but it isn't byte-by-byte writing.

Anyway, here's what you need to do:

Please see the SD specification document found in the library zip file. Look at 7.2.4 "Data Write" on pages 117-118.

I don't know what is the limitation to how many 512-byte consecutive blocks you can send, but I couldn't find it in the specs when I looked briefly. I think the practical limitation is the number of sectors per cluster, in case you want to use FAT32, at least up to a certain card size. This means your application should be able to adapt to the inserted SD card's formatting and send the data for each cluster in one CMD25 multiple blocks transfer. (Never more than on cluster per transfer!)

This might mean that you will have to experiment to see how many 512-byte blocks your SD cards can actually handle in one transfer. Please be aware that there might be differences in the various manufacturers' interpretation of the SD standard, so what works on one card might not work on another. Try a 32GB and a 16GB SDHC and (if you think it's worth it) a 64GB SDXC.

There might also be SD card timeout considerations due to data collection CPU time, but I don't know what they are. (If you truly want high speed writing, you need to collect and write the data concurrently.)

You need to do something like this:
* Copy Sdwritesector: and split it into 3 parts:
___Sdwritesectorsa: sends CMD25 instead of CMD24 and sets the addressing mode
___Sdwritesectorsb: sends start token, 512-byte data block plus dummy CRC, receives response token, handles response, and waits until not busy
___Sdwritesectorsc: clocks SD, sets !CS, and clocks SD
###Repeat step b for each sector (512-byte block) you want to send

* Copy Sdwritebyte: and modify it so that it operates on a cluster and/or sectors instead of bytes. It has to keep track of the total number of characters your file gets (excluding the final empty bytes and sectors) - otherwise your file will seem to contain garbage at the end.

There might be additional steps for you to take, but this should get you started at least.

Please keep me posted on your progress. It would be nice if we could add this to the library.

Kind regards

Niclas
Back to top
View user's profile
twesthoff

Bascom Member



Joined: 16 Dec 2005
Posts: 6

usa.gif
PostPosted: Thu Jul 14, 2011 4:17 am    Post subject: Reply with quote

Niclas,
Thank you for the detailed response. It will be some time before I get the hardware set up and can try this, but I hope to be able to do it.

If you get some time and could test how long it takes to write a 10Mbyte file, just writing a random string over and over for example, I would appreciate you posting your result. (Or anyone else who has the hardware setup.) No modifications, just the code as it is now.

I appreciate your work with the SD card code!

Tom
Back to top
View user's profile
KokkeKat

Bascom Member



Joined: 08 May 2011
Posts: 59
Location: Stockholm

sweden.gif
PostPosted: Thu Jul 14, 2011 1:28 pm    Post subject: Reply with quote

Hi Tom

Thanks!

I'll do it as soon as I can find the time. (I will be away on work and holiday in the next two weeks but I will post the result here then.)

Kind regards

Niclas
Back to top
View user's profile
glena

Bascom Member



Joined: 25 Jul 2007
Posts: 284
Location: PA near Philly

usa.gif
PostPosted: Fri Sep 02, 2011 4:47 pm    Post subject: Reply with quote

If your looking to do some basic speed tests to an SD card this may help but would need to be modified for xmega.

http://mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=7622&sid=6145c915a26e814c79c9c014cbad9199

Let me know if you get it working and how fast it is on the Xmega parts.

-Glen

_________________
http://bahbots.com
Back to top
View user's profile AIM Address
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> KokkeKat FAT-free SD card lib All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum