2026-05-13 11:48 PM
I am using STM32CubeMX 6.16.1 to configure a project for STM32F415.
I use the FATFS on SD card and set it up as:
According to FATFS documentation (https://elm-chan.org/fsw/ff/doc/config.html#lfn_unicode), the data type TCHAR should translate to char in this case. However, CubeMX generates Middlewares/Third_Party/FatFs/src/ff.h in which TCHAR is defined as WCHAR, i.e. a 16-bit type:
The _STRF_ENCODE is correctly defined as 3 in FATFS/Target/ffconf.h, which corresponds to UTF-8:
Is this a bug? How can I ensure that UTF-8 uses the 8-bit data type correctly?
Solved! Go to Solution.
2026-05-17 10:43 AM - edited 2026-05-17 10:48 AM
You're using older version of fatfs that does not support UTF8 yet.
Old version of fatfs has #ifndef _FATFS in ff.h, while the modern version (80386) has #ifndef FF_DEFINED .
This is how you can distinguish them.
Whether or when ST is going to update fatfs in the Cube firmware packages is a different question.
2026-05-17 10:43 AM - edited 2026-05-17 10:48 AM
You're using older version of fatfs that does not support UTF8 yet.
Old version of fatfs has #ifndef _FATFS in ff.h, while the modern version (80386) has #ifndef FF_DEFINED .
This is how you can distinguish them.
Whether or when ST is going to update fatfs in the Cube firmware packages is a different question.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.