Having not used littleFS before, and reading the documentation, I did not find a command to “erase the harddrive” from user firmware for the littleFS POSIX filesystem.
How can this be achieved quickly without going into detail with what is actually on the file system?
An enterprising soul should be able to improve and adapt to clear files as necessary. A wise soul would recognize they should be very very very very very careful not to delete any files under sys as LFS doesn’t have access protections and perhaps consider why they need this in the first place.
Actually, a clever soul would NEVER store files in the root of the Gen3 LFS! Instead, they should create their own directory that they can later recurse to only remove those files and subdirectories.
@thrmttnw, the Gen3 devices use LittleFS to store important data which must not be removed so as not to “brick” the device and have to be repaired with a JTAG programmer.
Yes, creating any subdirectory at usr would be preferred. And if you do adapt this for “deleting everything under directory X” then probably force the “usr” prefix. So that delete_my_stuff("images") gets translated to the /usr/images subdirectory. And reject any path with an embedded . or .. for the same reason as it could then get back out of /usr/.
@peekay123 Oh I see. I got the impression it was user dedicated memory. I now found the EEPROM emulation is also in littleFS.
So when LFS gets corrupted, while the device is in the field, that can not be handled from user firmware.
With PublishQueueAsyncRK using LFS from it’s own thread, do I need to use a mutex or similar, when accessing EEPROM from the user thread, or is that baked in?
I’m not familiar with the PublishQueueAsyncRK use of LFS.
But access to the filesystem, whether through the POSIX API or the EEPROM API, acquires a lock so should be safe without any concern on your part. You can search FsLock in the Device-OS codebase if you’re curious.