Micro SD File Locked Error

Discussion to talk about software related topics only.
Post Reply
rlupish
Posts: 26
Joined: Thu Oct 10, 2013 6:15 am

Micro SD File Locked Error

Post by rlupish »

We are using a microSD on the provided slot on the MOD54417 module. We are using the EFFS file access routines to access its file system. All EFFS functions seem to work just fine as advertised - I am able to open, read, write, close, delete, rename, etc. the various files on the microSD. Our application requires that various log files be created and maintained on the device.

However, in the course of developing the s/w, somehow I have managed to create a file, which, when I try to open, delete or rename via the appropriate EFFS functions (f_open, f_delete, f_rename), returns a F_ERR_LOCKED error. I have used the f_setattr() function to try to clear any offending attributes, but to no avail.

Is there an available function in the EFFS to UNLOCK a file which returns a F_ERR_LOCKED error?

Thanks,

Ron
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Micro SD File Locked Error

Post by rnixon »

The manual says that locked means the file is already open. I did not see a close in your list of attempted commands. Have you tried making sure the file is closed before deleting it?
rlupish
Posts: 26
Joined: Thu Oct 10, 2013 6:15 am

Re: Micro SD File Locked Error

Post by rlupish »

It's entirely possible one development version of my code left the file open when I did a shutdown in preparation for downloading the next version. :oops:

Unfortunately, the f_close() function requires a pointer to a FILE as an argument - the assumption is that the file has been opened and a file handle is available. I can find no function to close a file by name.

Apparently some "sticky" attribute of the file is set, showing it to be open, hence "locked". The f_setattr( ) does not clear this particular attribute. :(

So the file is still there, smirking at me :x

Ron
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Micro SD File Locked Error

Post by rnixon »

I think you have to have a file handle from the f_open(), otherwise, how would you write to it?
rlupish
Posts: 26
Joined: Thu Oct 10, 2013 6:15 am

Re: Micro SD File Locked Error

Post by rlupish »

f_open( ) fails on this file - it also returns a F_ERR_LOCKED error. So I can't open it, can't close it, can't delete it.

Again, the application was shut down, apparently when the file had been opened and not closed. Some bit in the file system is "stuck" saying the file is still open, and none of the EFFS functions seem to be able to override this. May just have to re-format the microSD...

Thanks for the responses, tho'.

Ron
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: Micro SD File Locked Error

Post by ecasey »

Try running the check disk utility with the SD card on a windows PC and choose the repair option. That usually works for me.
Post Reply