Skip to main content
MZadn.2
Associate II
May 14, 2026
Solved

FATFS UTF-8 support

  • May 14, 2026
  • 1 reply
  • 181 views

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:

MZadn2_3-1778741085479.png

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:

MZadn2_1-1778740933914.png

The _STRF_ENCODE is correctly defined as 3 in FATFS/Target/ffconf.h, which corresponds to UTF-8:

MZadn2_2-1778740998616.png

Is this a bug? How can I ensure that UTF-8 uses the 8-bit data type correctly?

Best answer by Pavel A.

You're using older version of fatfs that does not support UTF8 yet.

PavelA_0-1779039695395.png

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.

 

 

1 reply

Pavel A.
Pavel A.Answer
Super User
May 17, 2026

You're using older version of fatfs that does not support UTF8 yet.

PavelA_0-1779039695395.png

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.