使用 openocd 显示 Cortex-M4 SWO 日志 [英] show Cortex-M4 SWO log with openocd

查看:55
本文介绍了使用 openocd 显示 Cortex-M4 SWO 日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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:

  1. 打开两个终端
  2. 在第一个终端运行openocd -f debug.cfg
  3. 在第二个终端运行 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