在STM32H7上使用执行跟踪片上缓冲器(ETB) [英] Use execution trace on-chip buffer (ETB) on STM32H7

查看:285
本文介绍了在STM32H7上使用执行跟踪片上缓冲器(ETB)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些特定情况下,我需要输出片上缓冲区(ETB)执行跟踪。我说的是操作功能,而不是调试阶段的ETM跟踪。

I need to output the on-chip buffer (ETB) execution trace in some particular cases. I'm talking about an operational functionality, not about ETM trace during debugging phase.

我已经阅读了《 Arm®CoreSight™ETM-M7技术参考手册》 ,但是关于使用此ETB功能的细节几乎没有。

I've read Arm® CoreSight™ ETM-M7 Technical Reference Manual but there is almost no detail about using this ETB feature.

还有此链接位于ARM信息中心,但我特别不清楚。

There is also this link on ARM Information center, but I found it particularly unclear.

如何使用ETB?

编辑:由于STMicro的演示,我澄清了一些情况。它指出 ETF可以用作跟踪缓冲区,用于在芯片上存储跟踪。可以通过软件或调试器读取
或通过跟踪端口清除跟踪。如果配置为循环缓冲区
跟踪将被连续存储,因此最新的跟踪
将覆盖最旧的跟踪;或者,当缓冲区已满时,FIFO满标志
可用于停止跟踪,因此
会在特定时间点捕获到一条痕迹
。因此,我需要访问的不是ETB而是ETF,它是通过寄存器完成的(FIFO显然不是内存映射的?)

I clarified a little bit the situation thanks to a presentation from STMicro. It states that "The ETF can be used as a trace buffer for storing traces onchip. The trace can be read by software, or by the debugger, or flushed via the trace port. If configured as a circular buffer, the trace will be stored continuously, so the most recent trace will overwrite the oldest. Alternatively, the FIFO full flag can be used to stop a trace when the buffer is full, and hence capture a trace at a particular point in time." So what I need to access is not the ETB but the ETF, which is done through a register (the FIFO is apparently not memory mapped ?)

推荐答案

是的,CoreSight体系结构和ETM跟踪 旨在实现这种崩溃分析,尤其是在实时系统中,崩溃可能难以重现并且您可能无法拥有目标设备始终连接到外部调试捕获设备。 ETM跟踪可以是完全非侵入式的(除了使逻辑处于活动状态而产生的额外功耗成本之外)。

Yes, the CoreSight Architecture and ETM trace are designed to enable this sort of crash analysis, particularly in realtime systems where crashes can be difficult to reproduce and you may not able to have the target device hooked up to an external debug capture device all the time. ETM trace can be completely non-intrusive (except for the additional power consumption cost of having the logic active).

该体系结构非常通用,尽管每种实现方式都会有所不同关于执行什么的权衡。不幸的是,这意味着文档非常分散。您可能会发现技术概述非常有用

The architecture is quite generic, although each implementation will make different trade-offs about what is implemented. This unfortunately means that the documentation is quite spread-out. You might find this technical overview is useful for context (but not detail).

要实现崩溃分析,您需要执行以下步骤:

To achieve the crash analysis, you need to cover the following steps:


  1. 以循环缓冲模式配置ETF

  1. Configure ETF in circular buffer mode

配置ETM以相当频繁地跟踪所有内容

Configure ETM to trace everything, with fairly frequent synchronisation

在崩溃后禁用ETM(这样缓冲区不会被覆盖)

Disable the ETM after a crash (so the buffer is not overwritten)

从中提取跟踪崩溃(例如,到SD卡)

Extract the trace from the crash (to SD card, for example)

解压缩ETF添加的所有包装协议

Unpack any wrapping protocol added by the ETF

解压缩跟踪(可能是脱机)

Decompress the trace (presumably offline)

使用循环缓冲区,跟踪解压缩只能从同步点。 ETMv4协议使用可变长度的数据包,很少跟踪完整的PC地址值。您可能希望缓冲区中有4个同步点,然后仅丢失前25%。

With a circular buffer, trace decompression can only start from a synchronisation point. The ETMv4 protocol uses variable length packets, and rarely traces a full PC address value. You probably want 4 synchronisation points in the buffer, then only the first 25% is lost.

Trace解压缩依赖于正在运行的代码映像-这不应该

Trace decompression relies on having the code image which was running - this shouldn't be too much of a problem in this use case.

如果崩溃后缓冲的距离不够远,则可以在ETM中使用过滤逻辑排除您不感兴趣的任何代码。根据任何崩溃的性质,您可能需要计时信息。您可以将其设置为阈值,以便每100个周期左右在跟踪中得到一个滴答-跟踪精度可以节省成本,但这可能是一个很好的线索。

If you can't buffer far back enough after a crash, it is possible to use the filtering logic in the ETM to exclude any code you know is not interesting. Depending on the nature of any crash, you might want timing information. You can set this with a threshold to get a tick in the trace every 100 cycles or so - trace accuracy for cost, but it might be a great clue.

用于编程在ETM上,您需要 ETMv4体系结构(它使用DWT比较器作为处理器比较器输入 '(如果您需要过滤),对于ETF,我认为它将是技术参考手册。在外围设备ID寄存器中检查 part_number ,以确保您具有正确的程序员模型。

For programming the ETM, you want the ETMv4 architecture (it uses DWT comparators as 'processor comparator inputs' if you need filtering) and for the ETF I think it will be this technical reference manual. Check part_number in the Peripheral ID registers to make sure you have the right programmer's model.

这篇关于在STM32H7上使用执行跟踪片上缓冲器(ETB)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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