Skip to main content
Explorer
March 7, 2024
Solved

FATFS: f_stat returns FR_NO_FILE

  • March 7, 2024
  • 3 replies
  • 2016 views

Hello community, 

I am using STWINKT1B board and trying to implement basic accelerometer datalogging from scratch. I don't want to use HSDatalog because I don't need so many functionnalities.

I am using FATFS functions, able to use mount, mkfs, mkdir, open and write functions to create this file DATA/data_000.TXT.

When I add the f_stat (after mount and mkfs) function with the path "DATA/data_000.TXT" and restart the board, I always get a FR_NO_FILE error. 

If I put the SD card in my laptop I can see the file in DATA/data_000.TXT:

NCatt1_0-1709826921766.png

Here is my code:

NCatt1_1-1709827043552.png

Any idea about what could cause the issue ?

Thank you

 

    This topic has been closed for replies.
    Best answer by Pavel A.

    The reason of creating a new volume is your program calling f_mkfs().

    How to solve: do not call f_mkfs unconditionally. If the storage is already formatted, f_mount is enough.

    3 replies

    Super User
    March 9, 2024

    It looks like the change caused by f_mkfs() has not been flushed to the medium. The local program then sees the volume as empty (just created) so your file is not found. But the file actually remains on the medium and can be seen when mounted on another system.

     

    NCatt.1Author
    Explorer
    March 11, 2024

    Yes it is possible. By debugging the f_mkfs() function it seems it is creating a new volume. What could be the reason? How to solve this ?

    Pavel A.Answer
    Super User
    March 11, 2024

    The reason of creating a new volume is your program calling f_mkfs().

    How to solve: do not call f_mkfs unconditionally. If the storage is already formatted, f_mount is enough.