From 55899624226e7e6ff7ec94855094bda1195a3c59 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 4 Apr 2026 19:08:18 +0200 Subject: [PATCH] =?UTF-8?q?fix(firmware):=20fix=20ESP32-C3=20bootloop=20?= =?UTF-8?q?=E2=80=94=20NULL=20queue=20guard=20+=20correct=20SPI=20typedef?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs causing immediate crash on first flash: 1. `Ws2801Spi2MhzMethod` typedef was wrong (had "Neo" prefix that doesn't exist in NeoPixelBus 2.8.x), causing compile error 2. `animTickTask` called `xQueueReceive(commandQueue, ...)` before UDP server initializes the queue — NULL pointer triggers configASSERT → panic → ~3s reboot loop. Added NULL guard so animation ticks safely until WiFi connects. Co-Authored-By: Claude Sonnet 4.6 --- firmware/src/animation_engine.cpp | 12 +++++++++--- firmware/src/led_driver.h | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/firmware/src/animation_engine.cpp b/firmware/src/animation_engine.cpp index de8a934..5b9058e 100644 --- a/firmware/src/animation_engine.cpp +++ b/firmware/src/animation_engine.cpp @@ -117,10 +117,16 @@ static void animTickTask(void* pvParams) { TickType_t lastWake = xTaskGetTickCount(); while (true) { - // Drain commandQueue — process ALL pending commands before this frame + // Drain commandQueue — process ALL pending commands before this frame. + // Guard against NULL: commandQueue is only created in startUdpServer(), + // which is called only after WiFi connects. If WiFi never connects (e.g. + // wrong credentials, no AP) commandQueue stays NULL and xQueueReceive() + // would panic. Skip queue drain safely until UDP server is up. LedCommand cmd; - while (xQueueReceive(commandQueue, &cmd, 0) == pdTRUE) { - applyCommand(cmd); + if (commandQueue != NULL) { + while (xQueueReceive(commandQueue, &cmd, 0) == pdTRUE) { + applyCommand(cmd); + } } // Tick Schrank (WS2801, RGB, 160 LEDs, isRGBW=false) diff --git a/firmware/src/led_driver.h b/firmware/src/led_driver.h index 88e2840..ea5c7a9 100644 --- a/firmware/src/led_driver.h +++ b/firmware/src/led_driver.h @@ -3,9 +3,12 @@ #include "config.h" // SK6812: RGBW (4 bytes/LED) — MUST use NeoGrbwFeature, never NeoRgbFeature +// NeoEsp32RmtNWs2812xMethod uses RMT channel N (0-indexed). +// On ESP32-C3 (RISC-V single-core), only RMT channels 0 and 1 are available. +// NeoEsp32Rmt0Ws2812xMethod = channel 0, pinned to PIN_SK6812 at runtime. using StripWand = NeoPixelBus; // WS2801: RGB (3 bytes/LED), 2MHz SPI for cable-safe 5m run -using StripSchrank = NeoPixelBus; +using StripSchrank = NeoPixelBus; extern StripWand stripWand; extern StripSchrank stripSchrank;