OpenOCD with CLion (debugging)

icylord
Posts: 1
Joined: Sun Jan 26, 2020 9:01 pm

OpenOCD with CLion (debugging)

Postby icylord » Sun Jan 26, 2020 9:04 pm

Has somebody managed it to use OpenOCD within CLion for debugging the ESP32? I cannot get it running.

ice.bob
Posts: 7
Joined: Thu Jan 30, 2020 10:31 pm

Re: OpenOCD with CLion (debugging)

Postby ice.bob » Sun Feb 02, 2020 1:16 pm

Nobody?

ESP_cermak
Posts: 69
Joined: Thu Nov 01, 2018 8:32 am

Re: OpenOCD with CLion (debugging)

Postby ESP_cermak » Mon Feb 03, 2020 7:24 am

Hi,

Remote debugging works good with CLion on linux and macOS (in theory should also work on windows, but have never tried)

* Go to Run->Edit Debug configuration
- Add GDB Remote Debug
- fill in GDB custom executable as xtensa-esp32-elf-gdb
- setup target remote as :3333
- set Symbol file to the actual elf file application being built/debigged
- set Sysroot to an existing path (no important, but must be existent)

* Optional: Setup openocd to be executed before debugging
- Configure external tool to be executed prior debugging
- Create shell script running valid openocd configuration (as a child process), for example:

Code: Select all

cd $OPENOCD_DIR/openocd-esp32
pkill -9 openocd
bin/openocd -s share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp32-wrover.cfg  &
sleep 1
exit 0
* Create custom gdbinit file:
- in $HOME directory create file named .gdbinit containing:

Code: Select all

set $esp_reset = 0
define hook-stop
    if ($esp_reset == 0)
	set $esp_reset = 1
	printf "Reset ESP with halt command\n"
	stop
	mon reset halt
	flushregs
	thb app_main
    end
end

apjbabin
Posts: 1
Joined: Mon Aug 03, 2020 9:43 pm

Re: OpenOCD with CLion (debugging)

Postby apjbabin » Mon Aug 03, 2020 10:40 pm

I can confirm CLion debugging works on Windows, thanks to cermak's instructions. The shell scripts don't apply, of course, but I added the openocd executable as an external tool and run it before starting the debugger.

Who is online

Users browsing this forum: No registered users and 43 guests