1703 views|1 replies

227

Posts

0

Resources
The OP
 

How to use SEGGER J-Trace Pro streaming mode to implement instruction tracing? [Copy link]

Intrusive and non-intrusive debugging

In the process of developing embedded applications, debugging is needed to solve problems that arise during program operation. Depending on whether the "full-speed running state" of the program will be interrupted, debugging methods can be divided into intrusive debugging and non-intrusive debugging.

The intrusive debugging methods are as follows:

Halt and single-step program execution

Hardware breakpoints and breakpoint instructions (BKPT)

Variable data observation point (Watch window)

Access register values

Debug monitor exception

Non-intrusive debugging methods are as follows:

Accessing memory while the kernel is running

Instruction tracing, which requires hardware to include an instruction trace unit (ETM)

Normally, we use intrusive debugging, but this debugging will break the full-speed running state of the program. Non-intrusive debugging can understand the running status of the program while ensuring that the program runs at full speed. When debugging large software and RTOS multi-tasking systems, or applications related to communication timing (non-intrusive debugging will break the communication timing), the application code may suddenly run away or generate abnormal interrupts, and the cause of the problem may be difficult to find.

At this time, non-intrusive debugging functions such as instruction tracing play an incomparable role. Instruction tracing can record the instruction execution history inside the MCU before the problem occurs. This information can help developers trace back to the problem site to accurately locate the cause of the problem.

How to implement instruction tracing

There are many ways to implement instruction tracing in embedded MCU debugging. By comparing them, we will be able to more clearly understand the power of Segger J-Trace Pro product flow mode instruction tracing function.

(1) Using MCU on-chip cache to implement instruction tracking

Some MCUs contain an instruction cache area. The cache area may be named differently depending on the chip model, such as Embedded Trace Buffer (ETB), Micro Trace Buffer (MTB), Embedded Trace FIFO (ETF), etc. Instruction trace records are saved in this on-chip area. When the program stops running, the PC debugging software reads the data in this area to obtain instruction trace data.

Limitations of using this method to implement instruction tracing:

The on-chip cache space is very small, usually only in the kilobyte range

Only very limited instruction execution history can be recorded

(2) Using the debugger internal cache for instruction tracing

Another way to implement instruction tracing is to provide instruction cache space inside the debugger. The cache space size may be in the MB to GB level. However, due to the hardware implementation cost of the debugger itself, the cache space that can be provided inside the debugger will not be very large.

This method has the following limitations for implementing instruction tracing:

On-chip cache space ranges from MB to GB

Can record limited instruction execution history, but cannot record the entire process from the start of application execution to the occurrence of an exception

Usually, the PC software will read the Trace data cached in the debugger after the application is paused.

Segger J-Trace Pro Stream Mode Instruction Tracing

The previous two implementation methods have their limitations due to the size of the cache space. The Segger J-Trace Pro product uses a stream mode to solve the problems of the previous two methods, and can provide developers with a mature instruction tracing solution. In addition to the SWD/JTAG debug interface pins, J-Trace Pro is connected to the chip through additional trace function pins, including Trace clock and data transmission pins. The instructions recorded in the ETM module inside the MCU are transmitted to the PC in real time through J-Trace Pro in a stream mode. At this time, the cache space of the instructions is on the PC side, so the maximum cache space can even reach TB level, which completely solves the limitations of the previous two implementation methods.

J-Trace Pro supports real-time transmission of instruction trace data to the computer through streaming mode. This solution also brings the following advantages:

The size of the instruction cache depends on the size of the computer hard disk (TB level)

Capable of recording the complete instruction process of the application from the start of execution to the occurrence of an exception

Capable of recording the execution of instructions during user interaction with the application

Other advanced debugging features provided:

Real-time code coverage analysis

Real-time code execution analysis

This article introduces several ways to implement instruction tracing and debugging functions during embedded MCU debugging. By comparison, it can be found that the solution of Segger J-Trace Pro product has obvious advantages. In addition, Segger also provides supporting debugging software Ozone, which can provide powerful instruction tracing and debugging functions.

This post is from Embedded System

Latest reply

The hardware is too expensive. The functionality is really powerful.   Details Published on 2022-9-9 20:08
Personal signature

欢迎关注“麦克泰技术”


7462

Posts

2

Resources
2
 

The hardware is too expensive. The functionality is really powerful.

This post is from Embedded System
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list