Skip to content

fix(platforms): drop toxic ARDUINO_USB_CDC_ON_BOOT / USB_MODE flags#11

Merged
zackees merged 1 commit into
mainfrom
fix/remove-toxic-usb-cdc
Jun 20, 2026
Merged

fix(platforms): drop toxic ARDUINO_USB_CDC_ON_BOOT / USB_MODE flags#11
zackees merged 1 commit into
mainfrom
fix/remove-toxic-usb-cdc

Conversation

@zackees

@zackees zackees commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

Drop -DARDUINO_USB_CDC_ON_BOOT=1 and -DARDUINO_USB_MODE=1 from the ESP32 board envs that were carrying them.

Each affected ini also gets a short "Do NOT add" comment so the flag doesn't silently come back in future PRs.

Why this matters

With ARDUINO_USB_CDC_ON_BOOT=1, the Arduino-ESP32 core routes Serial to the USB-CDC interface, which only enumerates when a USB host is connected. Boards powered from a wall adapter then hang in setup() the moment user code touches Serial.

This is exactly the failure mode a starter repo must not ship with: users copy these envs as their starting point, the fixture works on the bench (plugged into a PC), and then stops working the moment they deploy it on a wall adapter.

Test plan

  • pio run -c platforms/platformio.esp32c3.ini still succeeds
  • pio run -c platforms/platformio.esp32c6.ini still succeeds
  • pio run -c platforms/platformio.esp32p4.ini still succeeds
  • Confirm a C6 sketch with Serial.begin(115200); Serial.println("hi"); in setup() now boots on a wall adapter (no host connected)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability for ESP32 C3, C6, and P4 boards by adjusting default serial communication settings, preventing potential hangs during initialization when devices are powered without a USB host connection.

With ARDUINO_USB_CDC_ON_BOOT=1 the Arduino-ESP32 core routes Serial to
the USB-CDC interface, which only enumerates when a USB host is
connected. Boards powered from a wall adapter then hang in setup() the
moment user code touches Serial. This is exactly the failure mode a
starter repo must not ship with — users copy these envs as their
starting point, and the fixture works on the bench but stops working
in deployment.

Drop the flag (and the related ARDUINO_USB_MODE=1) from every env that
was carrying it:

- esp32c6: remove both flags from build_flags
- esp32p4: remove ARDUINO_USB_MODE=1 (originally added per issue #9 spec)
- esp32c3: remove the explicit =0 stanza; default is already safe and
  the surrounding comment had the two states reversed

Each affected ini gets a short "Do NOT add" comment so the flag doesn't
silently come back.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 85792954-7aa9-4722-a3d3-17802f47bf4e

📥 Commits

Reviewing files that changed from the base of the PR and between f04558e and e9e80ba.

📒 Files selected for processing (3)
  • platforms/platformio.esp32c3.ini
  • platforms/platformio.esp32c6.ini
  • platforms/platformio.esp32p4.ini

📝 Walkthrough

Walkthrough

USB CDC compile-time build flags (ARDUINO_USB_CDC_ON_BOOT, ARDUINO_USB_MODE) are removed from three ESP32 PlatformIO configuration files (esp32c3, esp32c6, esp32p4). Each file gains inline comments warning that these flags must not be re-added because they route Serial to USB-CDC, which may hang if no USB host is connected.

Changes

USB CDC Flag Removal

Layer / File(s) Summary
Remove USB CDC flags and add warning comments
platforms/platformio.esp32c3.ini, platforms/platformio.esp32c6.ini, platforms/platformio.esp32p4.ini
Removes -DARDUINO_USB_CDC_ON_BOOT and -DARDUINO_USB_MODE defines from build_flags in all three environments and inserts comments explaining that enabling USB CDC can cause Serial to hang at boot when no USB host is present.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Three little configs, once causing a freeze,
No more USB CDC to hang on a breeze!
The UART stays cozy, the Serial is fine,
A wall adapter powers with no Serial whine.
Hop hop hooray, no more boot-time despair! 🎉

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-toxic-usb-cdc

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.

@zackees zackees merged commit 021fde7 into main Jun 20, 2026
1 of 2 checks passed
@zackees zackees deleted the fix/remove-toxic-usb-cdc branch June 20, 2026 04:39
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant