1

我正在尝试使用带有 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 的输出可以在这里找到)

现在我用 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

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

4

3 回答 3

1

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

于 2020-04-19T16:11:11.547 回答
0

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

于 2016-12-12T18:59:36.153 回答
0

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

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

于 2019-05-16T16:33:23.453 回答