SD card random read speed increase?

I am reading single bytes from a file in an SD card in a random order... is there any way to speed this operation up?

At present I open the file once during initialization and it stays open indefinitely, so this is not the source of my trouble.

To read a byte I do:

dataFile.seek(byteIndex); dataFile.read();

And this typically takes about 60 us to complete provided I'm reading bytes near each other in the file.

If I try to read bytes more than 512 bytes apart in the file, the next read takes 1200us. There must be some type of 512 byte buffer in the SDFat library, or maybe a page size issue with the SD card??

Regardless, is there are way to avoid the 1200us slowdown? I'd like to be able to read a byte anywhere in the file in under 500us.

Regardless, is there are way to avoid the 1200us slowdown? I'd like to be able to read a byte anywhere in the file in under 500us.

An entire 512 byte block must be read from an SD. You will never achieve less than 500 us. It will take much longer for a large seek since blocks must be read from the FAT (file allocation table) to find the correct data block..

You can avoid the extra I/O for FAT blocks by using a contiguous file with SdFat and do raw reads.

How large is your file? If it is small enough you could use an SPI RAM, pito has posted several topics about an 8 MB module.

I was actually trying to convert this application to SD from SRAM/FLASH because I need more storage - about 130Mbytes.

I can easily achieve that level of capacity with RAM, but then I have to load the files onto it with serial data via the Arduino... which is SLLLLOOOOWWWW.

EDIT: I suppose I could move data to RAM from the SD card via SPI. I assume a sequential read would be faster...

about 130Mbytes. ... I can easily achieve that level of capacity with RAM

How do you plan to do this?

I suppose I could move data to RAM from the SD card via SPI. I assume a sequential read would be faster...

SPI on AVR is slow since it is at not DMA and at 8 MHz max.

My guess is that a copy from SD to RAM will be at 250 KB/sec or less. 130 MB will take 8-10 minutes.

fat16lib:

about 130Mbytes. ... I can easily achieve that level of capacity with RAM

How do you plan to do this?

I have my application working [with a limited amount of storage] using a bank of 1MB flash ICs: Winbond W25Q80BVDAIG. Nothing fancy, no need for Dual/Quad SPI.

I have some W25Q128FV's on hand which are similar devices but 16x larger though I haven't tried them out yet - I don't see any red flags in the datasheet.

fat16lib:

I suppose I could move data to RAM from the SD card via SPI. I assume a sequential read would be faster...

SPI on AVR is slow since it is at not DMA and at 8 MHz max.

My guess is that a copy from SD to RAM will be at 250 KB/sec or less. 130 MB will take 8-10 minutes.

Hmm. Point.

Well then I'll have to use the FLASH ICs and come up with a way to write to them quickly with USB or Bluetooth.

:(

Well then I'll have to use the FLASH ICs and come up with a way to write to them quickly with USB or Bluetooth.

The W25Q128FV has a typical program time of 0.7 ms for a 256 byte page. It will also be very slo for write.

0_0

So it does, I must have read that as 0.7 us previously.

Any suggestions?