Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 20, 2025

ESP32-C3, ESP32-S2, and ESP32-S3 devices were configured with ARDUINO_USB_MODE=1 which causes them to wait for a USB debugger connection and never boot WLED without a USB data connection. This prevented end users from powering their devices from regular power supplies or wall adapters.

Problem

When ARDUINO_USB_MODE=1 is set, these ESP32 variants:

  • Wait indefinitely for a USB debugger to connect
  • Never complete the boot process without USB data connection
  • Cannot be used in production deployments with non-USB power sources

However, developers need ARDUINO_USB_MODE=1 for USB debugging capabilities during development.

Solution

Implemented a conditional approach using a PlatformIO script (pio-scripts/conditional_usb_mode.py) that automatically detects the build context:

Development Builds (Default)

  • ARDUINO_USB_MODE=1 - Preserves USB debugging capabilities
  • Detected when WLED_RELEASE environment variable is not set
  • No changes to developer workflow

CI/Release Builds

  • ARDUINO_USB_MODE=0 - Allows normal boot without USB debugger connection
  • Detected when WLED_RELEASE environment variable is set to True (as done in GitHub Actions CI)
  • Automatically produces end-user-friendly binaries

The script runs as a pre-build step and modifies the build flags dynamically based on the environment context.

Impact

  • Developers: Keep USB debugging by default, no workflow changes needed
  • End users: Get CI binaries that boot properly without USB debugger connection
  • CI builds: Automatically produce production-ready binaries
  • No breaking changes: Maintains existing development experience

This conditional approach ensures that CI-built binaries are suitable for end users while preserving full developer functionality for debugging workflows.

Fixes #255.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Avoid using ARDUINO_USB_MODE=1 in pio environments Fix ARDUINO_USB_MODE=1 causing devices to hang without USB debugger Sep 20, 2025
@Copilot Copilot AI requested a review from netmindz September 20, 2025 11:39
Copilot finished work on behalf of netmindz September 20, 2025 11:39
@netmindz
Copy link
Collaborator

@copilot This is a tricky one, for development you really need ARDUINO_USB_MODE set to 1, but for the bin files created by the CI workflow, we should not have this set as it's not suitable for end users

Copy link
Author

Copilot AI commented Sep 20, 2025

@copilot This is a tricky one, for development you really need ARDUINO_USB_MODE set to 1, but for the bin files created by the CI workflow, we should not have this set as it's not suitable for end us...

You're absolutely right about the tricky requirements! I've implemented a better solution that addresses both needs.

The new approach uses a conditional PlatformIO script that automatically detects the build context:

Development builds (default): ARDUINO_USB_MODE=1 - preserves USB debugging capabilities
CI/Release builds: ARDUINO_USB_MODE=0 - enables normal boot without USB debugger

The script detects release builds using the existing WLED_RELEASE=True environment variable that's already set in the GitHub Actions CI workflow. This means:

  • Developers get USB debugging by default (no changes to workflow)
  • End users get binaries that boot properly from any power source
  • No manual configuration needed

Changes in commit e094d60.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • wled00
    • Triggering command: node tools/cdata.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Copilot Copilot AI changed the title Fix ARDUINO_USB_MODE=1 causing devices to hang without USB debugger Implement conditional ARDUINO_USB_MODE: dev=1, release=0 to fix boot hanging Sep 20, 2025
Copilot finished work on behalf of netmindz September 20, 2025 12:07
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.

Avoid using ARDUINO_USB_MODE=1 in pio environments

2 participants