No USB or USB Connectivity Issues with My ESP32-S2 or ESP32-S3 Board
Problem: USB Serial Port Does Not Appear After Flashing
CDC On Boot
If using Arduino IDE, you must enable "CDC On Boot" in the tools menu for USB to initialize when your code starts.
In PlatformIO, add this to your build flags:
build_flags =
-D ARDUINO_USB_CDC_ON_BOOT=1
Code Crashing
These boards use native USB, meaning USB enumeration occurs as your code runs. If your code crashes, loops infinitely, or causes boot loops, USB will never enumerate or will disconnect again.
Important: Even without USB functionality in your code, the USB peripheral runs alongside user code on the main core. Code that blocks execution -- such as using delay() in Arduino -- can starve the USB peripheral of processing cycles, causing it to malfunction.
Problem: USB Works But Isn't Stable
Use a Quality USB-C Cable
Not all cables have data, and not all cables (especially long ones) are made well. Ensure your cable supports both data and power.
Connect Directly to Your Computer
Avoid USB hubs entirely. Unpowered hubs draw power from the host, and powered hubs may not deliver the required 5-5.1V consistently.
Try Flipping Your USB-C Cable
Sometimes dust or debris in the connector may block one direction. Reversing the cable can improve contact.
Last Updated: June 27, 2024