ESP32 - cannot initialize WLAN
While initializing a WLAN (on an ESP32 GENERIC_SPIRAM board) with:
>>> import network
>>> station = network.WLAN(network.STA_IF)
the following error occurs:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: Wifi Unknown Error 0x0101
MicroPython version used (build with ESP-IDF (stable) 4.3.1):
>>> import sys
>>> sys.implementation
(name='micropython', version=(1, 17, 0), mpy=10757)
esp32/network: Use non-PSRAM Wi-Fi settings if PSRAM fails to initialise
In ESP-IDF, enabling SPIRAM in menuconfig sets a Kconfig option called Wi-Fi Cache TX Buffers and switches the default TX Buffer type to Dynamic. These settings use 54,528 bytes of heap at runtime.
Not a problem if PSRAM is available, but it's quite a lot of RAM to use up if PSRAM failed to initialise! As we use the same config for PSRAM & no-PSRAM devices now, this either causes Wi-Fi to fail to initialise (seen on S2) or will eat quite a lot of RAM (seen on S3).
Original ESP32 has separate builds for SPIRAM vs "no SPIRAM", so this doesn't change anything there.
The difference in free IDF Heap between an ESP32-S3 build (PSRAM fails to initialise) is 54,528 bytes after Wi-Fi initialises. Building MicroPython with Kconfig set to disable PSRAM (and Wi-Fi settings restored to default) shows another 1856 bytes free at boot, unsure what this is used for (probably not Wi-Fi related).
Closes #12750.
This work was funded through GitHub Sponsors.