Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

header

Buy SWDxUSBC on FYSETC Join Discord Community Support Me on Ko-fi License: CC BY 4.0

SWDxUSBC: ST-Link V2 Debug Probe with SWD over USB Type-C

SWDxUSBC modernizes the classic ST-Link V2 by integrating a full-featured USB Type-C interface. It routes the SWD programming signals, SWDIO and SWCLK, through the USB Type-C Sideband Use (SBU) pins, eliminating fragile jumper wires and exposed debug pads.

It lets you program, debug, power the target through USB Power Delivery, and maintain USB 2.0 data communication, all through a single USB Type-C cable.

How Does It Work?

Two pins in a USB Type-C connector, SBU1 and SBU2, often remain unused in USB 2.0-only applications. They are intended for sideband signaling used by alternate and accessory modes.

Because many embedded projects require only USB 2.0 functionality, these pins can remain available. SWDxUSBC repurposes them for the two-wire SWD interface: SWDIO and SWCLK.

type-c-pinout

Core Features

  • Single-Cable Solution: Combines power, USB 2.0 data, and SWD debugging through one USB Type-C connector.
  • Long Debug Cables: Keep your PC meters away from the target without relying on fragile SWD ribbon cables.
  • Power Delivery (PD) and USB 2.0 Passthrough: Passes power and USB data to the target while debugging is active. You can read USB logs from the board and deliver PD power, up to 48 V / 5 A with suitable PD control, without interference from the debugger.
  • Space Saving: Removes bulky debug headers from compact projects, enables firmware updates in closed enclosures, and reduces throwaway adapters and e-waste.
  • Reliable Connection: Uses a single robust connector instead of separate power, USB, and debug cables.
  • Virtual COM Port: Supports VCP for direct UART debugging in addition to USB and SWD.

How to Use the Debugger

connection-diagram

Classic ST-Link Programmer over Type-C with USB2.0 and PowerDelivery Line Transit
Goal Use the debugger similarly to a classic ST-Link. Update firmware and debug through a single USB Type-C cable.
PC connection - ST-Link connector (green) via Type-C with USB2.0 support. - ST-Link connector (green) via Type-C with USB2.0 support.
- Data connector (orange) via Type-C with USB2.0 and PowerDelivery support, if required by the target.
Target connection SWD ribbon cable, plus optional SWO, RESET, or VCP lines. GND must be connected. Only the target connector (blue) via Type-C with USB3.0, PowerDelivery, and SideBand channel support (a full-featured cable).

Note

You can use the onboard 3V3 supply to power external targets at up to 500 mA. The onboard DC/DC converter is protected by a polyfuse.

Caution

The ST-Link operates with a fixed 3V3 target voltage. Before connecting it, make sure this voltage cannot damage the target.

USB-C IF Compatibility

Note

This is a custom hardware extension, intended only for devices that explicitly implement SWDxUSBC. It is not a USB Type-C Alternate Mode and must not be presented as USB-IF-certified USB-C behavior while SWD is connected without a MUX.

Although this approach is among the closest practical solutions to the USB IF specification, do not connect this programmer to arbitrary USB-C equipment.

It is generally safe to connect a board with SWD over Type-C directly to a PC or another device using a cable ONLY IF IT DOESNT HAVE SBU LINES INSIDE. This is common with power-only and USB2.0-only cables. However, there is no absolute guarantee that connecting a full-featured cable to a PC port supporting USB 3.x, USB4®, Thunderbolt™, or USB-C Alternate Modes will not cause issues.

The chance of a problem is extremely small, but it is not zero because of possible back-powering through the SBU pins. In most applications, where the MCU is not powered before the host device, this should be safe.

Warning

  • SWDxUSBC does not support USB 3.x, USB4®, Thunderbolt™, or USB-C Alternate Modes on the same connector while SWD is active. The SBU pins are shared infrastructure and may be used by DisplayPort Alt Mode, USB4, or other supported modes. If you need this functionality, add a MUX to the SWD signal lines.

  • A full-featured USB-C cable with SBU conductors is required for SWD debug access through USB-C. USB 2.0 Type-C cables frequently do not implement SBU wires and therefore cannot carry SWD.

  • SWDIO and SWCLK are orientation-dependent. The SBU conductors cross through a standard USB-C cable, so you may need to flip the cable if the debugger cannot communicate.

Caution

Use this programmer ONLY with devices confirmed to support firmware flashing through SWDxUSBC. It is not a general-purpose USB-C debugger and must never be connected to an unknown USB-C port.

Design Guidelines

Caution

The implementation must tolerate an unpowered target and prevent unintended back-powering through SBU, VBUS, CC, or ESD-protection paths.

Warning

Double-check the USB Type-C connector datasheet. The connector must have its SBU pins connected. Although most 16-pin connectors expose these pins, some do not.

In some cases, SBU pins may not be shown as connected in the documentation even though they are internally connected. For guaranteed compatibility, use connectors with confirmed SBU connectivity or test them before placing a batch order.

Tip

  • Use an additional 220R-1k series resistor on the SWDIO and SWCLK lines to improve safety and reduce ESD stress.
  • Place high-speed, low-capacitance ESD protection on every USB connector signal line, including SBU.
  • If possible, add an analog switch between the SWD and SBU pins for better compatibility with the USB IF specification.
  • For maximum USB IF compliance, add a special mode that configures SWDIO and SWCLK as high-impedance inputs with no pull-up or pull-down. This mode can activate after boot, or be selected by a specific condition such as a button press. Design this carefully, because a poor implementation could make MCU recovery difficult in the worst case.
  • If board space allows, adding conventional SWD pads is still a good idea for maximum reliability and recovery access.

Hardware Design

The SWDxUSBC schematic is available below. All project and production files are located in the Hardware folder. You can also find the ST-Link V2 design.

A small adapter board for the ST-Link V3 Mini is also available as a low-cost option.

./Hardware/ST-LinkV2/SWDxUSBC.svg

From Bare PCBA to Functional ST-Link

What came first: the egg or the chicken? The same applies here: you need another ST-Link to flash a new ST-Link.

Follow this step-by-step guide.

Extremely Useful Tool

MCUViewer is an ideal companion for SWDxUSBC. Connect the compact USB-C ST-Link, open the target .elf file, and plot live RAM variables over SWD without adding UART telemetry or loading the MCU core with USB or another communication interface.

E.g. for motor-control development, it is particularly useful for tuning current, position, velocity, observers, and control-loop gains directly on running hardware in real time, while USB remains available for device logs. MCUViewer's Var Viewer showing a triangle wave, two triggered plots, a live variable list, and recorder configuration controls

Where Is SWDxUSBC Used?

For now, SWDxUSBC is used in the CLN17 and CLN234 projects. I also use it in my side projects, and after switching away from separate pin wires, I cannot imagine going back.

I believe this approach will become much more common in hobby and open-source embedded projects over time.

Support the Project ☕

If SWDxUSBC saves you time, cables, or frustration, please consider supporting me and my developments on Ko-fi. Every coffee helps turn more ideas into open hardware.

About

SWD over USB Type-C debugger tool

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors