Arm 用openocd显示Cortex-M4 SWO日志
我正在使用ubuntu、openocd和stlink开发stm32f407 discovery, 我正在学习通过SWO引脚使用ITM模块从芯片获取日志。最后,我发现openocd命令Arm 用openocd显示Cortex-M4 SWO日志,arm,cortex-m,openocd,Arm,Cortex M,Openocd,我正在使用ubuntu、openocd和stlink开发stm32f407 discovery, 我正在学习通过SWO引脚使用ITM模块从芯片获取日志。最后,我发现openocd命令 tpiu config internal /tmp/swo.out uart off 168000000 从临时文件中获取日志非常完美,但是仍然可以直接在openocd控制台上显示日志,就像半托管日志一样。谢谢在搜索了几天之后,我没有发现任何关于直接在控制台中打印openocd的信息 你可以做的是将它重定向到UA
tpiu config internal /tmp/swo.out uart off 168000000
从临时文件中获取日志非常完美,但是仍然可以直接在openocd控制台上显示日志,就像半托管日志一样。谢谢在搜索了几天之后,我没有发现任何关于直接在控制台中打印openocd的信息 你可以做的是将它重定向到UART(需要更多的硬件来设置)并使用另一个程序(如st link实用程序)来查看输出,但在终端中执行“cat/tmp/swo.out”更简单。我将它用作辅助程序 为了使输出与GDB在同一个终端上可见,并方便地同时启动所有内容,我启动GDB如下:
arm-none-eabi-gdb \
-iex 'target extended | openocd -f interface/stlink.cfg -f target/stm32f3x.cfg -c "gdb_port pipe"' \
-iex 'mon halt' \
-iex 'mon tpiu config internal swo.log uart false 2000000' \
-iex 'shell bash -m -c "orbuculum -f swo.log &"' \
-iex 'shell bash -m -c "orbcat -c 0,%c &"' \
firmware.elf
-iex
参数告诉gdb在启动时立即执行命令。以下是这些命令的作用:
目标扩展…
启动openocd并使用管道在它和gdb之间进行通信mon-halt
告诉OpenOCD停止任何正在执行的程序mon tpiu…
将OpenOCD配置为接收跟踪输出并将其写入swo.log
文件shell bash-m“orbuculum…
启动orbuculum服务器并告诉它从swo.log
读取。&
使其在后台运行,而bash-m
在单独的进程组中运行,以便GDB中的ctrl-c
不会意外停止它shell bash-m“orbcat…
启动Orbuculum工具从ITM端口0读取任何输出,并将其作为字符写入终端GNU gdb (GNU Tools for Arm Embedded Processors 8-2018-q4-major) 8.2.50.20181213-git
....
Reading symbols from firmware.elf...
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: firmware.elf
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800011c msp: 0x10001000
Boot
ADC ch 1 val -100
ADC ch 3 val 0
ADC ch 4 val 3
ADC ch 1 val 4091
.....
Orbuculum套件中还有其他有用的工具。例如,
orbtop-e firmware.elf
显示了执行时间花费的位置。实际上,您非常接近于实现理想结果的位置。
首先,您不必指定输出流,默认为openocd控制台上公开的命名管道
tpiu config internal /tmp/swo.out uart off 168000000
与:
尽管出现的问题是您需要一个解析器来读取swo原始字节,但幸运的是,有一个非常未知但非常有用的存储库,它只需要一个python脚本就可以做到这一点:
因此,当我从jtag调试f1时(因为uart被用于其他目的),总结一下我的配置是:
openocd-f debug.cfg
source [find interface/stlink-v2.cfg]
source [find target/stm32f1x.cfg]
init
tpiu config internal - uart off 72000000
itm ports on
而且我忘了提到你必须做一个这样的函数
source [find interface/stlink-v2.cfg]
source [find target/stm32f1x.cfg]
init
tpiu config internal - uart off 72000000
itm ports on