[英]Gdb can't connect to OpenOCD on stm32
试图在 STM32L476 Nucleo-64 板上调试我的示例 flash_led 代码,但 gdb 无法连接到 OpenOCD(连接几乎立即断开并出现错误)。 我在这里和那里阅读了很多帖子,但没有一个有帮助。 尝试使用 -c 向 OpenOCD 添加命令,但没有改变行为。
我的代码在 Eclipse 的 Release 和 Debug 配置中编译。 我可以使用拖放来刷新 bin 文件(而板子具有内置的 STLink 附加组件)并且看起来代码在板上完美运行(LED 闪烁)。
使用以下版本在 Centos7 上交叉编译:
由于使用 eclipse 不起作用,我尝试了命令行,
(我在这个环境中不是经验丰富的开发人员,所以我找不到比 stm32l4discovery.cfg 更接近我的 stm32l476 板的任何配置文件,请让我知道使用它是否可能存在一些问题)
./bin/openocd -f scripts/board/stm32l4discovery.cfg -c "init"
开始,
GNU MCU Eclipse 64-bit Open On-Chip Debugger 0.10.0+dev-00462-gdd1d90111 (2019-01-18-11:37)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 500 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 500 kHz
Info : STLINK V2J28M17 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.244386
Info : stm32l4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
然后启动 GDB:
./arm-none-eabi-gdb ~/eclipse-workspace/test-blink-led/Debug/test-blink-led.elf
然后在 gdb 中运行以下命令:
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
Remote connection closed
由于它显示 gdb 连接立即断开,OpenOCD 提示以下错误:
Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080022e6 msp: 0x20017ff8
Info : device id = 0x10076415
Warn : STM32 flash size failed, probe inaccurate - assuming 1024k flash
Info : flash size = 1024kbytes
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
Error: jtag status contains invalid mode value - communication failure
Polling target stm32l4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
所以从那些每天在类似平台上做这件事的极客那里,谁能帮助我告诉我我哪里做错了。 缺少任何编译时标志是否会导致此问题?
我现在正在挠头几天,所以请让我得到你的提示。
原因之一可能是您的 STLINK 固件看起来很旧(如您的日志所示,STLINK V2J28M17)。 我建议下载STSW-LINK007应用程序来升级固件。 该软件是一个多平台的 Java 应用程序。 它在 Debian GNU/Linux 中完美运行。
目前,我使用另一个 gdb 服务器texane/stlink进行 GDB 调试任务,在某些 Nucleo 和自定义板上没有任何问题。 我使用target extended-remote
命令加入服务器的端口。 也许您也可以尝试在 OpenOCD 下使用此命令进行连接。
尝试 telnet 本地主机 4444
它对我有用,而 3333 没有
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.