Using the Built-in USB-Serial-JTAG of ESP32-C3

1. Introduction

In short: The ESP32-C3 has built-in two development toolsusb-serial and usb-jtag, which allows programming, online debugging, and log output with just one data cable, greatly facilitating developers;

The following is from the official data manual introduction

Using the Built-in USB-Serial-JTAG of ESP32-C3

2. Prerequisites

  1. ESP-IDF version is 4.4.+
  2. Download firmware pin level requirements (Pay attention to the pins of Joint Download Boot mode)

Using the Built-in USB-Serial-JTAG of ESP32-C3

Download firmware pin description.png

3. Using USB-Serial

usb-serial can be used for firmware programming and log output, saving us a UART port;

  1. SDK configuration, set log output to built-in USB
  2. Using the Built-in USB-Serial-JTAG of ESP32-C3

  3. Configure download method

    Using the Built-in USB-Serial-JTAG of ESP32-C3

  4. Hardware pin connection
  5. Using the Built-in USB-Serial-JTAG of ESP32-C3

USB Port ESP32C3
VCC VCC
GND GND
USB_D- GPIO18
USB_D+ GPIO19
  1. Confirm that the driver has been installed correctly

    Using the Built-in USB-Serial-JTAG of ESP32-C3

  2. Select the COM port assigned to the built-in usb-serial of esp32c3 on the computer, and you can download the firmware

    Using the Built-in USB-Serial-JTAG of ESP32-C3

    View logs

    Using the Built-in USB-Serial-JTAG of ESP32-C3

4. Using USB-Jtag

usb-jtag is used for firmware downloading and online debugging

  1. Configure SDK, same as step 3.1

  2. Configure download method

  3. Select chip in VSCODE (remember to re-execute menuconfig for configuration after selecting the chip each time)

  4. Before online debugging, download the program once

  5. Create a launch.json file with the following content

{
    "version": "0.2.0",
    "configurations": [
     {
       "type": "espidf",
       "name": "esp32c3-debug",
       "request": "launch",
       "mode": "auto",
       "skipVerifyAppBinBeforeDebug": false
     }
    ]
}

File explanation

  • version: This field indicates the version of the VSCode debugger being used. Currently, version 0.2.0 is being used.

  • configurations: This field lists the configuration options for debugging operations. In this example, we only have one configuration.

  • type: Specifies the type of debugger to be used. Here, we use the ESP-IDF debugger.

  • name: This field is the name of the debugging configuration to be launched. Here, we name it esp32c3-debug, and you can define any suitable name.

  • request: Specifies the action that VSCode will take through the debugger. Here, we use the launch command to start a new debugging session locally.

  • mode: Specifies the debugging mode to be used in the debugging session. In this example, we use mode=auto, indicating that VSCode will choose local or remote debugging based on the situation.

  • skipVerifyAppBinBeforeDebug: Indicates whether to skip the application binary verification step to speed up debugging startup. This is an optional parameter, defaulting to false.

Start debugging

Using the Built-in USB-Serial-JTAG of ESP32-C3

Run the debugging program

Using the Built-in USB-Serial-JTAG of ESP32-C3

Thus, we can perform firmware downloading, log printing, and online debugging through the built-in USB-Serial-JTAG of ESP32-C3 with just one USB data cable, oh yeah;

Leave a Comment