SD library bug???

Hi guys!
My device has SD-card datalogger, but there is periodically data lost while this one works:

Datalogger uses SD.h. 2GB SD is connected via SPI.
How can I write data without FAT (using SD as memory block)?
Or maybe is there the "fast FAT" version of SD.h?
Now speed of data write is about 25Hz, but I need 100Hz+. :frowning:
Please help to decide this problem.

SD cards must be written in 512 byte blocks and random long write latencies are a prosperity of all SD cards. The SD spec allows occasional write delays of up to 250 milliseconds on a write but typical cards have occasional delays of more like 40-80 ms. A major reason for these delays is wear leveling of flash memory. Another reason is that flash erase groups are very large in SD cards which can cause the card to be busy.

To write fast, you need a large buffer and multiple threads or you can capture the data in an ISR and buffer it.

I have posted programs using both of these methods at http://code.google.com/p/beta-lib/downloads/list.

AnalogIsrLogger20121219.zip uses an ISR to capture data.

ChibiOSBeta20121217.zip is a more general approach and uses ChibiOS/RT to run separate threads for data capture and writing to the SD. There are two data logger examples, one for Uno and one for Mega.

fastLoggerBeta20110802.zip has some additional examples of these methods but is somewhat out of date.

What about technique of memory-mapping?
Can I write (or read) data to (virtual base pointer + offset) to except SDfat approach at all? Just memory operations without files etc.

Yevdokimenko:
What about technique of memory-mapping?
Can I write (or read) data to (virtual base pointer + offset) to except SDfat approach at all? Just memory operations without files etc.

Well but if you keep data in ram you lose it at each reset... What do you mean ?

No, I'm talking about approach of using SD via linear memory space.
For example, ((*byte)EEPROM_Base+Offset). Similar approach is used to access external RAM, after enabling this one in MCU regs.

Sorry, memory mapped files on SD are not possible in this architecture.

-br

No, I don't need files, FAT, etc! :slight_smile:
I just wanna use SD card like a piece of memory, or memory space.
Is it unreal too?

Even eeprom address space is not mapped in ram address space.

Plus, SD card is accessed through SPI.

Plus, how would you access all of an SD card space (e.g. 4GB) with the limited MCU addresses ?

I think you could, however, write a class with an operator[] that would take care of accessing the SD card somehow (perhaps reading and writing bytes in a big file). That would be quite close to what you want, I think.

I don't see /why/ you're trying to do this. IMHO too much abstraction is /bad/ in a resource constrained environment like an MCU.