ST-LINK V2 Pinout and STM32 SWD Wiring Guide: Blue Pill, Black Pill and 20-Pin Connector (2026)

ST-LINK V2 pinout and SWD wiring for STM32 Blue Pill and Black Pill. Verified genuine 20-pin CN3 pins, clone warnings, power, reset and flashing fixes.

Quick answer: You need SWDIO, SWCLK and GND to connect an STM32 to a compatible ST-LINK programmerAliExpress price, plus a correctly powered target and, where required, a target-voltage reference (VTref/VAPP). Connecting NRST is strongly recommended for recovery and Connect Under Reset. On the STM32F103C8AliExpress price Blue PillAliExpress price, SWDIO is PA13 and SWCLK is PA14. For a genuine ST-LINK/V2 with ST’s 20-pin CN3 connector, the key pins are 7 = SWDIO, 9 = SWCLK, 15 = NRST, 1 = VAPP/target-voltage reference, and one or more of the documented ground pins. Those 20-pin numbers do not apply to unbranded 4-, 6- or 10-pin USB dongles.

If your programmer is the familiar inexpensive metal-cased USB ST-LINK/V2 clone, do not blindly copy a random internet pinout. Identically styled dongles may have different internal boards, swapped header orientations, different 3.3 V outputs or missing reset connections. Identify the exact probe, inspect its markings and measure power rails before connecting anything. This guide distinguishes verified connector standards from unverified clone layouts and shows the safe signal-level wiring method.

SWD—Serial Wire Debug—is the normal way to program and debug STM32 chips without using an application USB bootloader. It works with an STM32 Blue Pill, Black Pill, custom PCB and many STM32 Nucleo targets, although the latter normally include their own ST-LINK. It is also the easiest way to recover a board from badly configured firmware when its debug pins and reset remain accessible.

ST-LINK V2 debugger, STM32 Blue Pill and Black Pill boards on an electronics bench
SWD connects an ST-LINK probe to an STM32 through SWDIO, SWCLK, ground and a suitable voltage reference.

ST-LINK V2 pinout: the essential connections

SignalMeaningSTM32 target connectionMandatory?
SWDIOBidirectional debug dataMCU’s SWDIO pin, often PA13 on F1/F4Yes
SWCLKDebug clock supplied by probeMCU’s SWCLK pin, often PA14 on F1/F4Yes
GNDShared referenceTarget groundYes
VTref / VAPPSenses the target’s I/O supply levelTarget VDD / 3.3 V logic rail where probe requires itProbe-dependent, normally connect for a genuine ST-LINK
NRSTActive-low target resetMCU NRSTOptional for ordinary access; highly recommended
SWO / TRACESWOOne-way trace outputMCU trace pin if supported and enabledOptional, not needed to flash

The table describes electrical signal names, not the physical order of an unknown clone’s pins. Establish each signal on your specific probe before wiring. A 4-wire dongle marked SWDIO / SWCLK / GND / 3.3V may power a small target from its 3.3 V output; a genuine 20-pin probe instead exposes a target-voltage sense/reference signal. Treat these as different electrical functions.

Critical distinction: A probe’s target-voltage input is not automatically a target-power output. Do not connect two power sources together merely because both are marked 3.3V, and never feed 5 V into an STM32 board’s 3V3/VDD input. A board’s separately labelled 5V/VIN input, when present, is a different connector with an onboard regulator and must be assessed from that board’s schematic.

Which ST-LINK device and connector do you have?

There are several products commonly called “ST-LINK V2”, but their connectors are not interchangeable.

HardwareTypical debug connectionPractical implications
Genuine standalone ST-LINK/V2Standard 2×10, 2.54 mm JTAG/SWD ribbon connectorOfficial CN3 pin numbers are documented in UM1075
Genuine ST-LINK/V2-ISOLSimilar 20-pin interface with isolationSome pins and ground arrangements differ from the non-isolated V2; follow UM1075 Table 5
Low-cost USB ST-LINK/V2 cloneOften 4, 6 or 10 pins, sometimes a dual-row headerNo universal clone pin numbering; labels, silkscreen and actual voltage must be checked
Nucleo embedded ST-LINK/V2-1 / V2-B / V3EDebugger already connected to onboard STM32Usually no external probe required for the Nucleo itself; external-target access varies by board
STLINK-V3SET / V3MINIE / V3PWRNewer ST-LINK family; model-specific connectorsUse the documentation for that particular V3 model, not the V2 20-pin map
10-pin Cortex Debug connector2×5, 1.27 mm Arm/CoreSight standardStandardized pin assignment, but different from the old 20-pin connector

ST’s technical note TN1235, Overview of ST-LINK derivatives explains why the names are so confusing. A V2-era interface integrated into a Nucleo board is not automatically the same product as the standalone probe, and a low-cost clone’s USB shell gives no reliable indication of its header mapping. For a beginner buying hardware today, an authentic recent STLINK-V3 model or a Nucleo with integrated debug is generally a more dependable choice than an unknown clone.

Genuine ST-LINK V2 20-pin connector, standard 10-pin Cortex Debug connector and non-standard clone headers compared
ST-LINK connector styles are not interchangeable; match the exact probe before following any numeric pinout.

Genuine ST-LINK/V2 CN3 20-pin JTAG/SWD connector: verified pinout

The following entries are taken from STMicroelectronics UM1075 Revision 10 (April 2024), Table 4 and apply to the genuine, non-isolated standalone ST-LINK/V2 CN3. They are not a universal pinout for every 20-pin adapter or for the ST-LINK/V2-ISOL variant.

CN3 pinST designationUse when programming an STM32 over SWD
1VAPPConnect to the target’s VDD reference. This is not a 3.3 V power output.
3TRSTIn ST’s SWD cable map, connect to GND for noise reduction.
4GNDGround; at least one proper ground connection is required.
5TDIIn ST’s SWD cable map, connect to GND for noise reduction.
6, 8, 10, 12, 14, 16, 18, 20GNDAdditional signal-return/ground pins; follow official ribbon wiring.
7TMS_SWDIOConnect to target SWDIO.
9TCK_SWCLKConnect to target SWCLK.
13TDO_SWOOptional target TRACESWO/SWO trace output.
15NRSTConnect to target NRST, especially for recovery.
19VDD (3.3 V)ST documents a 3.3 V pin but does not designate it as a target SWD connection; do not use as a generic board-power instruction.
2, 11, 17Not connectedLeave unconnected.

With the official 2×10 ribbon, connector orientation matters: the red stripe normally marks conductor 1, but the keyed notch, triangle, PCB marking and manufacturer drawing determine the true orientation. Do not rotate an IDC plug to make its pins appear to match a photograph. In the official top view of the target connector, odd-numbered pins form one row and even-numbered pins the other.

Do not confuse pin 1 and pin 19. Pin 1 is VAPP, a target-supplied level reference; ST lists pin 19 as its own 3.3 V line and explicitly leaves the corresponding SWD target-connection entry blank. The safe general configuration is to power the target through its intended regulated input, connect VAPP to the appropriate target I/O supply, and use SWDIO/SWCLK/ground/NRST as specified. For isolated ST-LINK/V2-ISOL hardware, consult Table 5, including its different pin functions and isolated-ground arrangement.

Official reference: ST UM1075 — ST-LINK/V2 in-circuit debugger/programmer.

ST-LINK V2 genuine CN3 20-pin JTAG SWD connector pin 1 VAPP, 7 SWDIO, 9 SWCLK, 15 NRST, 13 SWO and ground pins
ST UM1075 Table 4 defines the genuine non-isolated ST-LINK/V2 CN3 20-pin JTAG/SWD pinout; clone headers differ.

The smaller standard 10-pin Arm Cortex Debug connector is different

Some modern probes and custom STM32 PCBs use a standardized 10-pin, 1.27 mm pitch Cortex Debug connector. This is not a smaller version of the genuine ST-LINK/V2’s older 20-pin 2.54 mm JTAG header. The widely used Cortex Debug layout is:

Cortex Debug pinFunctionNote
1VTref/VCC referenceConnect to target logic voltage according to probe specification
2SWDIO / TMSDebug data
3GNDCommon ground
4SWCLK / TCKDebug clock
5GNDCommon ground
6SWO / TDOOptional trace
7KEYPolarization/key position, normally no physical pin
8TDI / unused for SWDNormally not required for two-wire SWD
9GND / GNDDetectTarget ground/detection
10nRESETOptional reset

