Today, many Cortex-M processors can be debugged so conveniently due to the CoreSight technology based on Arm Cortex-M processor devices, which introduces powerful new debug and trace functionalities.
Let us focus on the debugging and tracing related content in CoreSight.
strongerHuang
1
The two main functions of CoreSight are debugging and tracing.
1. Debugging Function
-
Control the running processor, allowing to start and stop programs -
Step through source code and assembly code -
Set breakpoints while the processor is running -
Instantly read/write memory contents and peripheral registers -
Program internal and external FLASH memory
2. Tracing Function
-
The Serial Wire Viewer (SWV) provides program counter (PC) sampling, data tracing, event tracing, and instrumentation tracing information
-
Instruction (ETM) tracing streams directly to your PC, enabling historical sequence debugging, software performance analysis, and code coverage analysis
strongerHuang
2
JTAG is the industry-standard interface used to download and debug programs on target processors and many other functions. It provides an easy way to connect devices and is available on all Arm-based processor devices. The JTAG interface can be used with Cortex-M based devices to access CoreSight debugging functionalities.
1. JTAG History
JTAG stands for Joint Test Action Group, which is a commonly used name for the IEEE standard 1149.1, known as the Standard Test Access Port and Boundary Scan Architecture. This standard is used to verify the functionality of printed circuit boards produced by design and testing.
In 1990, JTAG was officially standardized by IEEE document 1149.1-1990, and in 1994, a supplementary document was added to clarify the Boundary Scan Description Language (BSDL). Since then, this standard has been widely adopted by electronics companies worldwide, and boundary scan has almost become synonymous with JTAG.
— Quote from Wikipedia
2. JTAG Interface
The JTAG interface typically consists of 4/5 pins connected to the chip:
-
TDI (Test Data Input)
-
TDO (Test Data Output)
-
TCK (Test Clock)
-
TMS (Test Mode Select)
-
TRST (Test Reset) optional
strongerHuang
3
SWD, Serial Wire Debug mode is an alternative to the standard JTAG interface that provides the same debugging functions with only two pins without compromising performance, and introduces data tracing functionality through the Serial Wire Viewer (SWV).
The SWD interface pins are included in the JTAG pins, allowing the use of standard target connectors. The pins include:
-
TCLK-SWCLK (Serial Clock)
-
TMS-SWDIO (Serial Data Input/Output)
-
TDO-SWO (Serial Wire Output – used by SWV)
About SWV
SWV: Serial Wire Viewer
-
PC (Program Counter) sampling
-
Event counters displaying CPU cycle statistics
-
Exception and interrupt execution with timing statistics
-
Trace data – data reads and writes for timing analysis
-
ITM trace information for simple printf-style debugging
strongerHuang
4
I previously shared “Differences between SWD and JTAG Download Debug Interfaces“; when choosing a download debugger, you can also compare the differences between the two.
Many download debuggers support both JTAG and SWD modes, such as J-Link, ST-LINK, and ULINK, and there are many niche download debuggers (like e-Link, GD-Link, etc.) that also support SWD mode.
So, which one should we choose? Which one is better?
J-Link is comprehensive, but its price for genuine products can be a burden for ordinary individuals.There are multiple versions, which can add up to several thousand.
Similarly, genuine ULINK costs over a thousand, just like J-Link. Of course, many people end up buying counterfeit ULINK and J-Link products.
Compared to ULINK and J-Link, the genuine ST-Link is reasonably priced, with a genuine ST-Link V2 costing only two to three hundred, but the downside is that it can only be used for STM8/32.
Of course, ST-Link also has a unique trick: turning into J-Link; refer to my article “How to Turn ST-Link into J-Link: A Step-by-Step Guide” for implementation.
1.Interpreting Yao Qizhi’s Latest Speech on AI Development!
2.Discussing the Design Ideas of RT-Thread Kernel Object Manager~
3.【C Advanced】 The three most common yet least used preprocessor directives
4.The Alumni Association of Beihang University Integrated Circuit Industry Association is established!
5.How to write code that makes the CPU run faster?
6.What happens from process creation to entering the main function?
Disclaimer: This article is a network reprint, and the copyright belongs to the original author. If there are copyright issues regarding the works, please contact us, and we will confirm the copyright based on the copyright certificate you provide and pay the manuscript fee or delete the content.