Custom ESP32-c3-mini-1 PCB flashing via USB errors

Hello,
I am testing my custom PCB with esp32-c3-mini-1 microcontroller. I tested all my peripherals by programming esp32 via USB_UART chip, that is present on PCB, but I also made a possibility to change flashing method, so now I try to flash firmware via USB. ESP32-c3 has integrated usb controller, so it can be flashed by just connecting D- and D+. Through searching I found ,that these lines are needed in platformio.ini file:

*upload_protocol = esp-builtin*
*debug_tool = esp-builtin*

I also changed drivers with Zadig to WinUSb
But when i try to flash my firmware to pcb, I get this error:

Open On-Chip Debugger  v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

adapter speed: 40000 kHz

Warn : Transport "jtag" was already selected
adapter speed: 5000 kHz

Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Error: libusb_get_string_descriptor_ascii() failed with -9
** OpenOCD init failed **
shutdown command invoked

Error: Unsupported xlen: -1
Error: Unknown target arch!
*** [upload] Error 1
====================================================================================== [FAILED] Took 1.83 seconds ======================================================================================

 *  The terminal process "C:\Users\pkasu\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--environment', 'esp32-c3-devkitm-1', '--upload-port', 'COM4'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

Any ideas what I’m doing wrong or what am I missing to flash my firm directly via USB?

Please show a screenshot for which device you’ve changed the drivers. Did this happen while the chip was in bootloader mode? (IO0 to GND)

I changed USB JTAG/serial debug unit (Interface 2):

I have found that my PCB design was interrupting flashing session, so after fixing it, I am able to flash the firmware, my code works (LED is blinking), but I also want to see text that I am printing via serial.println, maybe you know how to set up serial monitor to print my text via USB and not UART? I added these values in platformio.ini:

board_flags =
   -DARDUINO_USB_CDC_ON_BOOT=1
build_flags =
        -DARDUINO_USB_MODE=1

But starting serial monitor takes me to this window:

And I don’t know what to do next, no Available ports are present.

When you have two build flags you need to combine them to one option. Also there are no board_flags.

build_flags =
   -DARDUINO_USB_CDC_ON_BOOT=1
   -DARDUINO_USB_MODE=1

I see, thank you for correction. But this still doesn’t help. Its my first time trying to use internal USB JTAG controller to flash mcu and I’m just searching solutions on the internet. Since flashing is now working, I just want to see my data and text that I print. Maybe I need to change USB JTAG/serial debug unit (Interface 0) drivers? because USB JTAG/serial debug unit (Interface 2) and USB JTAG/serial debug unit (Interface 0) are two devices on device manager and zadig list, that disappears when I disconnect my PCB.

So yeah, I managed to solve this by myself. I will try to explain my steps for flashing and serial monitoring esp32-c3-mini-1 chip when using internal USB JTAG controller on Arduino framework:

  1. remove all chips or components from D- and D+ lines if they are not used, in my PCB, D- and D+ could go either to esp32 or to CP2102N-A02-GQFN24 chip, selection is made with jumpers, so I have to remove CP2102N chip completely.
  2. Add these lines in platformio.ini file of your project:
upload_protocol = esp-builtin
debug_tool = esp-builtin
build_flags =
   -DARDUINO_USB_CDC_ON_BOOT=1
   -DARDUINO_USB_MODE=1
  1. Using Zadig change USB JTAG/serial debug unit (Interface 2) drivers to WinUSB and USB JTAG/serial debug unit (Interface 0) drivers to USB serial (CDC)

  2. build and flash your project, this is my output after flashing:


    open serial monitor and you should see your prints.

Thank you so much for this info. I got the sparkfun pro micro esp32c3 working with this setup.