Probably in the file gfile_fs_fatfs.c there is a bug, namely in the functions -
FatfsExists and fatfsFileSize when the LFN option is enabled.
This was tested on the Nucleo F401RE board without the OS.
Sometimes when you call fatfsExists or fatfsFileSize, HARDFAULT appears.
Analysis of the execution of the program code showed that inside the FATFS library
There is a call to the uninitialized pointer fno.lfname.
Therefore, in the functions - fatfsExists and fatfsFileSize it is enough to add this code:
#if _USE_LFN
Fno.lfname = 0;
Fno.lfsize = 0;
#endif
If I'm wrong somewhere, then correct me.
Thank you in advance!