I am having issues with the SD card initializing when the device is first powered up. If i eject the card and reinsert it while the device is running then it will start working.
I am running genuine arduino 2650 and Ethernet shield R3 (v6).
What is really strange is if i use the networking with the sd card and reinsert the card after boot up I have no issues serving web pages off of it.
Here is the code i am running:
const int chipSelect = 4;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("SS: ");
Serial.println(SS_PIN);
Serial.print("MISO: ");
Serial.println(SPI_MISO_PIN);
Serial.print("MOSI: ");
Serial.println(SPI_MOSI_PIN);
Serial.print("SCK: ");
Serial.println(SPI_SCK_PIN);
Serial.print("PIN4: ");
Serial.println(PIN4);
Serial.print("\nInitializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(53, OUTPUT); // change this to 53 on a mega
// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card is inserted?");
Serial.println("* Is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
return;
}
else {
Serial.println("Wiring is correct and a card is present.");
}
// print the type of card
Serial.print("\nCard type: ");
switch (card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
break;
default:
Serial.println("Unknown");
}