OpenOCD - 卡在断点上,单步执行并继续不起作用

问题描述 投票:0回答:1

我使用带有 STLinkV3 的 STM32H745ZI Nucleo 板。我已经成功编译并运行了在 Cortex M7 内核上闪烁 LED 的简单程序。当程序在没有调试器的情况下运行时,一切都很好。

调试时出现问题。当我在打开 LED 的行上设置断点时,调试器会在此位置停止。问题是一旦停止,继续和单步执行将不起作用,直到断点被取消设置

代码并不复杂:

while (1) {
  LD1_SET(1);
  HAL_Delay(100);
  LD2_SET(1);
  HAL_Delay(100);
  LD3_SET(1);
  HAL_Delay(100);

  LD1_SET(0);
  HAL_Delay(100);
  LD2_SET(0);
  HAL_Delay(100);
  LD3_SET(0);
  HAL_Delay(100);
}

这就是 gdb 控制台中的样子:

# Setting breakpoint on LED ON
(gdb) b main.c:166
Breakpoint 1 at 0x8001788: file Src/main.c, line 166.
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

# Hit! Debugger seems working, LED is still OFF   
Breakpoint 1, main () at Src/main.c:166
166     LD1_SET(1);
(gdb) c
Continuing.

# Hit the same breakpoint with no blinking between
Breakpoint 1, main () at Src/main.c:166
166     LD1_SET(1);

# Setting breakpoint on LED OFF
(gdb) b main.c:174
Breakpoint 2 at 0x80017c6: file Src/main.c, line 174.
(gdb) c
Continuing.

# Still hits LED ON, LED is still OFF
Breakpoint 1, main () at Src/main.c:166
166     LD1_SET(1);
(gdb) info b
Num     Type           Disp Enb Address    What
1       breakpoint     keep y   0x08001788 in main at Src/main.c:166
    breakpoint already hit 3 times
2       breakpoint     keep y   0x080017c6 in main at Src/main.c:174

# Removing breakpoint on LED ON
(gdb) del 1
(gdb) c
Continuing.

# LED is ON, prorgram finally hit next breakpoint
Breakpoint 2, main () at Src/main.c:174
174     LD1_SET(0);

如何让它发挥作用?您以前遇到过类似的问题吗?

gdb stm32 cortex-m gdbserver openocd
1个回答
0
投票

我猜您正在使用开源 OpenOCD 版本。对于使用官方 OpenOCD 的 STM32H7xx CPU,单步执行代码不起作用(但正如您所发现的那样,闪烁工作正常)。

为了使调试设置正常工作,您可以在 STMCubeIDE 中创建调试配置并使用它。它使用 ST 的 OpenOCD 版本,其中包括 ST 对 OpenOCD 的修改,以使其能够与他们的 MCU 正常工作。

您可以将ST的OpenOCD脚本复制到您的项目中并使其正常工作。

注意,STMCubeIDE的版本比https://github.com/STMicroelectronics/OpenOCD早,因为ST没有保持公共版本最新,所以不要使用它,它不起作用。

© www.soinside.com 2019 - 2024. All rights reserved.