cancel
Showing results for 
Search instead for 
Did you mean: 

Debug protocols comparison and choice

Ricko
Associate III

Hi,

when it comes to programming and debugging, what is the difference between the 4 types (see screenshot below)?

Which one is best and how do you decide which one to use?

Please don't just say they all work the same pick one... 🙂 I am asking for the pros and cons of each and how to choose one with a precise logic.

- Serial Wire

- JTAG 4 pins

- JTAG 5 pins

- Trace Asynchronous Sw

 

Thank you 🙂

 

Ricko_0-1720395325957.png

 

9 REPLIES 9

If you need to ask, you want to go for Serial Wire (SWD), as the 99% of users do, and as is the cheap and out-of-the-box option on boards like Nucleo with software like CubeIDE.

To use JTAG of either form, you'd need some very good reason (e.g. you already have JTAG equipment you want to use, you want to perform boundary check - if you don't know what it is, you most probably don't need it), as it does not provide anything substantial beyond what SWD provides.

Trace is an extra feature, you'd need some appropriate (read: definitivaly not simple and not cheap) hardware and software, and a target with many pins (so that it does have the trace pins which are usually only on many-pins packages).

JW

 

Application note AN4989 "STM32 microcontroller debug toolbox" has many details.

Trace Asynchronous Sw is SWO tracing which is built-in in ST-LINK for cores that support it (M4 and better) and does not require additional tools and is quite useful. What @Jan Waclawek means, is synchronous tracing:

Screenshot 2024-07-08 135537.png

which I have never used.

hth

KnarfB

> What @Jan Waclawek means, is synchronous tracing:

I stand corrected, thanks.

So, the only cost to "trace asynchronous sw" is the SWO pin, is it?

JW

Yes, that's the hardware cost. Plus your SW investments into tracing (logging).  

Thank you @KnarfB and @waclawek.jan 

I have a Segger J-Link and am working on custom PCBs (not dev kits). Attached are both programming connectors and the signals connected to the micro.

Both PCBs have JTMS-SWDIO, JTCK-SWCLK and MCLR conencted tot he micro.

But one PCB also has the JTAG_SWO connected to the micro.

So I assume I can use SWD for both.

But what else can I use for the one PCB that also as the JTAG_SWO signal connected to the micro?

And what advantage or functionality does that extra connection provide (I assume possibly in debugging)?

Thank you 🙂

Ricko_0-1720450522703.png

Ricko_1-1720450581866.png

 

 

The SWO is like a extra serial connection, so you can send debug info (printf ( "main loop started. \n" )  ),

but you can get also interesting info like :

your serial msg:

AScha3_3-1720452452822.png

 

and same from some usb actions: (debug msg enabled)

AScha3_2-1720452300731.png

 

live chart from a value/variable :

AScha3_0-1720452107568.png

cpu use :

AScha3_1-1720452182746.png

AND important : without stopping the cpu in debug ! CPU just running, no changed timing (except the time, it needs to printf() , but this is then in your program, so always same timing, using it or not.)

If you feel a post has answered your question, please click "Accept as Solution".

@Ricko wrote:

But one PCB also has the JTAG_SWO (sic?) connected to the micro.


I think that's a misnomer?

SWO is not part of JTAG - it's an extension of SWD:

https://wiki.segger.com/SWO

ARM's documentation of JTAG/SWD:

https://developer.arm.com/documentation/101636/0100/Debug-and-Trace/JTAG-SWD-Interface

 

Your inability to look anything up, or query a search engine or ask ChatGPT seems prodigious..

SWO/TDO (PB3) is part of the JTAG complement, the ability to get the data back from the scan-chain, so boundary scan, daisy-chaining

One most, other than the CM0(+), it provides for the Serial Wire Viewer (SWV)

https://developer.arm.com/documentation/kan297/latest/

For proper Trace support you looking at pods running several $1000 USD, and more pins and a 20-pin header

The CM0(+) support SWD only, not JTAG, and frequently at lower speeds, typically a couple of MHz, not 10's. Use Event Recorder (EVR) methods rather than SWO/SWV

https://www.keil.com/download/files/swv_on_cortex-m3.pdf

https://www.keil.com/appnotes/files/apnt_321_v0.96.pdf

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Ricko
Associate III

Thank you all, much appreciated.