Page 1 of 1

"Factory reset" feature

Posted: Fri Apr 30, 2021 8:29 am
by mrsnail
Hi

I'm curious if there is a way to "factory-reset" a board (ESP32 in my case) to the original state of a fresh Micropython installation, typically found in commercial hardware solutions. This often involves pressing a button for some time while restoring power, or other techniques.

What I want to achieve basically is that someone without deeper know-how in Micropython can reset their chip to the firmware state as it was when freshly flashed. So basically it would need to:
  • delete any WiFi credentials
  • delete files created beginning first boot
Is there a way to do this? I don't have much know-how about Micropython yet, but I thought of a custom filesystem that can be cleared when some buttons are pressed.

Second idea I've had would be to put some code in main.py at the beginning that checks for i.e. a reboot reason (don't know if I can somehow determine if i.e. a button was pressed during startup)

Re: "Factory reset" feature

Posted: Fri Apr 30, 2021 10:18 am
by karfas
Use the source, Luke ;)

See https://github.com/micropython/micropyt ... nisetup.py how the initial filesystem (+some files) gets created.

I assume that a similar approach works for a "factory reset", given you have the required filesystem content somewhere (in frozen modules, another filesystem, tarfile, whereever).

Regards,
Thomas

Re: "Factory reset" feature

Posted: Mon May 03, 2021 7:27 am
by mrsnail
Thank you karfas

Yes, I have seen this and compile Micropython from scratch would be an option. But how do I reset it to this state? Or how can I delete i.e. the WiFi settings once it's set up? I can't seem to find using os.listdir() etc.

Re: "Factory reset" feature

Posted: Mon May 03, 2021 8:26 am
by karfas
Then you should find out where your installation saves the WLAN credentials.
They might as well live in NVS storage (another "partition" in the EEPROM).