Skip to content

Debugging ESP32

Stefan Profanter edited this page May 2, 2018 · 5 revisions

JTAG Debugging ESP32

The ESP-WROOM-32 microcontroller supports the OpenOCD protocol for debugging. This means that you need to buy an additional debugger hardware which you attach to the microcontroller, and then you can use any GDB-based debugger (like Eclipse, CLion) to debug code directly on the microcontroller.

Required Hardware

Optionally for the Status LEDs

  • Three LEDs (Green, Yellow, Red)
  • Resistors for the LEDs
    • 1x Red-Red-Brown (220 Ohm)
    • 2x Blue-Gray-Black (68 Ohm)
    • 1x Brown-Black-Brown (100 Ohm)

Wiring

To connect the Olimex Debugger with your ESP32 Feather board, you need 7 Jumper cables.

The number-char combination in parentheses is the hole I used on my breadboard.

  • (J2) - 3V -> Red -> VCC
  • (J4) - GND -> Black -> GND
  • (A6) - EN -> White -> TRST (Allows to reset the controller from the debugger)
  • (A8) - 13 -> Blue -> TLK/TCK
  • (A9) - 12 -> Orange -> TDI
  • (A12) - 15 -> Green -> TDO
  • (A14) - 14 -> Yellow -> TMS

Note: the JTAG 20 Pin interface in the following picture is the socket, and not the plug view. To connect your ESP32 with the Plug provided by Olimex you need to mirror the view correspondingly (check the images below).

The connected setup then looks like this:

With the board and all the (optional) leds the final setup is this:

Software installation

For the following steps I'm assuming that you are using a Linux OS, like Ubuntu 16.04 (where I tested the setup). Other OSes are probably also supported, but the commands may differ.

  1. Clone the OpenOCD ESP32 repository. git clone https://github.com/espressif/openocd-esp32.git $HOME/esp32/openocd-esp
  2. Open the file openocd-esp/tcl/target/esp32.cfg and enable/uncomment the line set ESP32_RTOS none
  3. Build OpenOCD and set an install target, e.g. $HOME/esp/openocd-esp-install
cd openocd-esp
./bootstrap
./configure --prefix=$HOME/esp/openocd-esp-install
make
make install
  1. To start OpenOCD, use the file in tools\OpenOCD\featheresp32.cfg:
$HOME/esp/openocd-esp-install/bin/openocd -f tools\OpenOCD\featheresp32.cfg

or if you are using the OpenOCD Plugin in CLion, you can use some similar settings:

Debugging

Now you can start the gdb debugger arduino-1.8.5/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb with your .elf file and it should do a remote debugging using openOCD.

Clone this wiki locally