Skip to content

fix(examples): route the console to UART0 in every usb_device example - #804

Merged
finger563 merged 1 commit into
mainfrom
fix/usb-examples-console-uart0
Sep 21, 2026
Merged

finger563 merged 1 commit into
mainfrom
fix/usb-examples-console-uart0

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Summary

Five espp::UsbDevice examples left the system console on its default, USB-Serial-JTAG (two of them selected it explicitly). On the ESP32-S3 and -P4 that peripheral shares the native USB port's PHY with USB-OTG, which TinyUSB takes over, so out of the box the vendor / CDC interfaces never came up on that port. The ota, switch_pro, msc_example and xinput_example examples already route the console to UART0; this brings the rest in line:

  • bldc_haptics/example, canopen/can_bridge_example, coredump/example, mcp266/webapp_example, telemetry/example: CONFIG_ESP_CONSOLE_UART_DEFAULT=y with USB-Serial-JTAG as the secondary console (early-boot logs still visible on the native port before TinyUSB starts), replacing the explicit CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y in the CAN bridge and MCP266 examples.
  • The CAN bridge, MCP266 and telemetry READMEs claimed the console "stays on the separate built-in USB-Serial-JTAG"; they now say UART0 and why.

The bldc_haptics and coredump examples additionally route the console onto their CDC port at runtime (tinyusb_console_init), which is unaffected by the boot-time default.

CANopen / DS402 follow-up to #803

Reviewed every other espp::Twai user for the same missing-initialize() bug: the twai, canopen, mcp266 and mcp266 webapp examples all call initialize() before use, and the canopen component itself is transport-agnostic (it never owns a node). The rest of the bridge request handler (CAN_TX / SET_CONFIG / STOP / GET_STATUS) guards the bus state correctly, and the CAN console and DS402 panel drive START exactly as the firmware expects. No further code changes were needed there.

Test plan

  • All five examples build with IDF_COMPONENT_MANAGER=0 (as CI does) and the resulting sdkconfig selects UART0
  • Hardware: can_bridge_example on an S3 devkit enumerates over the native USB port with a stock sdkconfig; DS402 panel START brings the bus up

🤖 Generated with Claude Code

https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU

bldc_haptics, can_bridge, coredump, mcp266 webapp and telemetry examples left
the console on USB-Serial-JTAG (the CAN bridge and MCP266 ones selected it
explicitly), which shares the S3 / P4 native USB PHY with USB-OTG: TinyUSB
takes that port, so the examples did not enumerate with a stock sdkconfig.
Use UART0 as the primary console with USB-Serial-JTAG secondary, like the
ota / switch_pro / msc / xinput examples, and fix the READMEs that claimed
the console stays on USB-Serial-JTAG.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
Copilot AI lite review requested due to automatic review settings September 21, 2026 15:13
@github-actions

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

@finger563
finger563 merged commit 806ddd3 into main Sep 21, 2026
165 of 166 checks passed
@finger563
finger563 deleted the fix/usb-examples-console-uart0 branch September 21, 2026 15:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR routes the primary console of five espp::UsbDevice examples to UART0 so TinyUSB can use the native USB PHY, while documenting the new console connection requirements.

Changes:

  • Selects UART0 as the primary console and USB-Serial-JTAG as a secondary console in five example configurations.
  • Updates CAN bridge, MCP266, and telemetry documentation to describe UART0 console usage.
  • Explains the USB-Serial-JTAG/USB-OTG PHY conflict on ESP32-S3 and ESP32-P4.
File Description
components/​telemetry/​example/​sdkconfig.defaults Routes the telemetry example console to UART0.
components/​telemetry/​example/​README.md Documents separate native-USB flashing and UART0 monitoring.
components/​mcp266/​webapp_example/​sdkconfig.defaults Routes the MCP266 webapp console to UART0.
components/​mcp266/​webapp_example/​README.md Updates MCP266 console and build instructions.
components/​coredump/​example/​sdkconfig.defaults Routes the coredump example console to UART0.
components/​canopen/​can_bridge_example/​sdkconfig.defaults Routes the CAN bridge console to UART0.
components/​canopen/​can_bridge_example/​README.md Updates CAN bridge console and build instructions.
components/​bldc_haptics/​example/​sdkconfig.defaults Routes the BLDC haptics console to UART0.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +16 to +17
# USB-Serial-JTAG stays the SECONDARY console so early-boot / bootloader logs are
# still visible on the native USB port before the app brings up TinyUSB.
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