Where is network connection information saved ?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
water
Posts: 23
Joined: Sun Sep 24, 2017 9:16 am

Where is network connection information saved ?

Post by water » Sun Feb 25, 2018 7:04 pm

My ESP8266 connected to a AP (router) success once, shutdown power, the next time power on, when create a station object via ">>> sta = network.WLAN(network.STA_IF)" only, it connect to the previous AP (router) automate.

Where is the connection information( AP's SSID and password) saved ? how to config it ? or set to don't connect a AP automate when I create station object ?

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Where is network connection information saved ?

Post by kfricke » Tue Feb 27, 2018 12:09 am

The ESP8266 writes the WiFi credentials to the flash memory every time you call the connect method. That is not MicroPython specific but implemented in the underlying the ESP8266 vendor SDK.
The config sector in flash memory keeps an history of the last 6 credentials and tries to connect to them if a station interface is created.

Sadly this is not very well documented and bears the risk of flash wearing, because the real implementation is unknown.
In case if excessive use of the connect method and/or reboots of the ESP8266 this behavior leads to unnecessary flash writes. The most flash chips used in the ESPs are rated at 100k writes per sector.

To get rid of your known or cached WiFi credentials you need to write six nonsense but differing configurations to flash by calling the connect method.

water
Posts: 23
Joined: Sun Sep 24, 2017 9:16 am

Re: Where is network connection information saved ?

Post by water » Tue Feb 27, 2018 6:08 pm

It's a risk.
Can you provide related document link (about the last 6 WiFi credentials write to flash memory) ?
The vendor SDK is it mean "ESP8266 NONOS SDK" and/or "ESP32-IDF" ?

If connect to a exist / saved in history 's connection use connect method, it may be "read" flash memory operation was happened, I think.

Thanks.

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Where is network connection information saved ?

Post by kfricke » Tue Feb 27, 2018 7:24 pm

I am away from my build machine at the moment and so not able to tell the exact details.
But all that needs to be done is to cross-read the ESP docs and open source parts of the SDK regarding this matter. You can search for the C config structs and find the relevant references in both the PDF and on the espressif GitHub repository.
That gives a clue on the desired behavior in the SDK docs. Simply check for references if that config struct.

When searching the net for esp rom and reverse engineering info one can even find the details which outline the addresses in the flash rom where that config data is saved on the flash usually connected to the ESP8266.

Combine that intel with the MicroPython Module ‘esp’ to read addresses from the flash to dig around in you own ROM and play with the details.

Post Reply