cancel
Showing results for 
Search instead for 
Did you mean: 

FATFS: f_stat returns FR_NO_FILE

NCatt.1
Associate III

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

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.

View solution in original post

3 REPLIES 3
Pavel A.
Evangelist III

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.1
Associate III

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.
Evangelist III

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.