【问题标题】:Cannot set breakpoints with GDB and OpenOCD for STM32F4 with ST-Link无法使用 GDB 和 OpenOCD 为带有 ST-Link 的 STM32F4 设置断点
【发布时间】:2017-04-26 19:18:57
【问题描述】:

我正在尝试使用带有 GDB 的 OpenOCD 来调试我的 STM32F4Discovery 板上的 STM32F4 Cortex-M4。

设置:

  • Ubuntu 16.04
  • OpenOCD 0.9.0(也用 0.10-dev 测试过)
  • arm-none-eabi-gdb 7.10
  • STM32F4Discovery 与 ST-Link v2 (V2J28S0)
  • 使用 STM32CubeMX 生成的项目代码

我确保在 STM32CubeMX 中启用了调试线(这使调试线引脚保持默认状态)

GCC 标志是:

-mcpu=cortex-m4 -mthumb -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffunction-sections -fdata-sections -g -fno-common -fmessage-length=0

我在主循环中添加了简单的闪烁 LED 代码,以测试调试。

我用openocd -f board/stm32f4discovery.cfg -c "program build/discovery_simple_test.elf verify reset" 启动OpenOCD。 OpenOCD 刷新芯片并重置它。 (OpenOCD的输出可以找到here

现在我用 GDB 连接到它:

(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x08001450 in ?? ()
(gdb) set verbose on
(gdb) file "/abs_path/build/discovery_simple_test.elf"
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Load new symbol table from "/abs_path/build/discovery_simple_test.elf"? (y or n) y
Reading symbols from /abs_path/build/discovery_simple_test.elf...done.
Reading in symbols for /abs_path/Src/main.c...done.
(gdb) monitor reset
(gdb) break main
Breakpoint 1 at 0x8000232: file /abs_path/Src/main.c, line 71.
(gdb) break /abs_path/Src/main.c:93
Breakpoint 2 at 0x8000258: file /abs_path/Src/main.c, line 93.

程序应该在第 93 行中断,但它没有。

当我停止执行并尝试继续执行时,它不会继续:

(gdb) monitor halt
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x21000000 pc: 0x080006d8 msp: 0x2001ffe8
(gdb) monitor continue
//Program doesn't continue

发生了什么,我该如何解决?

【问题讨论】:

  • 你确定你点击了主函数吗?你有正确的时钟设置吗?
  • 感谢您的评论。时钟设置是 STM32CubeMX 的默认设置。我已将板载 ST-Link 更新为 J-Link 适配器,现在我正在使用 Segger 的 GDB 服务器。现在我至少可以继续我的项目了。

标签: c debugging gdb stm32 openocd


【解决方案1】:

可能是另一个 GDB 实例正在运行?
“一个程序已经在调试中。” 寻找“arm-none-eabi-gdb”进程并杀死它。

【讨论】:

  • OpenOCD 只接受一个 GDB 实例。我认为“一个程序已经在调试”是关于目标的状态。我已将板载 ST-Link 更新为 J-Link 适配器,现在我正在使用 Segger 的 GDB 服务器。
  • @i.amniels 是正确的,调试器只是检测到 micro 没有处于重置状态,而是在做 something
【解决方案2】:

我猜要使用的命令只是continue 而不是monitor continue,因为你必须告诉 GDB 底层软件正在运行。

monitor continue 告诉嵌入式系统继续,但 GDB 不知道(它不解释 monitor 命令的含义,openocd 知道)。

【讨论】:

    【解决方案3】:

    为了解决这个问题,我在 openocd 中添加了以下命令: -c gdb_breakpoint_override hard

    【讨论】:

      猜你喜欢
      • 2016-09-11
      • 1970-01-01
      • 1970-01-01
      • 2015-10-16
      • 2014-09-22
      • 1970-01-01
      • 2015-10-05
      • 1970-01-01
      相关资源
      最近更新 更多