Conversation
(bool)Serial was wrong: HWCDC::isCDC_Connected() and USBCDC::operator bool() only report true once an actual terminal has exchanged data with the port (CDC TX/RX, or DTR/RTS), so the flag stays stuck false after a plain esp_restart() with no monitor attached, even though USB is genuinely powered. Confirmed on real V4.3 hardware: the charging icon vanished after WiFi-toggle reboots and only returned after a manual RST where a tool happened to be talking to the port. Two USB stacks are in play depending on ARDUINO_USB_MODE: - Native USB-Serial-JTAG (HWCDC, V4.3): Serial.isPlugged(), public static, purely SOF-frame-based (USB PHY level). - External USB-OTG via TinyUSB (USBCDC, Wireless Tracker V2): tud_mounted(), reflects real bus enumeration, independent of DTR/RTS. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Overrides isExternalPowered() on ESP32Board to use PHY-level USB detection instead of relying on (bool)Serial.
Why
No ESP32-S3 board in this codebase overrode isExternalPowered() before (confirmed by grep; the base MainBoard default is
return false;), unlike NRF52Board, which has a real VBUS-detect register (no ESP32-S3 equivalent exists). The obvious first attempt, (bool)Serial, is wrong on both USB stacks used in this codebase: HWCDC::isCDC_Connected() and USBCDC::operator bool() only report true once an actual terminal has exchanged data with the port (CDC TX/RX, or DTR/RTS), so the flag stays stuck false after a plain esp_restart() with no monitor attached, even though USB is genuinely powered. Confirmed on real V4.3 hardware: the companion display's charging icon vanished after a WiFi-toggle reboot and only came back after a manual RST where a terminal happened to be talking to the port.How
Two USB stacks are in play depending on ARDUINO_USB_MODE:
Common limitation either way: a dumb charger with no data lines generates no SOF traffic and never enumerates, so it will not be seen as external power; only an active USB host (PC, OTG phone) will.
Testing
Compiled and validated on real hardware for both stacks (Heltec V4.3 and Wireless Tracker V2): the charging icon now reflects actual USB presence across WiFi-toggle reboots and manual resets.
(Generated with Claude Code)