can I reset a thingy filesystem without flashing

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
bitrat
Posts: 7
Joined: Fri Jul 26, 2019 4:13 am

can I reset a thingy filesystem without flashing

Post by bitrat » Fri Aug 09, 2019 2:41 am

I have a bunch of null directories on my thingy (don't ask). ....ok, I've been resetting a deadlocked interpreter using this abomination, while pressing reset...

Code: Select all

while :
do
        expect -c 'send \003\003\003\003\003\003\003\003\003\003\003\003\003\003\003' > /dev/ttyS4
        expect -c 'send "\rimport uos\r";' > /dev/ttyS4
        s="\ruos.remove('main.py')\r"
        expect -c "send ${s};" > /dev/ttyS4
        expect -c 'send \004\004\004' > /dev/ttyS4
done
I'm sure there's a better way (what is it please! :) ampy doesn't work while the interpreter is deadlocked...)
Manually calling main() from prompt is the obvious answer to that.

Anyway, all 129 directories have the same name and inode:

Code: Select all

('\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00', 16384, 0, 4294967295)
...where 'inode' is a sfw alias for FFFFFFFF‬'d. ...actually not an inode as I see the filesystem is FAT :D I may seek an alternative...

anyway,

Code: Select all

uos.rmdir('\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00') 
returns ENOENT.

I can flash the thingy, but my MP build is currently broken and, well, I'm lazy (obviously). Anyway, this is all what I call exploratory testing.. I'm learning a lot just by writing this topic.

So, my question is: can I reset/format the filesystem without flashing the device?

Sorry about the rambling explanation..

Cheers,
Bitrat

User avatar
jimmo
Posts: 427
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: can I reset a thingy filesystem without flashing

Post by jimmo » Fri Aug 09, 2019 4:22 am

Hi,

If you can get to the REPL, you can unmount the filesystem, recreate it, then re-mount it (or soft reset).

Code: Select all

>>> import os
>>> os.umount('/')
>>> from flashbdev import bdev
>>> os.VfsFat.mkfs(bdev)
>>> Ctrl-D to soft-reset
(This is specific to ESP32 and ESP8266, other boards have equivalent methods, and the STM32 port has a way to do a filesystem reset by holding down the USR button at boot).

bitrat
Posts: 7
Joined: Fri Jul 26, 2019 4:13 am

Re: can I reset a thingy filesystem without flashing

Post by bitrat » Fri Aug 09, 2019 5:15 am

Awesome thanks! Just what I was looking for.

Works too :-)

Post Reply