Skip to content

Conversation

@troyhacks
Copy link
Collaborator

@troyhacks troyhacks commented Jan 29, 2026

This seems to put an and to the clusterfuck that is Serial on the ESP32-S3/C3/C6/etc.

You can now always have a serial console available with:

-D ARDUINO_USB_MODE=1 -D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MSC_ON_BOOT=0 -D ARDUINO_USB_DFU_ON_BOOT=0

With WLED_DEBUG you get a small delay as it tries a Serial few times, even if using WLEDMM_NO_SERIAL_WAIT - but it still comes up under "only power connected"

Plug back into your laptop, and you get a serial console and firmware uploading just the same as an ESP32-reggo.

This ends the madness, I hope.

Summary by CodeRabbit

  • New Feature/Fix

    • Allows USB serial (CDC) to be always enabled on the ESP32-S3, ESP32-C3, and ESP32-C6 preserving expected runtime serial behavior, just like on the original ESP32.
  • Bug Fixes

    • Fixes for the ESP32-C6 variant checks during build.
      • Not the point of this PR but the rabbit complained.

@troyhacks troyhacks requested a review from softhack007 January 29, 2026 18:45
@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

Adds ESP32C6 to build-architecture guards and mutual-exclusion checks, expands USB-CDC-on-boot handling to ESP32S3/ESP32C3/ESP32C6, and introduces a CDC-specific boot Serial initialization path that calls Serial.begin(115200) then Serial.setTxTimeoutMs(0). Also broadens runtime USB-CDC gating to include S3/C3/C6.

Changes

Cohort / File(s) Summary
Build guards & boot Serial
wled00/wled.cpp
Adds ESP32C6 to IDF/target guards and mutual-exclusion checks for ESP32 variants; inserts a CDC-on-boot path for ESP32S3/C3/C6 that runs Serial.begin(115200) then Serial.setTxTimeoutMs(0) while preserving existing serial-wait logic.
Runtime USB-CDC gating
wled00/wled_serial.cpp
Expands the canUseSerial condition to permit USB-CDC on ESP32S3, ESP32C3, and ESP32C6 when ARDUINO_USB_CDC_ON_BOOT is set (excluding WLED_DEBUG_HOST), keeping the existing runtime null-checks and gating rules intact.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 At boot I twitched a tiny wire,
CDC woke up and caught the fire,
Baud set steady, timeout nil,
ESP siblings hum and fill.
A hop, a blink — the serial choir.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: enabling proper serial console on ESP32-S3/C3/C6 under all conditions, which aligns with the PR's core objective and the file-level changes.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@wled00/wled.cpp`:
- Around line 470-485: Remove the critical section around
Serial.begin/Serial.setTxTimeoutMs: delete the portMUX_TYPE mux =
portMUX_INITIALIZER_UNLOCKED; portENTER_CRITICAL(&mux); and
portEXIT_CRITICAL(&mux) calls so Serial.begin(115200) and
Serial.setTxTimeoutMs(0) run normally (setup() is single-threaded); if true
exclusivity is required later, replace that pattern with a FreeRTOS recursive
mutex rather than disabling interrupts. Ensure the `#if` branch that currently
contains portENTER_CRITICAL/portEXIT_CRITICAL is simplified to just call
Serial.begin(115200) and Serial.setTxTimeoutMs(0).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@wled00/wled.cpp`:
- Around line 470-475: The build validation currently enumerates allowed
CONFIG_IDF_TARGET_* macros but omits CONFIG_IDF_TARGET_ESP32C6, causing C6
builds to hit the "No supported CONFIG_IDF_TARGET was defined" error; update the
sanity-check macros and any mutual-exclusion guards to include
CONFIG_IDF_TARGET_ESP32C6 (add it alongside CONFIG_IDF_TARGET_ESP32,
CONFIG_IDF_TARGET_ESP32S3, CONFIG_IDF_TARGET_ESP32S2, CONFIG_IDF_TARGET_ESP32C3)
so that the checks that reference these macros (the CONFIG_IDF_TARGET_*
validation block and any `#if/`#elif exclusivity guards) accept ESP32C6 builds and
keep existing behavior for other targets.

@softhack007
Copy link
Collaborator

@troyhacks "/etc" = P4 included? Because i'd like to fix this **** once and for all :-)

@troyhacks
Copy link
Collaborator Author

@troyhacks "/etc" = P4 included? Because i'd like to fix this **** once and for all :-)

The P4 doesn't have this problem. It has real USB ports for USB things.

But in the case of that one Olimex P4 board with a single USB-C port, yes, I think it would fix that too.

@troyhacks
Copy link
Collaborator Author

It works so well I forgot and built an S3 without it, and it immediately stopped when I disconnected the serial console.

It can indeed miss some characters and sometimes looks a bit garbled - but it freakin' works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants