我正在尝试将OpenOCD与GDB配合使用来调试STM32F4Discovery板上的STM32F4 Cortex-M4。
设定:
我确保在STM32CubeMX中启用了调试线(这使调试线引脚保持默认状态)
GCC标志是:
import UIKit
import PlaygroundSupport
class ViewController: UIViewController {
let label: UILabel = {
$0.frame.origin = CGPoint(x: 50, y: 50)
$0.text = "Bob"
$0.sizeToFit()
return $0
}(UILabel())
let animation: CATransition = {
$0.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
$0.type = kCATransitionPush
$0.subtype = kCATransitionFromTop
$0.duration = 1
return $0
}(CATransition())
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
view.addSubview(label)
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(toggle(_:)))
view.addGestureRecognizer(tapGesture)
}
func toggle(_ sender: UITapGestureRecognizer) {
label.layer.add(animation, forKey: nil)
label.text = label.text == "Bob" ? "Dan" : "Bob"
label.sizeToFit()
}
}
let controller = ViewController()
PlaygroundPage.current.liveView = controller
我在主循环中添加了简单的闪烁LED代码,以测试调试。
我使用-mcpu=cortex-m4 -mthumb -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffunction-sections -fdata-sections -g -fno-common -fmessage-length=0
启动OpenOCD。 OpenOCD闪烁芯片并重置。 (可以找到OpenOCD的输出here)
现在我用GDB连接到它:
openocd -f board/stm32f4discovery.cfg -c "program build/discovery_simple_test.elf verify reset"
该程序应该在第93行中断,但它没有。
当我暂停执行并尝试继续执行时,它不会继续:
(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.
发生了什么,我该如何解决?
答案 0 :(得分:0)
可能是另一个GDB实例正在运行?
"正在调试程序。"
寻找一个" arm-none-eabi-gdb"处理并杀死它。
答案 1 :(得分:0)
我猜想使用的命令只是continue
而不是monitor continue
,因为您必须告诉GDB基础软件正在运行。
monitor continue
告诉嵌入式系统继续运行,但是GDB不知道(它不解释monitor
命令的含义,openocd知道)。
答案 2 :(得分:0)
要解决此问题,我在openocd中添加以下命令: -c gdb_breakpoint_override