-
Notifications
You must be signed in to change notification settings - Fork 7.6k
ESP32-S3 USB CDC doesn't work on every computer, "serial port is closed" errors #9580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you tested v3.0.0 and IDF to see if the behavior is the same? |
Arduino-ESP32 v3.0.0 breaks our production firmware, I will try to make it work on v3 and let you know. |
You can try latest version from branch https://github.com/espressif/arduino-esp32/tree/release/v2.x |
Well, then also check that a minimal sketch with the same hardware settings causes the issue. This seems like a core issue, not something in your code, but it will be useful to narrow that down. |
Do you can provide a small example sketch where the problem arrives? |
It's the one in the screenshoot:
|
Setup is not as recommended, but this should not the reason.
|
Yes I know, but it doesn't matter. CDC on boot is enabled so |
Can you try this example https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/HWCDC_Events/HWCDC_Events.ino It does as intended with my S3 CDC device. Tested with Mac. It could be a problem in combination with Windows. |
Sure, I'll try it Monday when I go back to the office. May I ask what is the difference between using |
The way to use the HWCDC port as serial UART. |
Yes I know, but in the case of the ESP32-S3, |
Other way around. HWCDCSerial is the "physical" object. Serial is aliased to that. This is why you don't need to initialize it. HWCDC initializes it b/c you have chosen that option in the menu. As far as why the port doesn't exist, this happens when the HWCDC reinitializes quickly. The PC makes another connection, but the previous one hasn't been torn down yet, so it grabs the next handle. You need to be patient with it. It is not great as a debugging tool- HWCDC is more for ease of programming production devices. |
@marcocipriani01 - please keep in mind that DTR and RTS signals of the USB CDC port actually control "reset" and "boot mode" signals of the ESP32-S3. It may be putting the S3 into download mode... "freezing/halting" the S3 firmware execution... |
This is not possible when using HWSerial CDC mode. |
In the Arduino Menu for the S3 there are 2 option: When The From the comment that says that |
As for a potential question like "what is the difference between Using Using |
Sure, I tried that example and got this result, pretty much identically to the
If
I have the exact same issues with serial port signals disabled.
Yes I was aware of that.
I am not using USB-OTG (TinyUSB). In my testing initial testing a few months ago, that mode was less reliable than hardware CDC because, obviously, it is a software implementation. If you think could help, I am available to set up TeamViewer or AnyDesk so you can test it yourself on affected computers. We're delaying our product's launch because of this issue so any help is greatly appreciated. |
We had issues with Windows and the current Arduino HWCDC driver too. We fixed it for our project Tasmota by commenting lines 312 and 313
Windows seems to have big trouble by doing that. and inserting after line 334
so the code block looks like this
This is not a solution which can be used in general! Code like |
Good to know I'm not the only one with the issue, I'm trying your workaround. Luckily I don't need |
@Jason2866 your fix appears to be working on my workstation, I will test it on all the affected computers (to be safe) and let you know. Thanks a lot! @SuGlider now that hardware CDC seems to work, regarding your note:
I can say now it isn't the case. In fact, I get the following in the serial monitor when connecting with serial port signals enabled:
Which is to be expected when entering bootloader mode. I didn't get this before applying the fix. |
Yes... this is a potential problem and conflict... Follow Arduino USB Serial specification (with @me-no-dev -- something to discuss for a next meeting. |
I've tested the fix on other affected computers and I can say it's working reliably. My suggestion, since you'll be releasing Arduino-ESP32-v3 with breaking changes, and since this issue only affects the ESP32-S3 and -C3, is to use a pre-processor directive to apply the fix only for affected devices:
Then you could document somewhere that |
@marcocipriani01 Tested PR #9628 does work for us. |
Fixed in #9628 Please take a look if this fixes your issues |
Great, as soon as the next release candidate is available I will test it out on affected computers to confirm! |
@marcocipriani01 - Please check the fix #9660 for Arduino Core 2.0.x |
Closing this as solved, 2.0.17 was released today. |
Board
ESP32-S3-WROOM-1U
Device Description
Self-powered ESP32-S3-WROOM-1U custom board with USB connected on pins IO19 and IO20. The power comes from a barrel jack and a 3.3V LDO regulator.
There is a USB Type-C connector and a TVS diode array (designed for USB 2.0 usage). VUSB doesn't go anywhere except for the TVS diode.
Hardware Configuration
Version
v2.0.15
IDE Name
Arduino IDE
Operating System
Windows 10, 11
Flash frequency
QIO 80MHz
PSRAM enabled
no
Upload speed
921600, upload via native USB
Arduino settings
Just USB CDC on boot:
Description
In my company, we developed a product based on the ESP32-S3-WROOM-1U that uses USB CDC on a Type-C connector to communicate with the computer. During prototyping we didn't have major issues with USB, but now we're testing the first production batch of boards on a large sample of computers and in various conditions. Unfortunately, about ¼ of the PCs in our production test have trouble connecting to the ESP32-S3, and the issue is unclear to us. These are some of the behaviors we observed:
While testing, I also discovered that opening and closing the serial monitor rapidly a few times (open-close-open-close-...) makes the USB CDC stop working. For example, I created a sketch that prints "Hello" and does one
Serial.read()
every second in theloop()
function. After opening and closing the serial port a few times, I no longer see "Hello", I receive nothing.The issues happens on all the 30 boards in our first production batch. They've been professionally reflow soldered by another company. I manually inspected all of them under a microscope for soldering defects around the USB Type-C connector and the ESP32 module. It is a 6 layer board and the USB differential pair is length-matched and impedance-controlled to 90Ω according to USB standard.
Sketch
Any Arduino sketch that uses
Serial.print()
,Serial.println()
,Serial.read()
.Debug Message
"The serial port is closed" on some software.
Other Steps to Reproduce
Unclear. Depends on the PC where testing.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: