ESP32 S3 with native USB in CDC, device restarts when the desktop app opens the virtual COM port

gjanpjetro
Posts: 3
Joined: Fri Jun 20, 2025 6:27 am

ESP32 S3 with native USB in CDC, device restarts when the desktop app opens the virtual COM port

Postby gjanpjetro » Fri Jun 20, 2025 3:58 pm

I have two projects: both use the ESP32S3, and both utilise the native USB as the virtual serial communication with specific desktop applications.
One project is developed in IDF, and the other in Arduino.
In both projects, we have set up the native USB in CDC mode.
In IDF, using the sdkconfig: Component config -> ESP System Settings -> Channel for console output - [USB Serial/JTAG Controller]
In Arduino, using the platformio.ini file, setting the build_flags as -D ARDUINO_USB_MODE=1 -D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MSC_ON_BOOT=0

In both projects we have the same problem.
If we connect the USB cable to the device, it starts the booting and arrives in a stable status.
When the desktop application opens the COM port, the device restarts.
After the restart is complete, the application can start communicating with the device.
How is it possible to avoid this behaviour?
Is this a problem with the ESP32 USB setup or with the source code on the desktop app?
Consider that different apps produce the same problem. Also the free YAT terminal app.
Example:
1) Connect the USB cable between the PC and the board (the USB cable also provides power to the board): the device reboots and enters a stable state.
2) Set the COM port in the YAT Terminal, in 115200@8N1, without flow control
3) Open the connection and the device starts a restart

Thanks

lbernstone
Posts: 1132
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32 S3 with native USB in CDC, device restarts when the desktop app opens the virtual COM port

Postby lbernstone » Sun Jun 22, 2025 7:25 am

Does the Arduino IDE serial monitor do this? The RTS and DTR signals in CDC emulate the transistors that are normally hooked up to pull gpio0 and en down for automatic programming. Make sure your terminal program is not sending RTS or DTR on connection.

gjanpjetro
Posts: 3
Joined: Fri Jun 20, 2025 6:27 am

Re: ESP32 S3 with native USB in CDC, device restarts when the desktop app opens the virtual COM port

Postby gjanpjetro » Sun Jun 22, 2025 12:35 pm

The Arduino serial monitor does not generate the device reboot. Additionally, the Teraterm app does not trigger a device restart when it opens the COM port.
However, in many other Windows apps, particularly customer apps, a device reboot is triggered.
The native USB connection has only the D+ and D- signals. The RTS and DTR signals are not present. Look at the Hw scheme in the attachment.
The board has the ESP-PROG connector (8 pins), but it is present only in the prototype boards, not in the production boards.
Attachments
HwProject_USB.jpg
HwProject_USB.jpg (242.98 KiB) Viewed 767 times

lbernstone
Posts: 1132
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32 S3 with native USB in CDC, device restarts when the desktop app opens the virtual COM port

Postby lbernstone » Tue Jun 24, 2025 3:22 pm

The HWCDC emulates the RTS signal as toggling EN, so if the terminal program sends those signals out, then the device will reboot. Make sure that hardware flow control is always turned off, and ask on vendor forums if they are setting RTS. Note that this is a hardware function, AFAIK there is no way to disable it.

gjanpjetro
Posts: 3
Joined: Fri Jun 20, 2025 6:27 am

Re: ESP32 S3 with native USB in CDC, device restarts when the desktop app opens the virtual COM port

Postby gjanpjetro » Wed Jun 25, 2025 10:15 am

Thanks "lbernstone" for your feedback.
Sorry, but I'm confused. When the reset occurs, the PC application is connected to the ESP32 through the native USB. So, the RTS is not driven from the app because there are only the D+ and D- signals in the USB. Is it the ESP32 by itself that drives the RTS signal toggling the EN?
Thanks

Who is online

Users browsing this forum: Google [Bot], PerplexityBot and 3 guests