From cf28b3b5ea068c2ec19183c2d174bbdd73936e4e Mon Sep 17 00:00:00 2001 From: David Montero Date: Sat, 23 May 2026 22:54:10 +0200 Subject: [PATCH] fix(esp32): auto-enable WiFi NIC for MicroPython sketches using network module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hasWifi auto-detection in useSimulatorStore.startBoard only matched Arduino C++ patterns (#include , WiFi.begin). MicroPython sketches that call `import network` or `network.WLAN(STA_IF)` were not detected, so wifi_enabled stayed false and the backend never attached the esp32_wifi NIC model to QEMU. Symptom: any MicroPython ESP32 example that touches the network module hangs in network.WLAN(STA_IF) (the constructor that triggers esp_wifi_init internally) and the FreeRTOS task watchdog trips with TG1WDT_SYS_RESET ~26 seconds after boot. The chip then reboot-loops. Mirror the Pico W detector right below this one — it already handles both Arduino and MicroPython patterns. Now ESP32 does too. Affects 31 examples in examples-100-days.ts that use network.WLAN. --- frontend/src/store/useSimulatorStore.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/store/useSimulatorStore.ts b/frontend/src/store/useSimulatorStore.ts index e385fe94..186f9be2 100644 --- a/frontend/src/store/useSimulatorStore.ts +++ b/frontend/src/store/useSimulatorStore.ts @@ -1443,7 +1443,13 @@ export const useSimulatorStore = create((set, get) => { f.content.includes('#include ') || f.content.includes('#include ') || f.content.includes('#include "WiFi.h"') || - f.content.includes('WiFi.begin('), + f.content.includes('WiFi.begin(') || + // MicroPython patterns — without these the WiFi NIC is never + // passed to QEMU, and `network.WLAN(STA_IF)` hangs forever + // trying to init a peripheral that doesn't exist, eventually + // tripping the FreeRTOS task watchdog (TG1WDT_SYS_RESET). + /import\s+network\b/.test(f.content) || + /network\.WLAN/.test(f.content), ); } esp32Bridge.wifiEnabled = hasWifi;