Page 1 of 1

Micro SD File Locked Error

Posted: Fri Aug 21, 2015 5:39 am
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

Re: Micro SD File Locked Error

Posted: Sat Aug 22, 2015 9:22 am
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?

Re: Micro SD File Locked Error

Posted: Mon Aug 24, 2015 4:59 am
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

Re: Micro SD File Locked Error

Posted: Mon Aug 24, 2015 10:39 am
by rnixon
I think you have to have a file handle from the f_open(), otherwise, how would you write to it?

Re: Micro SD File Locked Error

Posted: Mon Aug 24, 2015 11:56 am
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

Re: Micro SD File Locked Error

Posted: Tue Aug 25, 2015 1:33 am
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.