This assignment follows Arm’s Cortex-M Debug Connectors reference. Only apply this map if the connector actually follows that standard. Cheap “10-pin ST-LINK V2” USB dongles sometimes use a proprietary 2.54 mm header. Counted pins alone cannot tell you the electrical layout, and connector view direction (looking into the plug versus looking onto the PCB header) can mirror a pictorial layout.

STM32F103C8 Blue Pill to ST-LINK: connection by signal name

A typical STM32F103C8T6 Blue Pill is powered at 3.3 V internally and exposes the Arm debug functions on fixed MCU signals. The actual header layout depends on board artwork and revision; this wiring table therefore uses signal names, not a guessed location on a photo.

From your identified ST-LINK signalConnect to Blue PillWhy
SWDIOPA13 / SWDIOTwo-way debug commands and data
SWCLKPA14 / SWCLKDebug clock
GNDGNDCommon electrical reference
VTref / VAPP input, when present3V3 target railTarget I/O voltage sensing, not powering
NRSTNRST / RSTHardware reset / Connect Under Reset
SWO, if neededPB3 / TRACESWO where pin is accessible/configuredOptional trace only

The PA13, PA14 and PB3 debug signal assignments are documented in ST’s STM32F1 reference manuals. Keep PA13 and PA14 reserved for SWD in CubeMX/firmware. You can sometimes reclaim them for GPIO in a finished product, but doing so complicates field debugging and recovery.

A safe five-step wiring sequence

  1. Disconnect all USB and external power before moving wires. Inspect the board for shorts, damaged pads and an unknown power jumper.
  2. Identify the ST-LINK signals from its own printed board revision/manual, not a generic clone infographic. If the probe has unlabeled pins, do not energize it until the mapping can be established safely.
  3. Provide the target’s intended regulated supply. For a typical Blue Pill used through its 3V3 rail, provide 3.3 V. If powering a specific board through its USB connector, check that board’s regulator and avoid conflicting supplies.
  4. Connect GND, SWDIO, SWCLK and target voltage reference as required, then connect NRST for recovery. Keep the leads short and avoid loose breadboard connections.
  5. Measure the target 3.3 V rail with a meter and then plug the probe into the PC. Confirm software recognition and target detection before flashing.
STM32F103C8 Blue Pill ST-LINK SWD signal wiring PA13 SWDIO, PA14 SWCLK, GND, NRST and target voltage reference
Connect SWD signals by name and power the Blue Pill correctly; the ST-LINK reference input is not automatically a power source.

Keep BOOT0 = 0 for a normal flash-boot application. SWD programming does not require BOOT0 = 1, unlike a UART system-memory bootloader procedure. If damaged application firmware quickly disables SWD, reset-based attachment or the bootloader state can sometimes help restore access; changing BOOT0 is not part of routine SWD flashing.

You can cross-check the board headers with our STM32F103C8T6 Blue Pill pinout reference and the broader STM32 beginner guide.

Wiring a Black Pill (STM32F401 or STM32F411)

The common STM32F401/F411 Black Pill boards also expose their ARM SWD debugging signals on PA13 (SWDIO) and PA14 (SWCLK), plus GND, 3.3 V supply and reset. Their header arrangement differs from the Blue Pill and may vary between manufacturers. Before applying the Blue Pill-style physical wiring, consult the precise Black Pill revision and manufacturer pinout.

The target-voltage warning is unchanged: the MCU GPIO core is 3.3 V logic, but some board versions have separate USB, 5 V or VIN inputs served by regulators. A label marked 5V on a breakout is not interchangeable with its 3V3 rail. Connecting an ST-LINK to the MCU SWD pins does not turn the probe’s USB connection into the STM32’s own USB DFU connector.

Unlike the STM32F103, common STM32F401/F411 parts have different peripheral sets and boot ROM capabilities; these differences do not alter the two core SWD signals, but can alter the correct reset, protection and recovery procedure. Our Blue Pill versus Black Pill comparison covers the board selection trade-offs.

