cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to open two files on uSD in FATFS ?

MauFanGilaMedical
Associate II
 
4 REPLIES 4
Saket_Om
ST Employee

Hello @MauFanGilaMedical 

Yes, it is possible to open multiple files simultaneously using FATFS. The number of files can be set via the FS_LOCK parameter in STM32CubeMX.

Saket_Om_0-1742381271642.png

 

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar
MauFanGilaMedical
Associate II

so I can open one file in uSD and copy its content to another on uSD ?

I have to do this copy to change some content.

I did a first try but processor goes into Hard_Fault ... I supposed that I cannot open two files.

I will investigate and Accept as Solution if I see that I can.

Thankyou for the advice

I would think separate FIL objects for both files should suffice.
Otherwise, I would try to call f_sync() whenever you change the file you currently access.

The FatFs documentation is here: http://elm-chan.org/fsw/ff/

Here is the documentation of the FS_LOCK setting: http://elm-chan.org/fsw/ff/doc/config.html#fs_lock

 


@MauFanGilaMedical wrote:

I did a first try but processor goes into Hard_Fault ... I supposed that I cannot open two files.


Did you make the configuration change as @Saket_Om showed?

Did you regenerate & rebuild the code?

Are you checking for the  FR_LOCKED error mentioned in the FatFs documentation?

How to debug Hard Faults:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/tac-p/708193/highlight/true#M51