Thanks for the FatFS example. I was about to do this so I could compare the new LFN version of SdFat I am developing with FatFS. I wanted to see how much RAM FatFS uses for LFN. I want Long File Names to be practical on Uno.
You use lots of RAM for string literals and your program tests lots of FatFS features but it still appears I am way ahead of FatFS for RAM use.
Your test program on a Mega:
Sketch uses 27,694 bytes (10%) of program storage space. Maximum is 253,952 bytes.
Global variables use 4,219 bytes (51%) of dynamic memory, leaving 3,973 bytes for local variables. Maximum is 8,192 bytes.
This little test program creates a directory and a file with Long File Names. It then writes a line of text to the file.
#include <SPI.h>
#include <SdFat.h>
SdFat sd;
SdFile dir;
SdFile file;
void setup() {
Serial.begin(9600);
if (!sd.begin()) {
Serial.println("begin failed");
return;
}
dir.mkdir(sd.vwd(), "A test directory");
file.open(&dir, "A SdFat LFN.txt", O_RDWR | O_CREAT);
file.println("Hello");
file.close();
Serial.println("Done");
}
void loop() {}
It uses this much memory on a Mega.
Sketch uses 12,972 bytes (5%) of program storage space. Maximum is 253,952 bytes.
Global variables use 935 bytes (11%) of dynamic memory, leaving 7,257 bytes for local variables. Maximum is 8,192 bytes.
Here is a list of the SD on a PC.
H:>ls -Rl
.:
total 0
drwxr-xr-x 1 bill None 0 Jan 1 2000 A test directory./A test directory:
total 16
-rw-r--r-- 1 bill None 7 Jan 1 2000 A SdFat LFN.txt
The new SdFat is based on a new generic FAT12/FAT16/FAT32 core, like FatFS, so I may try USB mass storage next. Not likely that will fit a Uno.