【问题标题】:Gdb can't connect to OpenOCD on stm32Gdb 无法连接到 stm32 上的 OpenOCD
【发布时间】:2019-05-06 07:13:28
【问题描述】:

尝试在 STM32L476 Nucleo-64 板上调试我的示例 blink_led 代码,但 gdb 无法连接到 OpenOCD(连接几乎立即断开并出现错误)。我在这里和那里阅读了很多帖子,但没有一个有帮助。尝试使用 -c 向 OpenOCD 添加命令,但没有改变行为。

我的代码在 Eclipse 的 Release 和 Debug 配置中都编译。我可以使用拖放来刷新 bin 文件(而开发板具有内置的 STLink 插件),并且看起来代码在开发板上完美运行(LED 闪烁)。

使用以下版本在Centos7上交叉编译:

  • 工具链 (gdb):gcc-arm-none-eabi-8-2018-q4-major
  • OpenOCD:0.10.0-11-20190118-1134

由于使用 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

因此,从那些每天在类似平台上做这件事的极客那里,任何人都可以帮助并告诉我我哪里做错了。缺少任何编译时标志是否会导致此问题?

这几天我一直在摸不着头脑,所以请给我一些提示。

【问题讨论】:

    标签: gdb stm32 openocd


    【解决方案1】:

    其中一个原因可能是您的 STLINK 固件似乎很旧(如您的日志所示,STLINK V2J28M17)。我建议下载STSW-LINK007 应用程序来升级固件。该软件是一个多平台 Java 应用程序。它在 Debian GNU/Linux 中完美运行。

    目前,我使用另一台 gdb 服务器 texane/stlink 进行 GDB 调试任务,在某些 Nucleo 和自定义板上没有任何问题。我使用target extended-remote 命令加入服务器的端口。也许你也可以尝试在 OpenOCD 下使用此命令进行连接。

    【讨论】:

    • 你是女神。我怎么也想不到这一点。看来固件已经过时了。升级到 V2J34M25 (API v2) 后,它连接成功,虽然我还有一些其他问题。感谢您的宝贵时间。
    【解决方案2】:

    试试 远程登录 localhost 4444

    它对我有用,而 3333 没有

    【讨论】:

    • 4444端口确实是用于telnet连接,但实际上3333是gdb服务器端口。
    猜你喜欢
    • 1970-01-01
    • 2018-03-02
    • 2022-08-10
    • 2011-07-28
    • 2017-09-22
    • 1970-01-01
    • 2015-12-07
    • 2022-11-10
    • 2013-02-21
    相关资源
    最近更新 更多