AnsweredAssumed Answered

ST-LINK, SWD, JTAG <- Which To Use Where?

Question asked by ro.dru on May 9, 2014
Latest reply on May 12, 2014 by sung.chen_chung
Using the disco boards for the STM32 they come with a built in ST-LINK/V2 on them and so when programming / debugging I have not had to give much thought to the details on this connection.

Can someone clarify what each of these do?  I ended up going down the rabbit hole and now I have 30 pages open from google searching and there is nothing that clearly outlines the programming/debugging questions that I can see.

This is what I think I know:

- There is Jtag 10 pin and 20 pin.  The 10 pin is newer and uses less pins.
- There is SWD which is equivalent from a protocol standpoint but uses 2 (or 3 including GND?) pins instead.  This is the ST-LINK/V2

So if after using the disco boards I have a prototype I want to create and I start drafting up the schematic what do I do about the programming/debugging of this?  From what I read there is a third option of using a serial port and a bootloader?  The ST-LINK/V2 comes shipped on the disco boards so if you buy an external hardware ST-LINK/V2 is there a header from the STM32 for the SWD/STLINK interface and another header for the JTAG interface?

I thought in the past I read a page that outlined nicely what each of these were and how/where you would use each one.  As well there were links to different programmers and what they were compatible with.  I cannot find this page again after searching through my bookmarks and scouring google.

I would just like to understand the different options, how they connect / when you would use them and any extra hardware needed for any of them.

One thing that seems confusing is that in the VisualGDB tutorial they show using STLINK for programming AND OpenOCD for debugging.  Does this mean that you would need both a STLINK /V2 connected to the SWD and a JTAG device to the JTAG 10 pin port?

Then I find JTAG devices but for example they will be from IAR, so does that mean it will not work when trying to use VisualGDB?

I thought JTAG was a standard and if I got a JTAG programmer, no matter who makes it, that I would be able to use it with anything that has a JTAG port.  So if I got a JTAG programmer and it worked with IAR/VisualGDB/Cosmic etc compilers and then I wanted to program a Xilinx FPGA would I be able to use the same JTAG hardware?

Also there was a JTAG device that was popular and in-expensive but I cannot find this link again either.  I thought there was a table on the page where you could get a cheaper version that was somewhat limited and it compared it to more featured more expensive versions.  Anyone know which one this might be?

I read in one forum that the person no longer uses anything other than SWD for the past few years and it has been working fine.  There was no mention on what was used to connect (would it be the stand-alone hardware version of the STLINK/V2?) 

Can someone please offer some clarification on this whole mess of protocols/devices/manufacturers/ports?  I am pretty sure from what I read that I can either hang the SWD or JTAG connector off of my board and I will be able to program using an external piece of hardware or have a bootloader and use a serial port to allow this as well.  (BTW what software would you use in each case, or is it the same?)