显示带有openocd的Cortex-M4 SWO日志 [英] show Cortex-M4 SWO log with openocd
问题描述
我正在使用ubuntu,openocd和stlink开发stm32f407-discovery,我正在学习通过SWO引脚使用ITM模块从芯片获取日志.最后,我发现了openocd命令
I'm using ubuntu, openocd and stlink to develop stm32f407-discovery, I'm learning to use ITM module through SWO pin to get log from chip. Finally, I found that openocd command
tpiu config internal /tmp/swo.out uart off 168000000
从临时文件中获取日志是完美的,但是无论如何,它可以直接在openocd控制台上显示日志,例如半主机日志.谢谢
It's perfect to get log from the temporary file, but is there anyway to show log on openocd console directly, like semihosting log. Thanks
推荐答案
实际上,您非常接近实现理想结果的位置.首先,您不必指定输出流,默认是在openocd的控制台上公开的命名管道.我的意思是,您可以简单地进行更改:
Actually you where very close to achieve the desirable outcome . First thing first you don't have to specify an output stream ,the default is a named pipe that is exposed on openocd's console .What I mean is you could simply change:
tpiu config internal /tmp/swo.out uart off 168000000
具有:
tpiu config internal - uart off 168000000
尽管随后发生的问题是,您需要一个解析器来读取swo原始字节,但是幸运的是,这个非常未知但非常有用的存储库仅使用一个python脚本即可完成此任务: swo_parser
Although the problem that occurs then is that you need a parser to read the swo raw bytes ,fortunately there is this quite unknown but very useful repository that do just that with a single python script: swo_parser
因此,当我从jtag调试f1时总结一下我的配置(因为uart被用于其他目的)是
So to sum up my configurations when I was debugging an f1 from a jtag (because the uart was occupied for other purposes) was:
- 打开两个终端
- 在第一个终端上运行
openocd -f debug.cfg
- 在第二个终端上运行
python3 swo_parser.py
debug.cfg仅包含:
debug.cfg contains just :
source [find interface/stlink-v2.cfg]
source [find target/stm32f1x.cfg]
init
tpiu config internal - uart off 72000000
itm ports on
我也忘了提到你必须像这样做一个_write函数 ITM_SEND_CHAR定义
also I forgot to mention you have to make one _write function like this ITM_SEND_CHAR definition
这篇关于显示带有openocd的Cortex-M4 SWO日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!