Shop OBEX P1 Docs P2 Docs Learn Events
How fast can a Prop write to a FAT32 SD Card? — Parallax Forums

How fast can a Prop write to a FAT32 SD Card?

FlyingFishFingerFlyingFishFinger Posts: 461
edited 2010-09-12 11:27 in Propeller 1
Hi-
We've been looking for a relatively easy way to log CAN data to an SD card. CAN specifies that one can run it at up to 1Mb/sec, but our CAN Architect tells me we won't be running any faster than 500Kb/sec, max.
Is there any way the existing drivers (E.g FSWR, Kye's Implementations) can log this fast? If not, is there a good way of logging CAN data this fast?
Thanks

Rafael

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-11 21:38
    This is not a simple question because the write speed for an SD card is dependent on the processor in the SD card and how much buffering is available in the SD card. Different manufacturers use different algorithms for space allocation and wear levelling.

    For example, when a write buffer is full, the SD card's processor has to write it to where it thinks that sector is located. There's a limit on how many times a sector can be written, so the processor may decide to write that sector to a different part of the SD card and it has to go back and copy the physical sector (which may contain quite a few logical sectors) to a new place on the SD card and update some markers to show where that physical sector resides. This whole process may take 10s of milliseconds or more.

    One way to handle this is to allocate a fixed logging file on the SD card larger than the largest log file you'll need or perhaps a series of fixed logging files that, together, provides enough storage. You'd use FSRW to build a table of absolute sector addresses and sizes for these files and use a low-level sector write routine that accepts absolute sector addresses to write the log data. You could modify either Kye's low-level routines or the low-level FSRW routines to run in their own cog writing from a large pool of sector buffers. I know the FemtoBasic low level SD card routines can do this and I'm sure any of the others can be made to work this way and they'd be faster.

    You'd need enough buffers for a sizable fraction of a second of log data.
  • lonesocklonesock Posts: 917
    edited 2010-09-11 21:44
    In the latest version of FSRW 2.6, you can get sustained average write speeds of ~ 800 K Bytes / s. If you use Mike's trick and raw writing, you can get 2x that. I don't know about Kye's drivers. As Mike mentioned the SD card's will hiccup occasionally, so these are average speeds, and you will want to buffer as much as possible.

    Jonathan
  • KyeKye Posts: 2,200
    edited 2010-09-12 04:50
    Mine aren't designed right now to be fast. I have a new release coming out that makes my code run fast however. (By coming out I mean that I wrote some stuff and may post it in a long time from now...).

    Due to how my file system works currently you can't just switch out the block driver and hope to get much faster write speeds.
  • FlyingFishFingerFlyingFishFinger Posts: 461
    edited 2010-09-12 10:42
    @lonesock:
    800K BYTES? That is a lot. Did you mean bits? Either way, that seems sufficient for our purposes.
    Thanks!

    Rafael
  • lonesocklonesock Posts: 917
    edited 2010-09-12 11:13
    @lonesock:
    800K BYTES? That is a lot. Did you mean bits? Either way, that seems sufficient for our purposes.
    Thanks!

    Rafael
    Writing speed is ~ 800,000 bytes per second. [8^)

    Jonathan
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2010-09-12 11:27
    Here are the stats I get with the 'test' program set to use 'mb_rawb_spi' on a SanDisk 2GB microSD
    Clock: 80000000 ClusterSize: 32768 ClusterCount: 60282
    Raw write 1920 kB in 2218 ms at 865 kB/s
    Raw read 3968 kB in 2445 ms at 1622 kB/s
    fsrw pwrite 2016 kB in 2332 ms at 864 kB/s
    fsrw pread 2016 kB in 1542 ms at 1307 kB/s
    FSRW pputc 63 kB in 2300 ms at 27 kB/s
    FSRW pgetc 63 kB in 1837 ms at 34 kB/s
    All done!
    

    Is that test program still up to date?
Sign In or Register to comment.