-
Notifications
You must be signed in to change notification settings - Fork 11
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.
- Adafruit HUZZAH32 - ESP32 Feather
- Olimex ARM-USB-OCD-H
- Breadboard 830 (630/200)
- USB Cable Type A to Type B (connection to the Olimex)
- USB Calbe Type A to Micro USB (connection to the ESP32)
- Breadboard Jumper Cables
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)
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:
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.
- Clone the OpenOCD ESP32 repository.
git clone https://github.com/espressif/openocd-esp32.git $HOME/esp32/openocd-esp
- Open the file
openocd-esp/tcl/target/esp32.cfg
and enable/uncomment the lineset ESP32_RTOS none
- 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
- 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:
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.