Cannot convert to littlefs2
Port, board and/or hardware
ESP32 S3 (Arduino Nano ESP32)
MicroPython version
MicroPython v1.24.1 on 2024-11-29; Arduino Nano ESP32 with ESP32S3
Reproduction
>>> import vfs
>>> vfs.umount('/')
>>> vfs.VfsLfs2.mkfs(bdev)
>>> vfs.mount(bdev, '/')
as according to https://docs.micropython.org/en/latest/reference/filesystem.html#littlefs
Expected behaviour
No errors, filesystem with littlefs2 made succesfully.
Observed behaviour
>>> import vfs
>>> vfs.umount('/')
>>> vfs.VfsLfs2.mkfs(bdev)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] EINVAL
:(
Additional Information
Works for fat32:
>>> import vfs
>>> vfs.umount('/')
>>> vfs.VfsFat.mkfs(bdev)
>>> vfs.mount(bdev, '/')
Code of Conduct
Yes, I agree
esp32: add support for littlefs
This PR adds support for littlefs on all esp32 boards, both VfsLfs1 and VfsLfs2.
It also adds general support to auto-detect a littlefs filesystem when doing uos.mount(bdev).
The original FAT filesystem still works and any board with a preexisting FAT filesystem will still work as normal. You can switch to littlefs by reformatting the block device like this:
import uos, flashbdev
uos.VfsLfs2.mkfs(flashbdev.bdev)
Then when you reboot (soft or hard) the new littlefs filesystem will be mounted. You can switch back to FAT filesystem by formatting with uos.VfsFat.mkfs(flashbdev.bdev). Note that all files will be lost during format!
I'm not sure that it makes sense to provide both VfsLfs1 and VfsLfs2 in the esp32 build by default, probably enough to just have VfsLfs2 (but it was easier to just enable both for now).
On a fresh esp32 the default filesystem will still be FAT, but that's easy to change. And since it's not exposed over USB MSC I think it makes sense to change the default to littlefs (with the FAT driver still there to retain backwards compatibility).
The esp32 port was the easiest to add support for littlefs, so that's why this is here now. It shows how to do it for other ports.