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.binThen 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