Differences Between SWD and JTAG Debug Interfaces

Follow+Star Public Account, don’t miss out on exciting content

Differences Between SWD and JTAG Debug Interfaces

Author | strongerHuang

WeChat Public Account | Embedded Column

As an embedded engineer, you should know about download debuggers, but do you really understand the meaning and differences of the SWD and JTAG interfaces?

Embedded Column

1

What is a Download Debugger

In simple terms, a download debugger is a device that converts commands sent from a PC (for example, via USB protocol) into a language (such as SWD or JTAG protocol) that the MCU (which is responsible for the MCU’s internal peripherals) can understand, loading code and precisely controlling execution.

Embedded Column

2

Debugger Protocol Standards
1. What is a Standard?
In simple terms, a standard is a set of rules and protocols that every participant in a specific industry agrees to follow and implement.

2. The Chaos of Debugger Protocols

Before protocols like SWD and JTAG emerged, debuggers and their protocols were in chaos, with each MCU manufacturer proposing their proprietary methods to load code onto their MCUs. Every time a manufacturer released an MCU, embedded software engineers had to understand their proprietary protocols to load code onto the microcontroller.
Moreover, debugging adapters were expensive because manufacturers had no competitors to match their protocols, as the protocols were proprietary. Another reason for their high cost was the lack of volume, as they could only sell the debugging adapters to companies (engineers) using the MCUs they manufactured.
Different protocols also increased development costs. For example, if you have four different chips from four different manufacturers on the board you are designing and wish to perform some automated tests to improve production efficiency, you will need to create a super complex production code that adapts to the complexity, and install four different debuggers at the test points on the board, thus increasing costs, production time, and programming time.
3. Establishing Protocols
The various download debugging differences can lead to several issues:
  • More time spent on learning

  • Increased costs for purchasing download debugging tools

  • Low efficiency in generating tests

To solve this issue, engineers from major MCU manufacturers and producers have established some standard protocols for debugging.

Embedded Column

3

JTAG Standard

JTAG: Joint Test Action Group, that is, the Joint Test Action Group.

This group began discussions in the late 1980s and officially released documentation interpreting the IEEE standard in 1990. (IEEE stands for the Institute of Electrical and Electronics Engineers, an international organization that publishes all standards, such as WiFi, Bluetooth, etc.). The protocol they proposed was documented in IEEE 1149.1 in 1990. The document has since been revised and improved, and as of this writing, the latest standard is IEEE 1149.7.

Differences Between SWD and JTAG Debug Interfaces

JTAG basically has 5 pins:
TDI: Test Data In. Serial input pin
TDO: Test Data Out. Serial output pin
TCK: Test Clock. Clock pin
TMS: Test Mode Select. Mode selection (control signal) pin
TRST: Test Reset. Reset pin

Embedded Column

4

SWD Standard

SWD: Serial Wire Debug, is a protocol designed by ARM for programming and debugging its microcontrollers.

Since SWD is specifically designed for programming and debugging, it has many special features that are often not available elsewhere, such as sending debugging information to a computer via IO lines. Additionally, because it is specifically manufactured by ARM for use in its devices, SWD’s performance is typically the best among its peers!

Differences Between SWD and JTAG Debug Interfaces

SWD Pins
SWDIO: Serial Wire Data Input Output. Serial data input/output pin
SWCLK: Serial Wire Clock. Serial wire clock pin

Embedded Column

5

Various Differences Between SWD and JTAG

There are many MCUs and debugging adapters on the market that are compatible with both SWD and JTAG protocols. They typically implement download and debugging functions through a set of download debugging pins that are internally multiplexed to the SWD and JTAG peripherals.

1.Shared Pins

The SWD pins can be multiplexed with the JTAG pins under certain conditions. Currently, there are many connectors for JTAG and SWD, such as the 20-pin connector:

Differences Between SWD and JTAG Debug Interfaces

Of course, there are also 10-pin ones:

Differences Between SWD and JTAG Debug Interfaces

2. Advantages of SWD / JTAG
Advantages of the SWD Protocol:
  • Uses fewer pins, requiring only SWDIO and SWCLK

  • SWD has special features, such as printing debugging information via its IO lines

  • SWD has better overall performance in speed compared to JTAG

Advantages of the JTAG Protocol:
  • JTAG is not limited to ARM chips; it also supports chips outside of ARM, such as the well-known MSP430

  • JTAG has more versatile applications for programming, debugging, and production testing

  • JTAG is an independent group that evolves with the development of the protocol

3. When to Choose SWD Over JTAG
  • If your schematic/circuit board design is simple enough to be tested without JTAG functionality

  • Debugging performance is more important than production testing; your device focuses on serving research rather than mass production!

  • If the MCU has size limitations, SWD can save space

  • If your hardware design is too complex, and the MCU has no extra two pins

Embedded Column

6

Summary: Comparison of SWD / JTAG

The following summarizes with a diagram:

Differences Between SWD and JTAG Debug Interfaces

———— END ————

Reply in the background with ‘Download Programming Tools’ or ‘Communication Interface’ to read more related articles.

Follow the WeChat public account ‘Embedded Column’, reply ‘Join Group’ to join the technical exchange group following the rules, reply ‘1024’ to see more content.
Welcome to follow my video account:

Differences Between SWD and JTAG Debug Interfaces

Click ‘Read Original’ to see more shares, and feel free to share, bookmark, like, and view.

Leave a Comment