一、jlink驱动的安装
参考:https://blog.csdn.net/p1279030826/article/details/102891704
二、ESP32开发环境的搭建
参考:https://blog.csdn.net/karaxiaoyu/article/details/122613328
三、openocd的安装
第一步:下载最新版的openocd-32的发行版,不能使用原版的openocd。下载地址:https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20230921/openocd-esp32-linux-amd64-0.12.0-esp32-20230921.tar.gz
此处对下载的文件夹进行了重命名:openocd-esp32-20230921。存放路径为:/home/ubuntu/ESP/openocd-esp32-20230921
第二步:添加环境变量
gedit ~/.bashrc
最后一行添加:export PATH=$PATH:/home/ubuntu/ESP/openocd-esp32-20230921/bin
Source ~/.bashrc
第三步:启动openocd,命令:openocd -f /home/ubuntu/ESP/openocd-esp32-20230921/share/openocd/scripts/interface/jlink.cfg -f home/ubuntu/ESP/openocd-esp32-20230921/share/openocd/scripts/board/esp-wroom-32.cfg
第四步:添加xtensa-esp32-elf工具连
参考:https://docs.espressif.com/projects/esp-idf/zh_CN/release-v3.3/get-started/linux-setup.html
四、使用gdb调试
执行xtensa-esp32-elf-gdb -x gdbinit build/blink.elf 开始调试。具体调试方法课参考其他博客,或者参考https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/jtag-debugging/using-debugger.html#jtag-debugging-using-debugger-command-line