Creating file on SD card results in SFN even with LFN enabled

Hi,

I'm trying to deal with a weird issue regarding writing files to an SD card. I am restructuring my project to be more maintainable, which means moving some things over from the src directory to drivers (T2 topology). I have a couple working drivers, so I'm familiar with how it works, but when I do the same thing with my custom SDHC driver (drv_sdhc), I'm getting some weird behavior that I cannot find the root cause of. Essentially, when creating a file or directory with a name longer than 10 characters and list the files on the SD card after, I see that the newly created file is in SFN format (e.g. RECORD~1 for a directory that should be recording_01). When loading that SD card on the PC, it also has the same SFN name.

The weird thing is, when I copy the exact same file to put it in src and make sure to not build the driver file but the src file (keeping all other configs etc. the same, CONFIG_FS_FATFS_LFN=y  for both cases), everything works as expected. What could be causing this? Am I missing something here?

Best,

Wout

Parents
  • Hi,

    Searching in nRF Connect SDK I can find for instance in test_fat.h that:

    #if defined(CONFIG_FS_FATFS_LFN)
    #define TEST_FILE	FATFS_MNTP \
    	"/testlongfilenamethatsmuchlongerthan8.3chars.text"
    #else
    #define TEST_FILE	FATFS_MNTP"/testfile.txt"
    #endif /* CONFIG_FS_FATFS_LFN */

    I can also find in kconfig.fatfs

    config FS_FATFS_LFN
    	bool "Long filenames (LFN)"
    	help
    	  Without long filenames enabled, file names are limited to 8.3 format.
    	  This option increases working buffer size.

    So it looks to me that you need to enable CONFIG_FS_FATFS_LFN=y to support longer than 8.3 file name yes.

    Kenneth

  • Hi Kenneth,

    Thank you for getting back to me, and sorry for my delayed response. I have been busy with some other work the past weeks.

    I know that I need to enable CONFIG_FS_FATFS_LFN, this was also indicate in my original post. I have narrowed down the main issue to something weird happening with how the module is operating depending on how it is included in the build.

    When I keep the drv_sdhc.c file inside /src and include it in the build in my CMakeLists.txt in /app, it seems to work as expected. However, when I move it to a directory in /drivers (and make sure that everything is set up so that the file is included in the build), I get the issue described above.

    Another issue I observed is that I store a pointer to an application callback function inside the drv_sdhc module, essentially to let the application know when the SD card is inserted. When I initialize the driver and set the pointer, everything is fine. But when I actually get the GPIO callback indicating that the SD card is inserted, I notice that the pointer variable has changed and is no longer pointing to my actual callback function, but rather 0xaa550000, which is not a valid address

    These things seem to be connected, as this also doesn't happen when I'm doing it from the drv_sdhc.c file in /src . I have made other /drivers, so I'm pretty sure it's not related to how it's implemented. But I'm lost as to finding out what exactly is going wrong. The good thing is that I can make things work by just doing everything in /src, but I would definitely want to understand the issue.

Reply
  • Hi Kenneth,

    Thank you for getting back to me, and sorry for my delayed response. I have been busy with some other work the past weeks.

    I know that I need to enable CONFIG_FS_FATFS_LFN, this was also indicate in my original post. I have narrowed down the main issue to something weird happening with how the module is operating depending on how it is included in the build.

    When I keep the drv_sdhc.c file inside /src and include it in the build in my CMakeLists.txt in /app, it seems to work as expected. However, when I move it to a directory in /drivers (and make sure that everything is set up so that the file is included in the build), I get the issue described above.

    Another issue I observed is that I store a pointer to an application callback function inside the drv_sdhc module, essentially to let the application know when the SD card is inserted. When I initialize the driver and set the pointer, everything is fine. But when I actually get the GPIO callback indicating that the SD card is inserted, I notice that the pointer variable has changed and is no longer pointing to my actual callback function, but rather 0xaa550000, which is not a valid address

    These things seem to be connected, as this also doesn't happen when I'm doing it from the drv_sdhc.c file in /src . I have made other /drivers, so I'm pretty sure it's not related to how it's implemented. But I'm lost as to finding out what exactly is going wrong. The good thing is that I can make things work by just doing everything in /src, but I would definitely want to understand the issue.

Children
No Data
Related