← index #16510PR #5274
Related · high · value 2.473
QUERY · ISSUE

Cannot convert to littlefs2

openby benj5378opened 2025-01-01updated 2025-03-06
bug

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

CANDIDATE · PULL REQUEST

esp32: add support for littlefs

mergedby dpgeorgeopened 2019-10-29updated 2019-11-06
port-esp32

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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied