Go Down

Topic: Waht is Max SD Size on newSparkfun Ethernet shield (Read 5941 times) previous topic - next topic


I just bought new Arduino Etherned with Micro SD card support
I am planning to use it with Arduino Mega 1280

What is the max micro SD size for fat16? How about Fat32?
Is this documented somwhere?


James C4S

FAT limits:
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com


Nov 09, 2010, 05:26 pm Last Edit: Nov 09, 2010, 05:54 pm by davekw7x Reason: 1
max micro SD size

Sparkfun and Adafruit both report that the new Ethernet Shield works with SdFat library.  Check out the ladyada tutorial.  I note that the tutorial uses half speed on the Arduino SPI bus.  I have not found that necessary for my designs. (See Footnote.)

I don't have the new Ethernet Shield, but I am using the SdFat library with SD and SDHC cards up to and including 8 GByte.  I haven't tried anything larger, since I don't have anything larger and I haven't had an excuse (or the discretionary funds) to buy anything larger.

I can create files with the Arduino and read/write/modify them on my PC systems (Windows and Linux).  I can create files on the PC and read/write/modify them on the Arduino.  (SdFat is limited to 8x3 file names, which is no big deal for me.)

The cards that I use come formatted as FAT32, and that's the way I use them.  I can't think of a single reason that I would want to reformat them to use FAT16 with any of my systems.  If your cards are formatted with a FAT16 file system, you can use them, just the way they come, with SdFat library with no modifications to the library.

Bottom line: I haven't found anything that doesn't work with the SdFat library, and I have never had to reformat an SD card to something other than what it came with.  I'm a big fan of SdFat.



I don't know whether the Ethernet Shield will work at Arduino's full SPI port speed or not, and I would like to hear from someone who has tried it.  My designs use logic device level shifter circuitry rather than the resistive voltage dividers used on the Official Arduino Ethernet Shield that you get from sparkfun or adafruit or other vendors.  I have never seen an error on my systems with the SPI port at full Arduino speed.

I am not an expert on all things SD, but I have read that later versions of the SD cards (the SDHC family) are somewhat sensitive to slow rise and fall times on the input signals.  Just a thought.  Maybe my concerns about the resistive level shifters are unfounded.

For simple data logging applications, I'm guessing that half speed is adequate.  The full speed SPI port gives me a couple of hundred KBytes/sec read speeds and write speeds, and, even at SPI port half speed, I'm thinking that will keep up with Ethernet speeds that you get with an Arduino system.

Or, as my namesake ancestor, DaveFarragut might have said:

"Damn the Resistors.  Half speed ahead!"


Thanks Dave and James

Looks like sky is the limit with Fat32
I connected Ethernet board with Mega328 and loaded http://www.ladyada.net/learn/arduino/ethfiles.html The sample app works ok (shows file and contents created using Win Vista). Looks like this Ethernet board connects to my router at 100mbit (the Ej60 board I have only does 10mbit). I am running Arduino v19 and sdfatlib20101010.zip and Kingston Micro SD 2GB. I believe it came formatted as FAT(16)
I also tried sample * SdFatWrite.pde* sketch but it fails with error: card.init failed SD error: 1,0  I tried few things but could not make it to work
At work I only just noticed troubleshooting page, plenty to try out: Full Speed, re-format SD as 32, try SanDisk micro SD, try to get 'older' sd card etc. I hope this is not due to resistor logic shift

If all else fails would there be an easy way to change Ethernet board from resistive voltage divider to logic device level shifter?

The most common problems are:
Wiring errors with card.init() failure and errorCode == 1.  This means the
first command, CMD0 - SPI init, failed.  Fat16 is not seeing the card.
card.init() failures caused by resistor SPI level shifters. Some, mostly older,
SD cards work with resistor level shifters but may be flaky with random errors.

Many newer SD cards have edge detectors and fail with errorCode() = 1.  These
cards will not work with resistor level shifters since Fat16 does not see the
card at low SPI clock rate.

Other cards fail with an errorCode() > 1.  These cards see SD commands at low
SPI clock rate but fail at higher SPI clock rate.  It may be possible to use
these cards by replacing card.init() with card.init(1).  This will slow the
the SPI clock by 50%.


I might have found the problem

In working WebServer example
if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");