Target voltage, power outputs, and why VTref causes so many failures

There are three separate questions whenever you connect the ST-LINK to an STM32:

  • Who powers the target MCU? A stable, suitable power source connected to its intended input or regulated rail.
  • How does the probe learn the target’s voltage? A reference/VTref/VAPP signal when its hardware requires one.
  • How are digital signals referenced? A shared GND for a non-isolated setup, with appropriate ground paths and logic compatibility.

ST specifies that the genuine V2 VAPP pin 1 connects to the target’s own VDD so the probe can match signal levels. This means the MCU must already receive correct power; VAPP is not an invitation to feed current from the debugger to the board. Some USB clones also have a physical 3.3 V power-output pin. Its available current, protection and relationship to the target reference are product-specific. Do not join that output to a separately powered 3.3 V rail unless you have verified the design and power path.

A meter is far more valuable than a speculative color-coded jumper diagram. With target power applied and probe ground referenced correctly, check for an expected stable supply, not a barely glowing power LED. Brownouts, voltage drops through poor USB cables, reversed power rails and two competing regulators can all prevent SWD from working.

For ST-LINK/V2-ISOL, grounding and power relationships differ because the debugger-to-target interface is isolated. Follow its isolation-specific documentation; do not assume it can be treated as the non-isolated V2 or linked indiscriminately to the PC’s USB ground.

First connection using STM32CubeProgrammer

Install the current STM32CubeProgrammer from ST and connect your ST-LINK to a PC with a known data-capable USB cable. ST’s application supports ST-LINK debugging interfaces and can report the connected probe and target separately.

  1. Open STM32CubeProgrammer and choose the ST-LINK connection interface.
  2. Set Port = SWD, not JTAG, for the three-wire debug configuration described here.
  3. Start conservatively at 100–400 kHz if you are troubleshooting a clone, long wires or unusual target clock state. With good wiring, increase speed later.
  4. Choose Mode = Normal for a typical first connection, then select Connect.
  5. Check that the ST-LINK probe itself is recognized. That alone does not prove the MCU is detected.
  6. After a successful target connection, inspect the reported device information and target voltage (where exposed). Avoid relying on a fabricated “device ID” from an online tutorial.
  7. Open your firmware file. For a typical STM32F103 application, a raw .bin at the beginning of main flash uses 0x08000000. An .elf or .hex normally contains its own load-address information.
  8. Program and verify. Disconnect or reset and confirm your expected application behavior.

For the STM32F103C8, respect the part’s documented flash size. A C8-labelled board must not automatically be treated as a 128 KB part because a particular clone once happened to contain additional accessible flash.

STM32CubeProgrammer command-line example

A reproducible initial probe connection can use ST’s CLI:

STM32_Programmer_CLI -c port=SWD freq=400 mode=NORMAL

For a raw binary intended for the start of internal flash:

STM32_Programmer_CLI -c port=SWD freq=400 mode=NORMAL \
  -d firmware.bin 0x08000000 -v

On Windows you may need the full path to STM32_Programmer_CLI.exe, and command continuation syntax differs between Windows shells and Bash. The 0x08000000 address is not universal; it is a common internal-flash base on the F103 and many STM32 families, but use the exact memory map, linker script and target part for your firmware.

These commands use the options documented by ST’s STM32CubeProgrammer 2.23 command-line manual. Do not erase or remove readout protection on an unfamiliar board without a backup: such operations may permanently delete its existing firmware.

Connect Under Reset: recovering an STM32 that no longer answers

A common failure occurs after firmware reconfigures PA13/PA14 as GPIO, enters an aggressive low-power mode or quickly crashes. The ST-LINK can appear in Windows or Linux, but CubeProgrammer reports “No STM32 target found”, “Cannot connect to target” or similar messages.

Connect Under Reset asks the probe to assert the MCU’s physical NRST pin and establish a debug connection as reset is released. This is different from an ordinary software-reset mode. It is useful when application code runs so quickly that it disables the debugger before a normal connection completes.

To try it, attach ST-LINK NRST to STM32 NRST in addition to SWDIO, SWCLK and GND, verify power and VTref, choose a low SWD clock and select Mode = Under Reset in CubeProgrammer. A representative CLI connection is:

STM32_Programmer_CLI -c port=SWD freq=100 mode=UR reset=HWrst

ST specifies that hardware reset requires the physical reset line; you cannot expect software to toggle a wire that is not connected. If the probe cannot pull the target NRST correctly, the under-reset strategy may fail even when basic SWD works. If firmware access is ultimately recovered, rewrite the debug GPIO configuration before restoring the application.

Do not confuse loss of debug access with active readout protection. RDP levels, option bytes and irreversible protection mechanisms vary by chip. Returning an RDP-protected device to an unlocked state can mass-erase its flash, and some protection states are irreversible. Never advise a user to “remove protection” merely to silence a connection error.

SWD, JTAG, SWO and UART: what each wire actually does

Interface or signalPurposeDoes it flash an STM32?Key consideration
SWDIO + SWCLKTwo-signal Cortex debug portYes, via an ST-LINK debuggerNormal preferred STM32 debug/programming method
JTAGMulti-wire debug/test portYes, on supported boards/chipsMore debug pins and a different wiring mode
SWOOne-way instrumentation/trace outputNo, not by itselfOptional trace; PB3 on STM32F103
NRSTPhysical MCU system resetNo, not by itselfImproves probe attachment and under-reset recovery
UART ROM bootloaderFactory system-memory upload protocolYes, when supported and correctly bootedUses UART TX/RX and boot selection, not SWD
Native USB DFUFactory USB bootloader on selected MCUsOnly if exact MCU supports itSTM32F103C8 lacks factory ROM USB DFU

The label TMS on a genuine JTAG-capable V2 connector can be used as SWDIO, while TCK corresponds to SWCLK. That is why the official CN3 table uses combined names such as TMS_SWDIO and TCK_SWCLK. The word SWIM is different again: it is ST’s single-wire programming interface for STM8, not an alternative name for Cortex SWD.

For Blue Pill UART firmware loading, the common system-memory path uses USART1, PA9 TX and PA10 RX, with its particular boot settings. That procedure is separate from connecting ST-LINK to PA13/PA14. Plugging a USB cable into a stock Blue Pill’s Micro-USB connector does not magically implement a factory ROM DFU bootloader.

Troubleshooting ST-LINK V2 connections, from easiest to hardest

SymptomLikely causesWhat to test first
ST-LINK not detected on PCBad USB cable, clone firmware, driver issue, damaged probeDifferent known-good data cable/port; check USB enumeration
Probe detected, no target foundMissing target power, GND, wrong SWDIO/SWCLK, missing VAPPMeasure target VDD; verify signal labels and pin 1 VAPP on genuine probe
Target voltage = 0 V or absentVAPP/VTref missing, board unpowered, wrong probe pinMeasure actual target rail; check documented VTref connection
Connection works only at low SWD speedLong/noisy leads, weak power, bad groundShorten leads, add proper grounds, start 100–400 kHz
SWD initially worked but fails after a sketchPA13/PA14 reused, clock/low-power changesConnect Under Reset with NRST connected
Program operation fails or verifies incorrectlyWrong part, wrong flash address, protection, bad supplyCheck exact MCU, linker memory, file type, verify log
Reset does not recover targetNRST not actually connected, incorrect clone header, reset circuit problemTrace NRST electrically to target; confirm HWrst support
Bootloader works but SWD does notSWD pins/mode or debug probe faultTest PA13/PA14, debugger and SWD mode separately
Trace/SWV does not workSWO not wired, trace not configuredSWD programming needs no SWO; check PB3 and tool support
Clone connects intermittentlyUnreliable firmware, voltage/pin labelling differencesCompare with genuine probe or Nucleo onboard debugger

