Port, board and/or hardware
esp32
MicroPython version
v1.26.1
Reproduction
I’ve tested this myself:
-
Turn on Wi-Fi
-
machine.freq(40_000_000)
MPY freezes
-
freq(40_000_000) first
-
wlan.active(True)
MPY freezes
Expected behaviour
Espressif’s docs do say that APB clock must be ≥80 MHz when wireless is on, and APB = CPU freq when it’s under 80 MHz
Observed behaviour
MPY freezes when cpu freq not compatitable with wireless module.
I think it stucks here:
|
while (esp_rom_get_cpu_ticks_per_us() != freq) { |
|
vTaskDelay(1); |
|
} |
|
// Wait for the interface to be in the correct state. |
|
while (self->active != active) { |
|
MICROPY_EVENT_POLL_HOOK; |
|
} |
Additional Information
Would it be possible to add a safeguard in MPY? For example:
If Wi-Fi or BLE is active, set a min allowed freq (raise an exception or warn if user tries to go lower)
When CPU freq already low, don't allow to enable wifi
Some tips from web:
| CPU Frequency |
Wi-Fi (STA/AP) |
BLE (Low Energy) |
Bluetooth Classic (A2DP, SPP, etc.) |
| ≥ 160 MHz |
✅ Stable |
✅ Stable |
✅ Recommended / Stable |
| 80 – 159 MHz |
✅ Generally OK |
✅ Generally OK |
⚠️ May be unstable (not recommended) |
| < 80 MHz |
❌ Unreliable / Hangs |
❌ Unreliable / Hangs |
❌ Likely to fail |
Code of Conduct
Yes, I agree
Port, board and/or hardware
esp32
MicroPython version
v1.26.1
Reproduction
I’ve tested this myself:
Turn on Wi-Fi
machine.freq(40_000_000)MPY freezes
freq(40_000_000)firstwlan.active(True)MPY freezes
Expected behaviour
Espressif’s docs do say that APB clock must be ≥80 MHz when wireless is on, and APB = CPU freq when it’s under 80 MHz
Observed behaviour
MPY freezes when cpu freq not compatitable with wireless module.
I think it stucks here:
micropython/ports/esp32/modmachine.c
Lines 128 to 130 in 27544a2
micropython/ports/esp32/network_wlan.c
Lines 291 to 294 in 27544a2
Additional Information
Would it be possible to add a safeguard in MPY? For example:
If Wi-Fi or BLE is active, set a min allowed freq (raise an exception or warn if user tries to go lower)
When CPU freq already low, don't allow to enable wifi
Some tips from web:
Code of Conduct
Yes, I agree