【问题标题】:Where does STDOUT go with GDB, OopenOCD and semihosting?STDOUT 与 GDB、OopenOCD 和半主机有什么关系?
【发布时间】:2019-09-27 00:02:47
【问题描述】:

我正在尝试找出 ARM (STM32042) 上的半主机。如果我直接从命令行运行openocd 并通过TCP 从gdb 连接到它,我可以看到printf 输出。但如果我从gdb 内部启动openocd,输出会转到天空中的某个大/dev/null。

如果我自己启动openocd

$ openocd -f interface/stlink-v2-1.cfg -f target/stm32f0x.cfg

然后像这样从gdb 连接到它

(gdb) target remote localhost:3333

我在opeocd 终端中看到printf 输出。但是,如果我按照this link 的建议从gdb 内部启动openocd

(gdb) target remote | openocd -f interface/stlink-v2-1.cfg -f target/stm32f0x.cfg -c "gdb_port pipe"

我看到了所有 openocd 调试消息(例如,xPSR: 0xc1000000 pc: 0x08001648 msp: 0x20001800, semihosting),但没有看到我的 printfs。

【问题讨论】:

  • 你发现了吗?
  • 是的,我做到了。谢谢你提醒我。见下文。

标签: arm gdb openocd semihosting


【解决方案1】:

结果比我想的要复杂一些。显然,在管道中启动 GDB 和 OpenOCD 是不可能的;他们需要通过套接字进行双向通信。因为它需要两个单独的命令调用,并且因为 GDB 的配置不仅仅是单行的,所以我把它放到了它自己的一个小存储库中:

https://github.com/arikrupnik/semihosting-ut

repo 包含将 stdout 路由到控制台的代码,但它的功能不止于此。我一直在将它广泛用于http://www.dish.tc 的 ARM 目标上的单元测试,并且发现它非常有用。我很乐意回答有关它的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-12
    • 1970-01-01
    • 1970-01-01
    • 2011-10-31
    相关资源
    最近更新 更多