SD card...initialization failed Adafruit MicroSD

Ok, Found it.

Typo, that I made in the Libs SdFile.cpp for root.ls() ,
I pasted an #endif inserted on same line as w++,
so it was ignored - yielding endless loop.

I added this, to fix the ArduinoZero/NanoArm print() to feed back to UsbProgrammer as SerialPort :

#ifdef SERIALUSB_E
SerialUSB.print(...);
#else
Serial.print(...);
#endif

Initializing SD card...Wiring is correct and a card is present.

Card type: SDHC

Volume type is FAT16

Volume size (bytes): 3960733696
Volume size (Kbytes): 3867904
Volume size (Mbytes): 3777

Open Root:

Files found on the card (name, date and size in bytes):
SDCARD4G.TXT  2017--19 18:38:46 10
FILE01.TXT    2017--19 18:38:50 0
FILE02.TXT    2017--19 18:39:00 0
FILE03.TXT    2017--20 00:11:54 0
DIR01/        2017--20 00:12:06

--

- done!
  • don't understand why the PrintDir() func doesn't work though ... :
void printDirectory(File dir, int numTabs) 
{
  while (true) 
  {
    SerialUSB.println(".");

    File entry =  dir.openNextFile();
    if (! entry) 
    {
      // no more files
      break;
    }
    
    for (uint8_t i = 0; i < numTabs; i++) 
    {
      SerialUSB.print('\t');
    }
    SerialUSB.print(entry.name());
    if (entry.isDirectory()) 
    {
      SerialUSB.println("/");
      printDirectory(entry, numTabs + 1);
    } else {
      // files have sizes, directories do not
      SerialUSB.print("\t\t");
      SerialUSB.println(entry.size(), DEC);
    }
    entry.close();
  }

  SerialUSB.println("--");
}