Bill Greiman
Well-known member
I am working on a new SD library for exFAT formatted SD cards. This library supports exFAT but not FAT32/FAT16 since I want the library to run on an ATmega328.
There is now a 1TB SanDisk card so an Uno could write a 1 TB file in about 40 days. This assumes a write speed of 300 KB/sec. A Teensy 3.6 could do it in less than a day.
I spent a lot of time analyzing existing exFAT implementations and developing faster smaller algorithms for this library.
I have the basic functions implemented in prototype form and its size/speed is promising. I expect the size to increase as I add error checks and reliability features. I hope this sketch will be under 16 KB on an Uno with ASCII file names.
This version has these major functions:
Here is a test sketch:
Eventually I will refactor the SdFat code like this library and introduce a Linux like virtual file level so I won't have the nasty problem of combining FAT16/FAT32 code with exFAT code in a single library.
There is now a 1TB SanDisk card so an Uno could write a 1 TB file in about 40 days. This assumes a write speed of 300 KB/sec. A Teensy 3.6 could do it in less than a day.
I spent a lot of time analyzing existing exFAT implementations and developing faster smaller algorithms for this library.
I have the basic functions implemented in prototype form and its size/speed is promising. I expect the size to increase as I add error checks and reliability features. I hope this sketch will be under 16 KB on an Uno with ASCII file names.
This version has these major functions:
Code:
open()
close()
remove()
mkdir()
rmdir()
read()
write()
seek()
sync()
Here is a test sketch:
Code:
// Example exFAT test sketch
#include "SdFs.h"
SdSpiAltDriver spi;
SdSpiCard card;
FsVolume sd(&card);
File file;
const uint8_t CS_PIN = 10;
#define error(s) {Serial.println(F(s));return;}
void setup() {
Serial.begin(9600);
Serial.println(F("Type any character to begin"));
while (!Serial.available()) {yield();}
if (!card.begin(&spi, CS_PIN, SD_SCK_MHZ(50))) error("card begin");
if (!sd.begin()) error("sd.begin");
if (!file.open(&sd, "Test.txt", O_READ | O_WRITE | O_CREAT)) error("sd.open");
file.println(F("Hello World!"));
if (!file.close()) error("close");
Serial.println(F("Done"));
}
void loop() {}
Code:
With ASCII file names.
Sketch uses 13,848 bytes (42%) of program storage space. Maximum is 32,256 bytes.
Global variables use 865 bytes (42%) of dynamic memory, leaving 1,183 bytes for local variables. Maximum is 2,048 bytes.
Code:
With Unicode file names.
Sketch uses 14,800 bytes (45%) of program storage space. Maximum is 32,256 bytes.
Global variables use 865 bytes (42%) of dynamic memory, leaving 1,183 bytes for local variables. Maximum is 2,048 bytes.
Eventually I will refactor the SdFat code like this library and introduce a Linux like virtual file level so I won't have the nasty problem of combining FAT16/FAT32 code with exFAT code in a single library.