ESP32 Projects

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 .

How to use JTAG to debug ESP32-C3

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:

USB signal
Typical Wire Colors
ESP32-C3 Signal Names
ESP32-C3-DevKitM Pin Name
D-
White
GPIO18
J3.13
D+
green
GPIO19
J3.14
V_BUS
red
5V
J1.13 or J1.14
GND
black
GND
J1.15

 

How to use JTAG to debug ESP32-C3

The settings after the connection is completed are as follows:

How to use JTAG to debug ESP32-C3

 

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:

JTAG Signals
JTAG20 Pinout
ESP32-C3 Signals
ESP32-C3-DevKitM Pinout
TMS
7
IO4
J3.11
TDI
5
IO5
J3.10
TCK
9
IO6
J3.9
TDO
13
IO7
J3.8
GND
4
GND
J3.1

 

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:

How to use JTAG to debug ESP32-C3

2. Choose a name and location for your project:

How to use JTAG to debug ESP32-C3

3. Use the default CMake build system:

How to use JTAG to debug ESP32-C3

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:

How to use JTAG to debug ESP32-C3

5. Go ahead and clone the basic “blink” example:

How to use JTAG to debug ESP32-C3

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:

How to use JTAG to debug ESP32-C3

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:

How to use JTAG to debug ESP32-C3

8. Finally, press ” Finish ” to create the project. Now you will be able to build and debug it as usual:

How to use JTAG to debug ESP32-C3

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).

 

Back to top button