How to use JTAG to debug ESP32-C3
This article mainly describes how to create a basic project for the RISC-V core-based ESP32-C3 device and how to debug it using JTAG. We will show all the necessary wiring on the ESP32-C3-DevKitM development board and the steps required to configure the software.
The ESP32-C3 chip contains its own on-chip USB-to-JTAG engine, so debugging can be done by connecting an auxiliary USB cable to the special debug USB pins (option A). Alternatively, debugging can also be done using an external JTAG probe (option B), but requires additional setup as described here .
In order to debug the ESP32-C3 using the built-in JTAG engine, you need to use an auxiliary USB cable and connect it to the following pins on the board:
The settings after the connection is completed are as follows:
Note that since the auxiliary USB connection also powers the board, you don’t need to connect another cable to the primary USB connector.
If you want to use an external USB-to-JTAG probe, you need to connect the following signals according to the Espressif documentation:
Once all the wiring is set up, follow these steps to create a basic project and debug it:
1. Start Visual Studio and open the VisualGDB ESP32 Project Wizard:
2. Choose a name and location for your project:
3. Use the default CMake build system:
4. Make sure you are using VisualGDB 5.6+, esp32 -gcc8.4.0-r3 toolchain or higher, and ESP-IDF 4.3 or higher. Then, select the ESP32C3 chip in the wizard:
5. Go ahead and clone the basic “blink” example:
6. Connect the auxiliary USB cable as shown at the beginning of this article. VisualGDB will automatically detect the JTAG interface built into the ESP32-C3 and select it on the Debug method page. Click “Test” to verify the connection:
7. Use the “Test” button to verify the connection. Note that VisualGDB may report that most device registers are set to 0. This is an expected result for ESP32-C3 devices and does not indicate an error:
8. Finally, press ” Finish ” to create the project. Now you will be able to build and debug it as usual:
9. Note that the default blink example does not blink the onboard LED. Instead, it configures IO5 (usually used as the TDI signal for external JTAG debugging) as an output and slowly toggles it. In order to debug the code with an external JTAG debugger, in addition to following the steps described here, you will need to disable this feature (for example, by changing BLINK_GPIO).