Using a Expressif dev-board and standard micropython.bin I was able to create a littlefs2 partition, mount it and write data into a file:
# ESP8266 and ESP32
import os
os.umount('/')
os.VfsLfs2.mkfs(bdev)
os.mount(bdev, '/')
with open("myfile.txt", "a") as f:
f.write("myData")
Once I have done this os.listdir() will show the myfile.txt file but I can't see a way to update my code on the ESP anymore.
I assume I need to get rid of the littlefs2 file system first but could not find an example for that.
The only way I found for changing my code was erasing all flash, load a new copy of micropython.bin and then flash my code modules again onto the chip - which is kind of a long process for every change in my code?
Any shorter/faster way to update my code files on the ESP?
if reformat with vfsFat is close enough to 'getting rid of' you can do the following:
import os
os.umount('/')
os.VfsFat.mkfs(bdev)
os.mount(bdev, '/')
import _boot
this should re-format the flash as fat, and re-init using the post_flash _boot
module
Assuming you also have a serialport ( or telnet) connection to your MCU another approach is to use an IDE ( VSCode + Pymakr works for sure, or likely Thonny works as well) to connect to your MCU. Pymakr will happily upload / download files from whatever filesystem you are using, as long as the files are not TOO HUGE
there are a few tools for this