Skip to main content
Visitor II
March 1, 2025
Question

FATFS: f_mkfs not working.

  • March 1, 2025
  • 3 replies
  • 1263 views

Hi,
I use STM32Cube, STM32CubeIDE and my board is STM32F746. How do I update FATFS? The system is running version 0.12c. This is from 2017.

Why do I want to update it?
After inserting the SD card, I check the status and if the card is not formatted, I want to format it. I have tried everything I could find on the internet. I am obviously not the only one who has a problem with the SD card in STM32 systems.
The command I use is this:
res = f_mkfs((TCHAR const*) SDPath, FM_FAT32, 0, work, sizeof(work));
Of course, I have tried all possible parameters. I get a response that formatting is OK, but after moving the card to the computer there is no system on the card and I get a RAW response.

When the card is formatted in advance, everything works for me.

    This topic has been closed for replies.

    3 replies

    Super User
    March 1, 2025

    What makes you think this problem will be solved by updating?

    Is FF_USE_MKFS enabled in your project?

    http://elm-chan.org/fsw/ff/doc/config.html#use_mkfs

    http://elm-chan.org/fsw/ff/doc/mkfs.html

    To update it, just replace the source files with later source files:

    http://elm-chan.org/fsw/ff/archives.html 

     

    PS:

    FatFS support forum: http://elm-chan.org/fsw/ff/bd/ 

    JNova.0Author
    Visitor II
    March 3, 2025

    I don't know where to look anymore. It seems the problem is in TouchGFX.
    The same code works without TouchGFX. Where should I look for the error?

    Super User
    March 3, 2025

    As @Tesla DeLorean suggested, instrument your code so that you can see what's happening ...

     

    maybe a scope or analyser on the card interface ...

    JNova.0Author
    Visitor II
    March 1, 2025

    thanks for the quick response.

    in which directory should I replace the files?
    if I do it in the project directory, it changes back to 0.12c when generating :(
    In version 0.12c it is _USE_MKFS. And I have it set to 1
    If I change it in the directory ...\STM32Cube\Repository\STM32Cube_FW_F7_V1.17.2\Middlewares\Third_Party\FatFs\
    then there is a problem with the configuration. I open .ioc I find FATFS and there is version 0.12c. how do I change this too?

    Super User
    March 3, 2025

    @JNova.0 wrote:

    if I do it in the project directory, it changes back to 0.12c when generating :(


    I don't think you can update what version CubeMX uses - so you'd have to do it outside CubeMX ?

    Graduate II
    March 1, 2025

    What Format is on the card originally? Is it EXFAT? Has that been enabled in the build?

    The old version of FATFS has issues with large cards, but the new version has a different DISKIO layer, so that needs to be modified.

    If the new format isn't working it suggests the DISKIO is not working. Revalidate that they actually read/write properly. Instrument DISKIO, perhaps reporting data CRC's so you can audit a log to see it content is coming back as expected.