How is a JTAG used as a debugger?

tinkerbeast picture tinkerbeast · Jan 16, 2014 · Viewed 18.7k times · Source

I understand how JTAG used to be used as boundary scanner (very clean explanation at http://www.fpga4fun.com/JTAG1.html). However I can't see how JTAG these days is used as a hardware level debugger (Somewhat similar to in-circuit emulators).

1. Can some-one explain how JTAG is used as a hardware level debugger?

My assumption is there has to be some extra hardware on-chip which helps in debugging while JTAG merely drives that hardware to get the debug information. If my understanding is correct -

2a. What is that hardware?

2b. Is there a standard for it?

I rather doubt the standard part since all implementations I've seen of JTAG based hardware level debuggers vary from each other.

Finally it's really confusing to have JTAG be called a hardware level debugger whereas the JTAG standard doesn't define anything of the sort. So is there a different name for when JTAG is used for this?

Answer

Martin Thompson picture Martin Thompson · Jan 17, 2014

JTAG is simply a method for interfacing to the chips internals which works alongside the "usual" chip functionality. It's basically a multi-mode (synchronous) serial port.

One of the things this allows is boundary-scan, by accessing the pins directly.

As you surmise, another is to access extra hardware inside the chip. That hardware can be set up to provide (for example) hardware breakpoints, the ability to read registers and arbitrary memory locations, programming internal flash etc. Those are the sorts of things that a debugger application can use.

The JTAG standard provides space for device specific extensions which were always intended for the chip designers to use to provide these sorts of features. There is an attempt to standardise the interface, which covers JTAG and also higher-rate connections to debug hardware, which is called Nexus. However, I've only ever seen Freescale implement it, so it appears to not be as useful a standard as one might hope!

Regarding the terminology, yes, it is probably wrong to call "a JTAG" on its own a hardware debugger. I'm not entirely sure what "a JTAG" is (as used in the question title) - maybe "a JTAG pod" or "a JTAG interface module" would be better?

However phrases like "JTAG debug access" or even "JTAG debugger" (and indeed "JTAG programmer" for those users who are just using it to program the flash) are in common usage (in the UK at least!) and seem to me to be non-confusing, combining as they do the method of interface and the function provided.