一款调试工具
默认已经搭建好了开发环境,使用brew安装好了openocd
各种介绍网上有很多这里就不多说
下面是我的openocd的安装路径/usr/local/Homebrew/share/openocd
一会要用到
这部分仅介绍使用,具体更深层次的介绍,可以看以后的介绍
连接stm32开发板之后使用命令连接openocd -f /usr/local/Homebrew/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/local/Homebrew/share/openocd/scripts/target/stm32g0x.cfg
这里第一个参数.cfg是指定连接的工具stlink等等,后面的stm32g0x.cfg是选择的芯片型号;选择对应的型号就可以
运行成功之后的提示信息,注意提示的端口
✘ yjhm@yjhmdeMacBook-Pro /usr/local/Homebrew/share/openocd/scripts/interface stable openocd -f /usr/local/Homebrew/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/local/Homebrew/share/openocd/scripts/target/stm32g0x.cfg
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
WARNING: interface/stlink-v2-1.cfg is deprecated, please switch to interface/stlink.cfg
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Info : STLINK V2J37M27 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.240865
Info : stm32g0x.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for stm32g0x.cpu on 3333
Info : Listening on port 3333 for gdb connections
在openocd连接成功后会发现这条信息,就可以使用telnet通过4444端口,连接openocd了
Info : Listening on port 4444 for telnet connections
执行telnet指定端口
telnet localhost 4444
连接上之后是这样的,右边是telnet
使用这个命令下载
flash write_image erase target.bin 0x08000000
如果使用.bin文件刷,一定要指定flash的地址这里是0x0800 0000,具体可查手册