ESP32程序调试 win10 使用OPENOCD及GDB工具
需求:使用OPENOCD及GDB工具调试ESP32程序,本文以ESP32-WROOM-32模块为例。环境说明:
- ESP32软件开发环境
- ESP32-WROOM-32模块
- J-link烧录器
步骤:
-
找到openocd.exe及xtensa-esp32-elf-gdb.exe路径,添加为path环境变量,重启
默认路径:
C:\Users\Yuule\ .espressif\tools\openocd-esp32\v0.10.0-esp32-20200709\openocd-esp32\share\openocd\scripts
C:\Users\Yuule.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\bin -
找到并修改对应板子的配置文件esp-wroom-32.cfg
默认路径:
C:\Users\Yuule\ .espressif\tools\openocd-esp32\v0.10.0-esp32-20200709\openocd-esp32\share\openocd\scripts\board
增加配置参数:
adapter_khz 1000 -
将J-link连接模块JTAG引脚
-
启动 openocd.exe
openocd -f .\interface\jlink.cfg -f .\board\esp-wroom-32.cfg
-
以hellow-world例程为例,在程序目录中创建gdbinit文件
-
程序编译后,启动GDB调试
xtensa-esp32-elf-gdb -x gdbinit .\build\hello-world.elf
结果展示:
GDB调试指令:
- 查看代码
查看10-20行
l(或list) 10,20 - 查看函数代码调用
bt(或backtrace)
- 设置删除断点
break N
delete N - 运行
c
- 单步、单行运行
s
n - 更多指令略