A disciplined fault-isolation sequence

  • Power: Verify actual target VDD and GND with a meter under operating conditions. Confirm you have not connected 5 V to the MCU rail.
  • Connector: Determine whether you have genuine V2 CN3, official 10-pin Cortex Debug, ST-LINK/V2-ISOL or an undocumented clone. Never mix their physical pin numbering.
  • Signals: Check continuity of SWDIO and SWCLK from the programmer connector to PA13/PA14 on the target. Check GND separately.
  • Voltage reference: Attach target VDD to VAPP on a genuine V2; don’t mistake an output 3.3 V pin for the sense input.
  • Software: Try ST-LINK + SWD in CubeProgrammer at a low clock. Confirm both probe and target are found.
  • Reset: Add NRST, try Under Reset, then check clock/pin initialization in firmware.
  • Substitution: If possible, test the STM32 board with a genuine probe or a known-good Nucleo onboard debugger, and test the questionable ST-LINK against a known-good target.
ST-LINK V2 SWD troubleshooting: USB probe, target voltage, SWDIO SWCLK, reset, clock and flash verification
Troubleshoot probe recognition, target power and SWD wiring before changing STM32 firmware or protection settings.

Do not conduct an electrical “continuity test” between live power rails using a meter’s continuity mode. Power off first; measure resistance/continuity only when safe, and use voltage mode on energized hardware.

Frequently asked questions

Can I program a Blue Pill with just SWDIO, SWCLK and GND?

Sometimes, if the target is already powered and the probe’s target-voltage requirements are satisfied. A genuine ST-LINK/V2 also expects its VAPP target-voltage reference, so the safest recommended wiring is SWDIO, SWCLK, GND, VAPP and NRST together with appropriate separate target power.

Is the ST-LINK V2 3.3 V pin an input or output?

It depends which specific pin and probe you mean. On genuine standalone ST-LINK/V2 CN3 pin 1 VAPP is the target-voltage reference, whereas pin 19 is documented as VDD 3.3 V but not as the SWD target power connection. A USB clone’s 3.3V header may be an output. Check the original manual or an actual schematic; do not generalize from the label alone.

What happens if I swap SWDIO and SWCLK?

A normal debug connection will fail because data and clock are on different lines. Rewire correctly with power disconnected; do not try to “fix” a swapped physical connection through a software setting.

Should BOOT0 be high or low for ST-LINK programming?

Usually low for normal application boot. SWD does not need the UART system-memory bootloader. Using BOOT0 high for a special recovery scenario is not part of the ordinary wiring procedure.

Does a genuine 20-pin ST-LINK/V2 map to the 10-pin Cortex connector one-to-one?

No. Both connector layouts have specific standards and different numbering. Use a properly specified adapter mapping signals and voltage reference; never connect pin 1 to pin 1 and pin 2 to pin 2 by assumption.

Is an ST-LINK V2 clone the same as an STLINK-V3?

No. A clone is usually an imitation of older hardware and software, while STLINK-V3 is a distinct family of genuine probes with additional features. If selecting a new debugger, consult ST’s TN1235 for the current line-up and the model’s own connector manual.

Can SWO be used in place of SWDIO?

No. SWDIO is the bidirectional data line required for SWD debug, while SWO is an optional instrumentation output. They are separate signals and often separate target pins.

Why does CubeProgrammer recognize my ST-LINK but not my STM32?

The computer can communicate with the USB probe even if the probe cannot communicate with the target. Most often the target is unpowered, ground or VTref is missing, SWDIO/SWCLK is reversed or a sketch has disabled the debug port. Check hardware first, then lower SWD speed and use Under Reset if NRST is wired.

Final checklist: the safest ST-LINK V2 hookup

For a Blue Pill or Black Pill, start by identifying the exact probe and applying the verified SWDIO, SWCLK, GND, target-voltage-reference and NRST connections. Power the STM32 correctly and independently of any ambiguous probe pin, check the rail with a meter, then test connection at low speed in STM32CubeProgrammer. Do not treat a clone photo as an official pinout, and don’t confuse the genuine 20-pin CN3 with the 10-pin Cortex Debug standard.

If you are new to the ecosystem, follow our STM32 for Beginners guide next, or compare the best STM32 development boards before buying additional hardware. For the exact connectors and voltage behavior, the original manufacturer manuals always take priority over a generic wiring photograph.

Authoritative technical references

CONTINUE EXPLORING / ESP32 & ELECTRONICS

Read next

Practical guides related to this article.

Explore the topic →
HARDWARE DECISION GUIDEWhich ESP32 board should you use?

Compare practical options before you choose hardware.

Compare options →