JTAG vs SWD debugging

Electrically

  • Pin Count
    • JTAG requires 4 signal lines
    • SWD only requires 2 signal lines
    • 2-wire JTAG interface specified in IEEE 1149.7 drops the pin count but doesn't seem to be widely available on many ICs. It also reduces bandwidth.
  • Topology
    • JTAG uses a daisy chain configuration for its data lines between chips. JTAG's speed is thus limited by the slowest chip on the chain. Its reset and clear lines are bused (not chained) however which allows for interoperability via SWDJ-DP (see discussion below).
    • 2-wire JTAG allows for a star topology, but it is not used often.
    • SWD allows for star topologies

Functionally

  • SWD is an ARM specific protocol designed specifically for micro debugging.
  • JTAG (Joint Test Action Group) was designed largely for chip and board testing. It is used for boundary scans, checking faults in chips/boards in production. Debugging and flashing micros was an evolution in its application over time.
  • JTAG is in use for multiple microcontroller/processor architectures aside from ARM.

General Discussion

JTAG is more widely supported, as of 2017, by non-ARM micros, programmers and production lines. Programmers for JTAG can be had for cheap in the form of FT232H[*] breakouts and other such programming devices. However, SWD has a distinct advantage in speed and other areas in debugging ARM chips.

Due to the split in the purposed nature of JTAG in testing and SWD in debugging, ARM provides SWJ-DP (serial wire/jtag debug port) via its CoreSight technology which maps SWD pins onto JTAG's clock and reset lines. SWJ-DP therefore allows using both protocols on the same physical connection though not necessarily at the same time or with the same programmers as JTAG and SWD would have to be multiplexed in time.

Useful References

  • Low Pin-count Debug Interfaces for Multi-Device Systems - ARM whitepaper and great source of information on the differences between the two protocols (though focused on the advantages of SWD)
  • Wikpedia: JTAG
  • SWJ-DP Reference
  • ARM CoreSight Whitepaper - good introduction to ARM's CoreSight debug technology used in ARMv6 architectures and up.

SWD should be able to program the ARM chipset plus you can debug and add breakpoints. The other good thing about SWD is you can use the serial wire viewer for your printf statements for debugging. I have only used it with the Keil compiler.


Old question, but none of the answers address the performance comparison. Although the feature set between SWD and JTAG (when using a CoreSight DAP) are near enough the same, SWD sequences are roughly 10% shorter than the equivalent JTAG sequences.

There is no loss in data bandwidth in most cases (particularly streaming reads or writes where bandwidth is most important).