Files
xiaozhi-esp32/main/boards
Copilot 280b2ff856 Fix crash when LAMP_GPIO or BUILTIN_LED_GPIO is GPIO_NUM_NC (#1853)
* Initial plan

* Add GPIO_NUM_NC guards for LampController and SingleLed across all board files

Boards crash when LAMP_GPIO or BUILTIN_LED_GPIO is set to GPIO_NUM_NC because
LampController and SingleLed are instantiated unconditionally.

Fix: Guard LampController with `if (LAMP_GPIO != GPIO_NUM_NC)` in InitializeTools()
and guard SingleLed with `if (BUILTIN_LED_GPIO != GPIO_NUM_NC)` in GetLed(),
falling back to NoLed when GPIO is not connected.

Fixes the reported crash on bread-compact-wifi-lcd and hardens all similar boards.

Co-authored-by: 78 <4488133+78@users.noreply.github.com>

* Fix crash when LAMP_GPIO or BUILTIN_LED_GPIO is GPIO_NUM_NC (minimal 2-file fix)

Instead of adding guards in every board file (36 files), fix the root cause
in just 2 source files:

1. SingleLed constructor: replace assert(gpio != GPIO_NUM_NC) with graceful
   early return, leaving led_strip_ as nullptr (all methods already null-check it)
2. LampController constructor: add early return when gpio_num == GPIO_NUM_NC

This fixes the crash on bread-compact-wifi-lcd and any other board where
these GPIOs are set to GPIO_NUM_NC.

Co-authored-by: 78 <4488133+78@users.noreply.github.com>

* Remove esp_timer_delete from destructor to match original behavior

Co-authored-by: 78 <4488133+78@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: 78 <4488133+78@users.noreply.github.com>
2026-03-20 07:02:03 +08:00
..
2026-02-19 20:10:27 +08:00
2026-02-09 19:16:49 +08:00
2026-02-19 20:10:27 +08:00
2026-02-19 20:10:27 +08:00
2026-02-19 20:10:27 +08:00