I'm working on a CAN bus controller with a STMF105 MCU.
The controller is in a waterproof enclosure with a sealed USB-C connector.
I want the option to properly debug with SWD and easy field update the firmware.
Only the USB 2.0 pins (D+, D-, GND, VBUS) are used for the USB connection. CC1 and CC2 are pulled down to get 5V power from a USB-C host.
I discovered it possible to use the two shielded differential pairs of the USB-C connector (TX1, RX1, TX2, RX2) for SWD debugging? USB-C offers an official Debug Accessory Mode where even up to 14 pin's with orientation detection or 7 pin's without can be used for debugging. But I'm wondering if I can't keep the SWD pin's connected to the unused USB-C pin's without actively detecting debug accessory mode?

Could the USB 2.0 connection be disturbed by the SWD signals on the other pin's or could I even damage the SWD pins of the MCU or RX/TX pin's of the computer if a USB-C cable is connected?
I want to make a custom USB-C to ST-link cable for debugging and flashing the DFU bootloader over SWD.
After that updates could be easily flashed trough the same port with a standard USB-C cable.

USB-C wiring

USB-C with SWD

Any advice how to implement SWD over the USB-C connection are welcome.


2 Answers 2


I discovered it possible to use the two shielded differential pairs of the USB-C connector (TX1, RX1, TX2, RX2) for SWD debugging?

I wouldn't do this, if a user plugged in a USB 3.0 Cable those pins would connect with the trancievers of the host and that could lead to unpredictable results. If I were doing this, I might provide a means to make those ports Hi-z with a buffer (with an enable line) and then have a button or switch on the device so you could flash over USB but the rest of the time the ports would be Hi-z.

  • \$\begingroup\$ Actually, there is a mux that either switches the lines to the pins or leaves them floating. But there are other mistakes that make this dangerous, such as you can have 3.3V on SBU lines because they are unused - well if you plug that to a laptop with e.g. DP alt mode support then you may end up with a damaged laptop. \$\endgroup\$
    – Justme
    Mar 23, 2023 at 18:02
  • 1
    \$\begingroup\$ Thanks for the hint about the constant 3.3V on the SBU lines. I moved 3.3 V voltage detect to the AND output. \$\endgroup\$ Mar 26, 2023 at 10:49

I think it should be safe. Those pins are used for other data channels as well. Since USB-C swaps things around so much, nothing should be connected until devices negotiate for it. If you're only implementing USB 2 or lower, nothing should try to use the fast lanes.

As for interference in the cable, that's unlikely. The pairs are all twisted for their own immunity so nearby single ended signals shouldn't affect them much. They also all have error detecting (and sometimes correcting) features.

You can check the full USB-C Cable and Connector Specification. There is a "correct" way to enter this mode with pulling the CC lines to ground temporarily, but you can possibly ignore that without much issue on a development device.

As you mentioned, you get, including the 4 for D+/-, 14 pins (minus 1 per reversable pin) - plenty to add SWD with VTG, SWO, and RST while keeping the USB 2 connection and reversibility.

Figure B-2, DTS Plug Interface, from USB Type-C Specification highlighting the pins that are available for arbitrary use in DAM mode

Álvaro Prieto wrote a nice explanation with full open source hardware to put SWD on the extra pins.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.