Page 1 of 1

ESP32-DevKitM-1 JTAG Debugging in Eclipse

Posted: Tue Sep 07, 2021 11:45 pm
by Ninjabean
Sharing some experience

Environment
  • Windows 10
  • Eclipse 2021-06
  • ESP-IDF v4.3
  • OpenOCD v0.10.0-esp32-20210401
Hardware
  • ESP-PROG
  • ESP32-DevKitM-1
The ESP32-DevKitM-1 uses the ESP32-Mini-1 module which uses a ESP32-U4WDH SoC. This Soc is single core, unlike the more common dual core ESP32 SoCs, so the setup is a bit different and requires a few extra steps to get it going.

Blink example is used for the below.

Flashing over UART
If you flash over UART by strictly following the user guide only then the application will not run and the device will reset every 6 seconds or so.
Since this is a single core device you must enable single core mode. In Eclipse this can be done through sdkconfig -> Component config -> FreeRTOS and ticking "Run FreeRTOS only on first core". Now the application can be successfully flashed over UART.
https://docs.espressif.com/projects/esp ... ware-setup

Flashing and debugging over JTAG
Connect the ESP-PROG JTAG pins to the ESP32-DevKitM-1.
The menuconfig set up for flashing over UART above must be completed first before trying to flash and debug over JTAG.
I found this guide very helpful setting up JTAG debugging and flashing:
https://www.beyondlogic.org/debugging-with-jtag/
However, since this guide is for Ubuntu and a dual core ESP32 some changes need to be made to get it working for Windows and a single core device like the ESP32-DevKitM-1.

First, on windows the the ESP-PROG driver needs to be replaced using Zadig.
https://docs.espressif.com/projects/esp ... -jtag.html

Second, the OpenOCD config options need to be set up for single core operation. ESP32_ONLYCPU.
https://docs.espressif.com/projects/esp ... figure-tar
The guide above says to change the configuration to
-s ${openocd_path}/share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp32-wrover-kit-3.3v.cfg
Doing so will give you an error when you try to debug:
Warn : JTAG tap: esp32.cpu1 UNEXPECTED: 0xffffffff (mfg: 0x7ff (<invalid>), part: 0xffff, ver: 0xf)
Error: JTAG tap: esp32.cpu1 expected 1 of 1: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
One way to fix this is to create a copy of the "esp32_devkitj_v1.cfg" file located in ${openocd_path}/share/openocd/scripts/ interface/ftdi, rename it, I renamed it to "esp32_devkitj_v1_singlecore.cfg", and add these lines to the end of the file and save:

Code: Select all

# Single core version of ESP32
set ESP32_ONLYCPU 1
Change the interface .cfg path to the new file in config options. For me it was:

Code: Select all

-s ${openocd_path}/share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1_singlecore.cfg -f board/esp32-wrover-kit-3.3v.cfg
Now the debugging will execute. But the .bin file will not be loaded and this line of error can be seen on the console:
** Programming Started **
Error: couldn't open C:eclipse-workspaceesp32-iotlinkuildlink.bin
embedded:startup.tcl:449: Error: ** Programming Failed **
This is due to incompatibility of Windows Eclipse and OpenOCD file path syntax, forward slash vs. back slash.
https://github.com/espressif/openocd-esp32/issues/92
Not sure if there are other ways but, the easiest way I found to fix this problem is to use absolute paths. For example:

Code: Select all

mon program_esp C:/eclipse-workspace/esp32-iot/blink/build/blink.bin 0x10000 verify
Happy debugging... I hope. :D