SYMPTOM
In my microcontroller application I store multiple files into the root folder of a SD memory card which is formatted as FAT16. I know that the FAT16 file system limits the number of files in the root folder to 512 but I cannot create more than 255 files. Are there reasons why?
CAUSE
It is correct that the maximum number of file in the root folder of a FAT16 file system is 512. This applies to files with 8.3 filenames. As soon as you use longer filenames, the maximum number decreases to at least 255 or even less depending on the length of the filenames. This is a restriction of the FAT16 file system, not a restriction of FlashFS.
Please note:
RL-ARM FlashFS handles filenames as 8.3 only when the length is not exceeded and when all characters of the filename are all either uppercase or all lowercase. FlashFS then converts the filename to all uppercase characters.
When a filename contains upper- and lower-case characters, the filename must be considered as a 'long' filename and the maximum number of files in the root folder decreases significantly.
RESOLUTION
In order to use the maximum number of files possible or to bypass this limit, you can do the following things:
- Use 8.3 filenames with only uppercase characters in the filenames to create up to 512 files in the root folder.
- Create the files in a sub-folder rather than in the root folder
- Use FAT32 instead