| 
 
| 使用openocd + jlink 调试stm32f4x板子 
 遇到问题:
 
 
 PS D:\openocd> .\openocd.exe -f .\interface\jlink.cfg -f .\target\stm32f4x.cfgOpen On-Chip Debugger 0.10.0
 Licensed under GNU GPL v2
 For bug reports, read
 http://openocd.org/doc/doxygen/bugs.html
 Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
 adapter speed: 2000 kHz
 adapter_nsrst_delay: 100
 jtag_ntrst_delay: 100
 none separate
 cortex_m reset_config sysresetreq
 Info : No device selected, using first device.
 Info : J-Link V9 compiled Feb  2 2021 16:34:10
 Info : Hardware version: 9.50
 Info : VTarget = 3.325 V
 Info : clock speed 2000 kHz
 Error: JTAG scan chain interrogation failed: all zeroes
 Error: Check JTAG interface, timings, target power, etc.
 Error: Trying to use configured scan chain anyway...
 Error: stm32f4x.cpu: IR capture error; saw 0x00 not 0x01
 Warn : Bypassing JTAG setup events due to errors
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Invalid ACK (0) in DAP response
 Error: Could not initialize the debug port
 
 
 
 查了一下,解决方法:
 
 连接的设备平台是不支持jtag的,请检查自己设备的设置,是否使用的jtag的transport协议。解决方法很简单。openocd命令在没有指定的情况下默认会选择jtag协议。如果自己的设备使用了swd协议。需要单独指定。cp一份openocd的interface/XX.cfg文件,比如我使用的是j-link,我cp一份jlink.cfg并命名为jlnk-swd.cfg,文本内容如下
 interface jlink
 transport select swd
 
 注:openocd支持的transport可以使用命令查看
 openocd -c 'transport list'
 结果:
 
 
 没有报错,继续下一步。PS D:\openocd> .\openocd.exe -f .\interface\jlink_swd.cfg -f .\target\stm32f4x.cfgOpen On-Chip Debugger 0.10.0
 Licensed under GNU GPL v2
 For bug reports, read
 http://openocd.org/doc/doxygen/bugs.html
 swd
 adapter speed: 2000 kHz
 adapter_nsrst_delay: 100
 none separate
 cortex_m reset_config sysresetreq
 Info : No device selected, using first device.
 Info : J-Link V9 compiled Feb  2 2021 16:34:10
 Info : Hardware version: 9.50
 Info : VTarget = 3.325 V
 Info : clock speed 2000 kHz
 Info : SWD DPIDR 0x2ba01477
 Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
 
 
 | 
 |