found a bug in esp8266 wifi

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
nedoskiv
Posts: 20
Joined: Fri Jan 18, 2019 10:48 am

found a bug in esp8266 wifi

Post by nedoskiv » Fri Feb 11, 2022 1:40 pm

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.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: found a bug in esp8266 wifi

Post by pythoncoder » 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.
Peter Hinch
Index to my micropython libraries.

jomas
Posts: 59
Joined: Mon Dec 25, 2017 1:48 pm
Location: Netherlands

Re: found a bug in esp8266 wifi

Post by jomas » Fri Feb 11, 2022 7:39 pm

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.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: found a bug in esp8266 wifi

Post by pythoncoder » Sat Feb 12, 2022 9:44 am

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.
Peter Hinch
Index to my micropython libraries.

nedoskiv
Posts: 20
Joined: Fri Jan 18, 2019 10:48 am

Re: found a bug in esp8266 wifi

Post by nedoskiv » Mon Feb 14, 2022 7:11 am

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.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: found a bug in esp8266 wifi

Post by davef » Mon Feb 14, 2022 7:42 am

Show us your code to disable the AP.

nedoskiv
Posts: 20
Joined: Fri Jan 18, 2019 10:48 am

Re: found a bug in esp8266 wifi

Post by nedoskiv » Mon Feb 14, 2022 12:52 pm

nothing special, just tested to see what gonna happen:

Code: Select all

import network

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

Shards
Posts: 39
Joined: Fri Jun 25, 2021 5:14 pm
Location: Milton Keynes, UK

Re: found a bug in esp8266 wifi

Post by Shards » Tue Feb 15, 2022 3:23 pm

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.

nedoskiv
Posts: 20
Joined: Fri Jan 18, 2019 10:48 am

Re: found a bug in esp8266 wifi

Post by nedoskiv » Mon Feb 28, 2022 9:20 am

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.

Post Reply