前馈科技

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 489|回复: 0

Ubuntu下Jlink调试STM32

[复制链接]

97

主题

97

帖子

539

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
539
发表于 2022-4-7 00:06:34 | 显示全部楼层 |阅读模式
1 安装JLINK驱动
在官网https://www.segger.com/downloads/jlink/ 下载.deb驱动包,本次下载的是V7.58b,直接双击安装

2 通过openocd和JLINK连接目标板

sudo openocd -f interface/jlink.cfg -f target/stm32f4x.cfg -c init -c "reset halt"
结果报错了:

Open On-Chip Debugger 0.11.0-snapshot (2021-10-12-23:33)
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>'.
Info : J-Link V9 compiled May  7 2021 16:26:12
Info : Hardware version: 9.50
Info : VTarget = 3.332 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


根据提示,是由于默认采用JTAG连接,需要通过transport select <transport>'改变成默认使用SWD
于是打开jlink.cfg进行修改,对于本机,openocd安装在:

/usr/local/share/openocd
打开/usr/local/share/openocd/scripts/interface/jlink.cfg在其中添加如下内容:transport select swd

改后如下:

#
# SEGGER J-Link
#
# http://www.segger.com/jlink.html
#

adapter driver jlink
transport select swd

# The serial number can be used to select a specific device in case more than
# one is connected to the host.
#
# Example: Select J-Link with serial number 123456789
#
# jlink serial 123456789

再次连接后成功:

sudo openocd -f interface/jlink.cfg -f target/stm32f4x.cfg -c init -c "reset halt"
Open On-Chip Debugger 0.11.0-snapshot (2021-10-12-23:33)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
swd
Info : J-Link V9 compiled May  7 2021 16:26:12
Info : Hardware version: 9.50
Info : VTarget = 3.332 V
Info : clock speed 2000 kHz
Info : SWD DPIDR 0x2ba01477
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Error executing event examine-end on target stm32f4x.cpu:
/usr/local/bin/../share/openocd/scripts/mem_helper.tcl:37: Error: wrong # args: should be "expr expression"
in procedure 'mmw' called at file "/usr/local/bin/../share/openocd/scripts/target/stm32f4x.cfg", line 85
at file "/usr/local/bin/../share/openocd/scripts/mem_helper.tcl", line 37
Info : starting gdb server for stm32f4x.cpu on 3333
Info : Listening on port 3333 for gdb connections
Error executing event examine-end on target stm32f4x.cpu:
/usr/local/bin/../share/openocd/scripts/mem_helper.tcl:37: Error: wrong # args: should be "expr expression"
in procedure 'ocd_process_reset'
in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 288
in procedure 'mmw' called at file "/usr/local/bin/../share/openocd/scripts/target/stm32f4x.cfg", line 85
at file "/usr/local/bin/../share/openocd/scripts/mem_helper.tcl", line 37
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08001878 msp: 0x20020000
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections


烧写flash:
sudo openocd -f interface/jlink.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32f4x_stlink.cfg -c "program nuttx.hex verify reset"

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|计算机控制

GMT+8, 2024-4-24 23:01 , Processed in 0.050209 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表