← index #7904PR #12968
Likely Duplicate · high · value 1.550
QUERY · ISSUE

ESP32 - cannot initialize WLAN

openby eliclementopened 2021-10-15updated 2026-03-12
bugport-esp32

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)
CANDIDATE · PULL REQUEST

esp32/network: Use non-PSRAM Wi-Fi settings if PSRAM fails to initialise

mergedby projectgusopened 2023-11-14updated 2024-11-01
port-esp32

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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied