The standard JTAG connector for ARM processors is the huge 20 pin IDC header. It has a whole bunch of unused pins and takes up a lot of board space. There are a several alternatives that reduce the pin count but, for a bare minimum, you can use Serial Wire Debug (SWD)…

It is often stated that SWD needs only two wires to connect to the processor but that overlooks the need for a common ground. Actual implementations are also likely to want a power connection to drive level converters or to tell the programming/debug hardware that the device is present and powered up. Then there is the reset line. While not strictly needed, your debug hardware and software may need to be able to reset the processor to overcome issues caused by reassigning the SWD pins in your target code. If you don’t need the reset though, you can easily manage just 4 pins to the target.

My current development tools are the Rowley Crossworks for ARM suite. I run that on a mac so all the following is predicated upon use of a OSX and I have no idea how it all behaves under Windows. Just lately, Rowley added support for the STLINK/V2 programmer. You can buy these quite readily but don’t get the earlier STLINK. It will work fine with other tools but not Crossworks on a mac. The STLINK/V2 is probably one of the cheapest debugger/programmers available – it can be had from Farnell for about £34. It is small and neat and connects to the PC using a common mini-USB lead. Best of all, for the Mac, it needs no drivers. Crossworks sees it automatically. All you need to remember is to set it up to use SWD rather than JTAG. As an extra benefit, the new STM32F4Discovery has an STLINK/V2 built in which can aso be used as a slightly less elegant stand-alone debugger/programmer for other targets.

The connector provided on the STLINK/V2 for STM32 targets is the standard 20-pin header so you will need to make an adaptor to bring out just the SWD signals to your target. The minimum requirement is four wires and it is quite easy to use four separate wires into a standard IDC connector directly. Be sure to use suitable wires for this – they need an outside diameter of no more than 1mm if you are to avoid accidentally connecting to the pins either side. On the target board side, use whatever is convenient.

STLINK/V2 four wire SWD connection for STM32

For my breadboarded test rig, I used a four pin Harwin M20 connector. Even on a half size micromouse, this will not take up much room and I may use it as the only debug/programming connector.

The pins on the 20-pin standard JTAG connector to use are:

Pin 1 – VCC:
This is the traget board Vcc. It is used by the STLINK/V2
Pin 7 – TMS/SWDIO:
The SWD Data signal
Pin 8 – GND:
Be sure there is a common ground
The SWD Clock Signal
Pin 15 – nSRST/RESET
System reset – probably optional

 You can find out more about JTAG/SWD connectors here:

Incoming search terms:

  • stm32 swd (95)
  • SWD stm32 (83)
  • stlink swd (81)
  • swd connector (52)
  • stlink (46)
  • stm32 swd pinout (46)
  • stm32 swd connector (27)
  • swd connector stm32 (24)
  • crossworks stlink v2 swd (22)
  • st link v2 pinout (22)
This entry was posted in STM32 and tagged , . Bookmark the permalink.

11 Responses to STLINK SWD for STM32

  1. digital_dreamer says:

    Thanks for all this great info on the STM32F4! Just got my Discovery board and, like you, am on a Mac, so this info is very helpful.

    Given that there is a embedded STLINK/V2 on the STM32F4Discovery card, I’m a bit disappointed that there is no way to use it with via USB port connected to a Mac, but must use a debugger/programmer adapter.

    I’m new at this stuff and find the STLINK/V2 issue a little confusing. When some use this term, I immediately think of the external adapter. But, this board has the STLINK/V2 tool embedded, so I’m left with wondering a bit.

    Looking at your previous article (…taste of speed), when you said Crossworks will support the STLINK/V2, I’m assuming you mean via external STLINK/V2 debugger/programmer, as mentioned here in this article. Crossworks will not support the embedded STLINK/V2 tool via USB on the Mac (like it does in WIN), correct? Or, am I a bit confused with how this interface is being used?

    I’m a newbie just venturing into MCUs, but used to program in assembly on 8-bit micros (Z-80, 6502, 6809, etc.) some 25 years ago.

    best of wishes,

  2. Peter Harrison says:

    Perhaps I was not clear. the STM32F4 Discovery board has a built-in STLINK/V2. Crossworks on the mac can use that either to program the processor on the discovery board or as a programmer for external target boards. I also purchased a stand-alone STLINK/V2 and can use that as a general- programmer, both for the discovery board and other SRM32 targets. And, I presume, other ARM targets but I don’t have any.

    Does that help?

  3. digital_dreamer says:

    Yes, that’s perfectly clear now and certainly helps! The confusion was on my part. :-)

    Best of wishes and thanks for your contributions.

  4. Rodrigo says:

    Hi, great site, you help a lot with STM32 informations. I bought a ST-LINK/V2 and use CrossWorks ( on Mac OS Lion. How you set it up to working with this programmer?


  5. Peter Harrison says:

    To use the SWD and ST-LINK/V2 with Crossworks, you need only select it in the target device list and then, in the target properties window, change the Target Interface Type to SWD.

    On a Mac, this just works. It may need additional work on Windows or Linux though. I run neither here I am afraid.

  6. Sumankumar says:

    Hi all,

    Could you pls any one help me on this.

    I am using one STM32217xx in one of the product. i am making one fixture for the flashing the firmware to the PCBA. Can this STLINK SWD for STM32 can be used as unviersal flash programmer for flashing the firmware to the controller


  7. Hi,

    really useful info!

    Do you know the connectors part numbers or references?

    Thank you.

  8. Peter Harrison says:

    The IDC connector is a common, standard part. For the programming header, I used Harwin M20 shells

  9. fabrice says:


    I have some difficulties with the STLINK V2. I used a J-Link to program/debug my STM32F205 and it works well. I just bought a ST LINK V2. First I used my cable from J-LINK to program, so it seems to program (I got the progress bar) but in fact, it still be the old program in my µc. So I just made your cable, and the same, it programs well, but in fact it still be the old program.
    Have you some ideas or settings to do ?

    Thank you

  10. Peter Harrison says:

    Have you made sure that the programmer is set into SWD mode?

  11. fabrice says:


    Thank you for your reply. Yes, the programmer is set in SWD mode, I have checked.

Leave a Reply