Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By craigfoo
#41226 I'm developing on a Adafruit Feather HUZZAH with the Arduino and I ran a couple WiFi client examples to get started. I had to hard code my WiFi credentials and that worked fine. I used the WiFi.begin(ssid, password) function to get it working and it looks like it stored the WiFi credentials somewhere. How can I clear those credentials? Is there a tool out there that can format the ESP8266? I tried using the FS.h library and the SPIFFS.format() function but that doesn't clear the stored creds. Any thoughts?
User avatar
By craigfoo
#41284 Thanks for the reply.

What if I wanted to implement a "factory reset" using a button? I want to programmatically erase all Wifi profiles that are saved in flash. I played around with the system_restore API and I think it's working but there might be a better way.
User avatar
By gaber
#41297 If you want to factory erase based upon a button push -- and the factory erase function clears out the SSID values, then it looks like you need to write a little function that will clear the following address on most hardware: 0x7E000 -- around 128 bytes looks like the values you want to clear. On my flash, it is all FF's before a valid SSID is stored there. If that is not your address you want to find the right area. But anyway, you can check if its correct by reading from that area using esptool. No need to delete the entire flash if you want to nuke those settings.

You can investigate more by doing this before and after changing your wifi settings:

./esptool.py read_flash 0x7E000 128 wifisettings.bin

Then read the file using your favorite hex editor like xxd or whatever.
xxd wifisettings.bin

It is all FF's before saving an SSID:
Code: Select allmylinuxbox$ xxd wifisettings.bin
00000000: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000010: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000020: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000030: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000040: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000050: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000060: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000070: ffff ffff ffff ffff ffff ffff ffff ffff  ................


Then after saving an SSID and password that is successfully connected to:
Code: Select allmylinuxbox$ xxd wifisettings.bin
00000000: ffff ffff ffff ffff 01ff ffff 0a00 0000  ................
00000010: 4d59 5f53 5349 445f 3132 00ff ffff ffff  MY_SSID_12......
00000020: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000030: ffff ffff ffff 0131 3233 3435 3637 3839  .......123456789
00000040: 3031 00ff ffff ffff ffff ffff ffff ffff  01..............
00000050: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000060: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000070: ffff ffff ffff ff00 ffff ffff ffff ffff  ................


So if all you want to do is nuke that area of flash, then you can do this -- should work:

spi_flash_erase_sector(0x7E);

See this example code if you want to get more fancy with reading/writing values from the spi_flash
https://github.com/igrr/atproto/blob/ma ... ig_store.c

-Gabe