0

I've heard that OpenOCD is supposed to daemonize after running some commands.

I try giving commands as CLI arguments. The commands are run, but OpenOCD does not background afterwards, so GDB is never run. I could add '&' to the end of the openocd command, but then I have a race condition with GDB.

How can I make OpenOCD daemonize after loading the flash?

13 # Launch OpenOCD
14   # specify our hardware debugger and mcu type
15   # reset target
16   # erase in bank 0 from 20k (0x5000) to end of flash
17   # load hex format because elf has extraneous section at 0x00000000
18   # NOTE: we don't use 'erase' so we can't blow away bootloader
19   # ??? daemonize when done so GDB can run 
20 openocd -f interface/olimex-arm-usb-tiny-h.cfg -f target/stm32f1x.cfg \
21   -l .openocd.log \
22   -c "init" -c "reset init" \
23   -c "flash erase_sector 0 20 last" \
24   -c "flash write_image $HEXFILE"
25
26 # run gdb
...
4

1 回答 1

2

您可以使用monitor命令从 GDB 中执行此操作,而不是在 OpenOCD 中写入闪存。

将您的 OpenOCD 更改为启动,如下所示:

20 openocd -f interface/olimex-arm-usb-tiny-h.cfg -f target/stm32f1x.cfg \
21   -l .openocd.log \
22   -c "init" &

然后使用.gdbinit与此类似的:

target remote localhost:3333
monitor reset halt
monitor flash erase_sector 0 20 last
monitor flash write_image build/my_project.hex
set remote hardware-breakpoint-limit 6
set remote hardware-watchpoint-limit 4
break main
continue

你仍然有竞争条件,因为 OpenOCD 仍然需要时间来启动,但这对我来说没问题,没有任何延迟。

于 2014-04-03T15:21:32.863 回答