Page 1 of 1

found a bug in esp8266 wifi

Posted: Fri Feb 11, 2022 1:40 pm
by nedoskiv
Not sure if I posted that in correct place, if not please point me where I should report this.

In short I never used micropython on esp8266, so I give it a shot,
going thru the basics, making some init script for wifi, etc.
During testing them I realized, that once wifi Is set for AP mode, It always start AP after that, without being initialized. Or if initialized in station mode, it start AP again. Deleteting all files, unplug and plug device do not change anything, AP is UP and running, can connect to it and ping the device, tested with:

MicroPython v1.18 on 2022-01-17; ESP module with ESP8266

and

MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266

AP stop showing, only when I re-flash device with full erase of flash memory.
tested on 2 esp8266 devices.

Re: found a bug in esp8266 wifi

Posted: Fri Feb 11, 2022 5:18 pm
by pythoncoder
I think this is how it's supposed to work. The ESP8266 stores its configuration in Flash. For example, in station mode on power up it remembers its WiFi credentials and automatically logs in. I don't believe you can make it "forget" other than by erasing flash. I guess AP mode works similarly. I'm pretty sure it can support AP and station mode simultaneously.

This behaviour is a function of the chip and not of MicroPython. It was widely criticised on security grounds: Esspressif evidently took it on board because ESP32 does not do this.

Re: found a bug in esp8266 wifi

Posted: Fri Feb 11, 2022 7:39 pm
by jomas
pythoncoder wrote:
Fri Feb 11, 2022 5:18 pm
I think this is how it's supposed to work. The ESP8266 stores its configuration in Flash. For example, in station mode on power up it remembers its WiFi credentials and automatically logs in. I don't believe you can make it "forget" other than by erasing flash. I guess AP mode works similarly. I'm pretty sure it can support AP and station mode simultaneously.

This behaviour is a function of the chip and not of MicroPython. It was widely criticised on security grounds: Esspressif evidently took it on board because ESP32 does not do this.
No that is not true. The SDK of the esp8266 has two calls to set the wifi configuration. One will store the credentials in flash and one without storing to flash (like the esp32). It was the decision of the developers of MicroPython to choose the one that stores in flash. They could have easily added a extra flag to choose between one of the two but unfortunately they did not. Of course, if you want this you can easily compile you own version and choose the call you want. See the SDK documentation: wifi_station_set_config, and wifi_station_set_config_current, wifi_softap_set_config, wifi_softap_set_config_current.

Re: found a bug in esp8266 wifi

Posted: Sat Feb 12, 2022 9:44 am
by pythoncoder
OK, I stand corrected. I remain puzzled about the adverse comments in the technical press about the security implications, but these were in the early days. Did the SDK change at some point to provide this option?

In any event your best course is probably to raise a ticket against the ESP8266 port. If the firmware were to be changed it should default to the existing mechanism to avoid breaking code.

Re: found a bug in esp8266 wifi

Posted: Mon Feb 14, 2022 7:11 am
by nedoskiv
bad part is when problem happen, I initialize AP and set it to disable (false), it do not turn off AP, that is not acceptable for me at this point. Guess gonna move to LUA again.

Re: found a bug in esp8266 wifi

Posted: Mon Feb 14, 2022 7:42 am
by davef
Show us your code to disable the AP.

Re: found a bug in esp8266 wifi

Posted: Mon Feb 14, 2022 12:52 pm
by nedoskiv
nothing special, just tested to see what gonna happen:

Code: Select all

import network

tmp=network.WLAN(network.AP_IF)
tmp.active(False)

Re: found a bug in esp8266 wifi

Posted: Tue Feb 15, 2022 3:23 pm
by Shards
I've been doing some testing and it all works as expected for me. I'm using version 1.18 of Micropython, '.active(False)' disables the access point and if it's disabled it doesn't reconnect on reboot. If I then reconnect it has remembered the credentials but they are readily changed. You can ensure that the network doesn't reconnect with a couple of lines in boot.py :

Code: Select all

import network
network.WLAN(network.AP_IF).active(False)
Though this obviously requires that '.active(False)' works, which it does for me.

Not sure why you see things differently unless it's down to ESP8266 boards, the one I'm testing on is based on an ESP8266 12F module. Also tested on an ESP8266-01S board with the same results.

Not sure how you are testing for access point connection. I'm using my tablets WiFi 'show networks' option and it can take a good number of refreshes to both show a new connection and a lost one.

Re: found a bug in esp8266 wifi

Posted: Mon Feb 28, 2022 9:20 am
by nedoskiv
I have changed the esp8266 board and can successful disable wireless now, guess something was happen to old one.
Still the fact that it stores wireless config every time when I initialize wireless is enough not to use micropython on esp8266, after all, writable memory life is limited.