From f4574e2213f0dbb53850f6e68c0f3629867e117c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 19 Nov 2026 17:14:37 -0500 Subject: [PATCH] espressif: default to no WiFi power save on ESP-Hosted boards With some access points, inbound traffic to the Metro ESP32-P4 stalls in MIN_MODEM power save. A likely cause is the ESP32-C6 co-processor missing broadcast and ARP frames in power save: https://github.com/espressif/esp-idf/issues/16096 Default to WIFI_PS_NONE until this is fixed upstream. Workaround for #11682. Co-Authored-By: Claude Opus 5.5 --- ports/espressif/common-hal/wifi/Radio.c | 10 ++++++++++ shared-bindings/wifi/Radio.c | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 44148cc6413..5df02ad5e7e 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -112,6 +112,16 @@ void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled) { #endif self->started = true; common_hal_wifi_radio_set_tx_power(self, CIRCUITPY_WIFI_DEFAULT_TX_POWER); + #ifdef CONFIG_ESP_HOSTED_ENABLED + // Temporary workaround: default to no power save on ESP-Hosted co-processors. + // + // With some APs, inbound traffic stalls in MIN_MODEM power save. A likely cause is + // the ESP32-C6 missing broadcast and ARP frames from the AP in power save. + // TODO: Remove when fixed upstream. + // https://github.com/espressif/esp-idf/issues/16096 + // https://github.com/adafruit/circuitpython/issues/11682 + esp_wifi_set_ps(WIFI_PS_NONE); + #endif return; } } diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index f94c5f3bbd1..235dc4fe9a8 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -203,8 +203,15 @@ MP_PROPERTY_GETSET(wifi_radio_tx_power_obj, (mp_obj_t)&wifi_radio_get_tx_power_obj, (mp_obj_t)&wifi_radio_set_tx_power_obj); +// TODO: Remove the ESP-Hosted exception below when the upstream bug is fixed. +// https://github.com/espressif/esp-idf/issues/16096 +// https://github.com/adafruit/circuitpython/issues/11682 //| power_management: PowerManagement //| """Wifi power management setting. See `wifi.PowerManagement`. The default is `wifi.PowerManagement.MIN`. +//| +//| On Espressif boards whose WiFi runs on an ESP-Hosted co-processor, such as the Metro ESP32-P4, +//| the default is `wifi.PowerManagement.NONE`. This is a temporary workaround for a bug in power +//| save mode; see `#11682 `_. //| """ static mp_obj_t wifi_radio_get_power_management(mp_obj_t self_in) { wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in);