Debugging on ESP32 with OpenOCD and SEGGER J-Link
ESP32 is one of the popular chipsets for Wi-Fi and BLE-based IoT development. ESP32 provides the facility to flash the board via the UART port. However, there is no on-chip debugger available to step debug your program on ESP32. Either you need to buy an ESP Debugger kit or you can use your existing Debugger like J-Link to debug your program. Debugging with J-Link is not explained on official Esperessif Docs. Most Embedded developers have J-Link already available, so it's obvious to use that one instead of purchasing an ESP debugger.
In this post, I'll explain in detail how to use J-Link with ESP32 boards to debug your programs on Ubuntu 20.04 Linux OS.
Please make sure that you have not installed Segger J-Link drivers as we are going to use OpenOCD here.
Before we start the Software part, let's ensure proper hardware connection between J-Link and ESP32 board.
I am using ESP32-S2-WROVER and J-Link Pro for my setup.
ESP32-S2 and J-Link Pro connection
- Right-click on the project, click on Debug As -> Debug configurations.
- Click on "ESP-IDF GDB OpenOCD Debugging" in left column on Dialog.
- Click on "New Configuration" Icon on top left corner.
- You will see that new configuration is filled with default values.
- Click on the second Debugger tab and modify "Config options:" field with following value.
- -s ${openocd_path}/share/openocd/scripts -f interface/jlink.cfg -f target/esp32s2.cfg -c 'adapter_khz 2000'
- Click on Debug button. Make sure that ESP32 and J-Link are connected to your PC.
Which version of OpenOCD did you use?
ReplyDeleteEspressif has ported OpenOCD for use with their chipset. I am using v0.10.0-esp32-20200709 version. You can follow steps on Espressif website to compile their ported OpenOCD on your PC and use it.
DeleteWhat is the configuration file I need to use on MAC for the JLink to work ?
ReplyDelete