Go Down

Topic: SdFat with Long File Names - smaller than SD.h with 8.3 names (Read 4648 times) previous topic - next topic

fat16lib

I posted a new SdFat beta with full support for Long File Names here https://github.com/greiman/SdFat-beta.

Long File Name support is optional so I decided to compare the size of SD.h with the new SdFat.

I used a simple program that creates a file, wtite a line to the file, and closes the file.  Here is the test program.

Code: [Select]

// Program to compare the size of SdFat with the SD.h library.
// Select the test library by commenting out one of the following two lines.
// #include <SD.h>
#include <SdFat.h>

// SD chip select pin.
const uint8_t SD_CS_PIN = SS;

#ifdef __SD_H__
File file;
#else  // __SD_H__
SdFat SD;
SdFile file;
#endif // __SD_H__

void setup() {
  Serial.begin(9600);
  while (!Serial) {}  // wait for Leonardo

  if (!SD.begin(SD_CS_PIN)) {
    Serial.println("begin failed");
    return;
  }
  #ifdef __SD_H__
  file = SD.open("SFN_file.txt", FILE_WRITE);  
  #else  // __SD_H__
  file.open("LFN_file.txt", O_RDWR | O_CREAT);
  #endif  // __SD_H__
  
  file.println("Hello");
  file.close();
  Serial.println("Done");
}
//------------------------------------------------------------------------------
void loop() {}


Here are the sizes using 1.0.6 with an Uno.
Quote
SD.h  SFN 13,286 bytes

SdFat LFN 11,112 bytes (SD.h program is 19% larger)

SdFat SFN  9,670 bytes (SD.h program is 37% larger)
So, if you don't need LFN, SD.h is 37% larger.  You can use LFN and SdFat is still smaller.

SdFat now has a comparability mode API so converting from SD.h to SdFat is easy.

Here are some other features of the new SdFat.

Quote
Replaced the core SdFat code with FatLib, a generic FAT12/FAT16/FAT32
library.  This may result in some backward compatibility problems.

Added SdFatSoftSpi, a software SPI template class.  See the SofwareSpi
example.

Added SdFatLibSpi, a class that uses the Arduino SPI.h library.

Allow simultaneous use of hardware and software SPI with multiple cards.
See the ThreeCard example.
 

Added the "File" class for compatibility with the Arduino SD.h library

Added StreamParseInt example to demonstrate the SD.h API.

robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

ghlawrence2000

#2
Dec 07, 2014, 02:52 am Last Edit: Dec 07, 2014, 02:54 am by ghlawrence2000
Now SdFat is so mature and complete with LFN, you will have plenty of time to start with NTFS for DUE?  :smiley-wink:  :smiley-grin:  

Why don't the Arduino team implement SdFat into the core functions? Performance wise it is better, memory footprint is shown to be smaller, what possible arguments can they have to not include it as the default?

Regards,

Graham

+1
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

guix

I wanted long file names since a long time, thank you ;)

sorin171

Thank you! I had sucess to my project!  :smiley-mr-green:

obs: For the perfect function of Library this is necessary install Arduino 1.0.6, because Arduino 1.0.5 don't function.

Best regards!!!

Go Up