Can't open file on SD from directory with many files inside

Hi everyone. I am using the "standard" SD library and an Arduino Uno to open some files on an SD card. I am opening the files by name specifically (rather than looping through them). I can open files fine when there are only a few dozen files in the directory, but if I try to open something from a directory with many hundreds of files in it, it doesn't work. The file isn't opened and if I try to read from it I get a string of nothing. My SD card is formatted as FAT32 and the file names are all very short - they are simply numbered from 1 up to whatever, sequentially.

I doubt it matters but my SD card is a SDXC card (64GB) and to get it to work I had to wipe it competely of partitions and create a smaller partition on there so I could format it with FAT32 from Windows. Might be of interest.

Just an update - I have tried using the SdFat library, but I get the same problem. Files in small directories can be opened normally, but ones in larger directories cannot.

But you can read these files ok in Windows? And all files are in the root directory? If there are too many files, can you still read the first few files, or are you unable to read any files?

I don't have an explanation. In FAT32 the root directory is just like any file. So I don't think there's any limitation, within reason, on the number of files. But there may be a limit on the number of clusters of the root directory that an Arduino can deal with. Do you have any idea of the number of files at which the problem begins to happen?

As for the smaller partition of an SDXC card, I think the only way to determine if that's the problem is to do a duplicate setup on a 32GB SDHC card, and see if it also craps out with too many files.

Hi Sherman, thanks for your reply but I just now fixed it. I think there was a bug in my code somewhere, or maybe it's because I switched to SdFat but using exFAT file system.... I actually don't know exactly what fixed it - but it works OK now.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.