In Write SD example ( think this defaults to pin 8
if (!card.init(SPI_HALF_SPEED)) error("card.init failed");


Looks like sky is the limit with Fat32

FAT32 apparently has an 8TB disc limit.  (That USED to be a horribly huge number.  It doesn't seem so huge anymore, with 2B drives being consumer items, and 8TB well within what I could actually connect to my computer...)


Hi All
Apology for late response and thank you very much for your input. The 8TB SD limit for 32 bit FAT is a very high capacity limit indeed

The reason I was getting an error when trying to access Micro SD is that SD Fat samples are written for SD card alone and I am using 'new' Ethernet Shield W5100 with micro SD
This shield has both Ethernet and SD thus so to use SD alone the Ethernet must be disabled. After disabling the Ethernet PIN 10 the micro SD card started to rock

 digitalWrite(10, HIGH);      // *MUST DO THIS* when using Ethernet Shield with MicroSD from SparkFun - turn off the W5100 chip!

I am using SDFat 32 library & Web Server example http://www.ladyada.net/learn/arduino/ethfiles.html -> http://code.google.com/p/sdfatlib/downloads/list

I tested both the web SD browser example and *SdFatAppend.pde* example modified to log elapsed time every 100 appends. (Just bought new Kingston Micro SD China ~$7 USD)
Surprisingly the average times for appending 100 records x 100 times are similar for half and full SPI speed
I repeated the test and re-format SD few times, so far no faults/errors.

Half SPI speed average 375 ms
Full SPI speed average 354 ms

Noticeably 1st write was slower for half speed 890 v 571 ms. Happy to post details

I hope I did not miss anything
Code: [Select]
* Append Example
* This sketch shows how to use open for append and the Arduino Print class
* with SdFat.
Nov 2010 Modified by PeterSek to run on 'new' Arduino Ethernet Shield W5100 with micor SD
#include <SdFat.h>
#include <SdFatUtil.h> // use functions to print strings from flash memory

Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
SdFile fileLog;

// store error strings in flash to save RAM
#define error(s) error_P(PSTR(s))

void error_P(const char* str) {
 PgmPrint("error: ");
 if (card.errorCode()) {
   PgmPrint("SD error: ");
   Serial.print(card.errorCode(), HEX);
   Serial.println(card.errorData(), HEX);

void setup(void) {
 PgmPrintln("Type any character to start");
 while (!Serial.available());

// Nov 2010 Modified by PeterSek to run on 'new' Arduino Ethernet Shield W5100 with micro SD
 pinMode(10, OUTPUT);         // set the SS pin as an output
 digitalWrite(10, HIGH);      // *MUST DO THIS* when using Ethernet Shield with MicroSD from SparkFun - turn off the W5100 chip!
 // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
 // breadboards.  use SPI_FULL_SPEED for better performance.
 if (!card.init(SPI_FULL_SPEED, 4)) error("card.init failed");  //FULL
//if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed");  //half

 // initialize a FAT volume
 if (!volume.init(&card)) error("volume.init failed");

 // open the root directory
 if (!root.openRoot(&volume)) error("openRoot failed");
 char name[] = "APPEND.TXT";
 PgmPrint("Appending to: ");

 // clear write error
 file.writeError = false;
 unsigned long tBefore;
 for (uint8_t i = 0; i < 100; i++) {
   tBefore = millis();
   // O_CREAT - create the file if it does not exist
   // O_APPEND - seek to the end of the file prior to each write
   // O_WRITE - open for write
   if (!file.open(&root, name, O_CREAT | O_APPEND | O_WRITE)) {
     error("open failed");
   // print 100 lines to file
   for (uint8_t j = 0; j < 100; j++) {
   if (file.writeError) error("write failed");
   if (!file.close()) error("close failed");
   if (i > 0 && i%25 == 0)Serial.println();

   fileLog.writeError = false;
   if (!fileLog.open(&root, "log.txt", O_CREAT | O_APPEND | O_WRITE)) {
     error("openLog failed");
   fileLog.print(" millis = ");
   fileLog.println(millis() - tBefore);    
   if (fileLog.writeError) error("writeLog failed");
   if (!fileLog.close()) error("closeLog failed");
void loop(void){}

void writeLine(unsigned long t){
     file.print("line ");
//      file.print(j, DEC);
     file.print(" of pass ");
//      file.print(i, DEC);
     file.print(" millis = ");

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131