FATFS: f_stat returns FR_NO_FILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-07 7:57 AM
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:
Here is my code:
Any idea about what could cause the issue ?
Thank you
Solved! Go to Solution.
- Labels:
-
FatFS
-
STM32CubeExpansion
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-11 10:13 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-09 2:23 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-11 8:08 AM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-11 10:13 AM
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.
