主要
查看路径
yjw@ubuntu:~$ echo $OPENOCD_SCRIPTS
/home/yjw/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts
OpenOCD 的参数
--help | -h 显示帮助信息
--version | -v 显示 OpenOCD 版本号
--file | -f * 使用配置文件 <文件名>
--search | -s * 指明配置文件和脚本所在的目录,类似环境变量的path配置
--debug | -d 设置调试级别为3
| -d<n> 设置调试级别为 <level>
--log_output | -l 重定向日志输出到文件<name>
--command | -c * 运行命令<命令>
启动和整合
启动 OpenOCD【参考:根据目标芯片配置 OpenOCD】
我这里使用的是 ESP-Prog 调试器,开发板为ESP32-DevKitC V4开发板
所以使用如下指令:
openocd -f interface/ftdi/esp32_devkitj_v1.cfg -f target/esp32.cfg
# 查看路径
echo $OPENOCD_SCRIPTS
# 在路径创建yjw.cfg文件
gedit /home/yjw/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/yjw.cfg
内容如下
# 获取JTAG接口配置文件的源代码
source [find interface/ftdi/esp32_devkitj_v1.cfg]
# 设置电压3.3
set ESP32_FLASH_VOLTAGE 3.3
# 导出ESP32配置文件
source [find target/esp32.cfg]
这样就把指令openocd -f interface/ftdi/esp32_devkitj_v1.cfg -f target/esp32.cfg
整合成了openocd -f yjw.cfg
其他
使用 OpenOCD 通过 JTAG 接口将应用程序镜像烧写到闪存中
命令如下:
openocd -f yjw.cfg -c "program_esp build/blink.bin 0x10000 reset exit"
其中 OpenOCD 的烧写命令 program_esp
具有以下格式:program_esp <image_file> <offset> [verify] [reset] [exit]
image_file
- 程序镜像文件存放的路径offset
- 镜像烧写到闪存中的偏移地址verify
- 烧写完成后校验闪存中的内容(可选)reset
- 烧写完成后重启目标(可选)exit
- 烧写完成后退出 OpenOCD(可选)