[SOLVED] Upip problem ESP32 WiFi Kit

Can’t use MicroPython’s upip with ESP32 WiFi Kit. Problem is that WiFi disconnects with a beacon interval timeout. Here’s the detailed log:

import upip
Installing to: /lib/
I (54352687) wifi: bcn_timout,ap_probe_send_start
I (54355187) wifi: ap_probe_send over, resett wifi status to disassoc
I (54355187) wifi: state: run -> init (c800)
I (54355187) wifi: pm stop, total sleep time: 49780126008 us / 54353492785 us
I (54355197) wifi: new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
mbedtls_ssl_handshake error: -71
I (54355207) wifi: STA_DISCONNECTED, reason:200
beacon timeout
Error installing ‘micropython-umqtt.robust’: [Errno 5] EIO, packages may be partially installed

I (54355337) wifi: new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (54355337) wifi: state: init -> auth (b0)
I (54355337) wifi: state: auth -> assoc (0)
I (54355347) wifi: state: assoc -> run (10)
I (54355357) wifi: security type: 3, phy: bgn, rssi: -51
I (54355367) wifi: pm start, type: 1
I (54355367) network: CONNECTED
I (54355387) wifi: AP’s beacon interval = 102400 us, DTIM period = 1
e[0;32mI (54358587) event: sta ip:, mask:, gw:
I (54358587) network: GOT_IP

I Googled this issue and the most plausible explanation is in this discussion:


ESP_Sprite says:

The issue is that most of the ESP32 is ‘locked up’ while doing flash writes; the architecture is somewhat dependent on being able to read code from the flash chip on the fly, and while doing a write it cannot do this, so it will suspend most tasks until the write is over. If you do a lot of large writes back-to-back, this means a bunch of tasks won’t run for a long time, and the task watchdog kicks in. Suggest doing a vTaskDelay(10) or something between flash writes, to give other tasks the chance to run.

This makes sense because large writes is exactly what upip would be doing. So the suggested solution is to modify upip, or is there something on the ESP32 board that can be done?

I’ll also be posting this question on the MicroPython forum. It’s surprising that upip doesn’t work on all ESP32 boards, and no one noticed it so far.

The problem appears to be in the MicroPython firmware. I was using this firmware: esp32-idf3-20200122-v1.12-68-g3032ae115.bin and upip failed with wifi beacon timeout. I then loaded this firmware: esp32-idf4-20200122-v1.12-68-g3032ae115.bin and upip works fine.