ESP32S3 : Tool wl_fatfsgen.py => Why filenames are converted to lowercase ?

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

ESP32S3 : Tool wl_fatfsgen.py => Why filenames are converted to lowercase ?

Postby ThomasESP32 » Tue Apr 30, 2024 8:26 am

Good morning,

I am using the python tool wl_fatfsgen.py in order to build a binary file of a directory containing audio files.

Then, this binary file is flashed with my firmware in an Esp32S3.

When I try to read the content of the filesystem using readdir, I can see that all the filenames have been converted to lowercase
by the wl_fatfsgen.py tool. Do you know why ?

Is it possible to keep the filenames so that they are not converted to lowercase ?

Best regards,
Thomas TRUILHE

ESP_adokitkat
Posts: 50
Joined: Thu Jun 22, 2023 12:50 pm

Re: ESP32S3 : Tool wl_fatfsgen.py => Why filenames are converted to lowercase ?

Postby ESP_adokitkat » Tue May 07, 2024 10:00 pm

Hello.

This is due to FatFS storing the file names in upper-case only (source, under "Namespace" section) - that is if you use SFN (short filenames, so-called "8.3 filenames"), i.e. you didn't enable LFN (long filenames).

The text from the first source link:
Short File Name

SFN, often called the 8.3 format name, is a traditional style file name originally used on the MS-DOS in format of body (1-8 character) plus optional extension (1-3 characters). These two parts are separated with a dot (.). The allowable charactes for the SFN are ASCII alphanumerics, some ASCII marks ($%'-_@~`!(){}^#&) and extended characters (\x80 - \xFF).

SFN is stored in the SFN entry in OEM code set (used on MS-DOS) depends on the system locale. Low-case character in the file name is converted to up-case and then stored and matched, so that the case information of SFN is lost.

Long File Name

Length of LFN can be upto 255 characters. The allowable characters for the LFN are white space and some ASCII marks (+,;=[]) in addition to the SFN characters. Dots can be embedded anywhere in the file name except the trailing dots and spaces are treated as end of the name and truncated off on the file API. Preceding spaces and dots are valid, but some user interface, such as Windows common dialog, rejects such file name.

LFN is stored in the LFN entry without up-case conversion. Character code used by LFN is in Unicode.

Because different character codes are used by SFN (OEM code set) and LFN (Unicode), generic implementation needs to convert those codes. This is not the matter on the OEM code is single byte code, however, when the OEM code page is in double byte character set (DBCS), a huge (several hundreds KB) conversion table is needed, so that it is difficult to implement LFN in the small embedded systems with a limited memory.
You can enable LFN in `idf.py menuconfig` -> "Component config → FAT Filesystem support → Long filename support".

However if the conversion to uppercase still happens even when using LFN then it is probably a bug.

Who is online

Users browsing this forum: No registered users and 89 guests