Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: SD directory listing anomaly

  1. #1
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013

    SD directory listing anomaly

    Just for the record, I have a SanDisk 8 GB uSD (SDHC, fat32) that has had lots of file activity. A directory listing from SD example listfiles on various Teensy 3* and 4* microSD drives (both SPI and SDIO/BUILTIN)) only lists the first 4 files of the 30 or so files on the uSD?? Using arduino 1.8.15 and TD 1.56, I can still read and write files on the uSD even though the directory list is truncated. The directory is short also if I use SdFat example DirectoryFunctions.

    The directory is fine if I insert uSD into Windows 10 or Ubuntu. SD listfiles directory is good on adafruit Adalogger built on Arduino IDE. And directory is good on NXP 1170 SDK FATFS.

    The Teensy SD libs don't like a NULL directory entry (?), I can hack listfiles to give a full directory listing with a counter
    void printDirectory(File dir, int numSpaces) {
       int count = 0;
       while(true) {
         File entry = dir.openNextFile();
         if (! entry) {
           //Serial.println("** no more files **");
           if (++count > 1) break;
    I know i could reformat the card etc., but it would be nice if Teensy Sd libs were more robust.
    Last edited by manitou; 02-03-2022 at 08:35 PM.

  2. #2
    Senior Member
    Join Date
    Nov 2012
    I ran into that a while ago and I think the problem was something to do with there being a windows System Directory (I forget its name) OR there was a file with garbage characters in the name. The listfiles example stopped dead when it got to that entry.
    Sorry, can't remember the details now.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts