SWD Debug Port
Last updated
Last updated
PX4 runs on ARM Cortex-M microcontrollers, which contain dedicated hardware for interactive debugging via the interface and non-invasive profiling and high-bandwidth tracing via the and .
The SWD debug interface allows direct, low-level, hardware access to the microcontroller's processor and peripherals, so it does not depend on any software on the device. Therefore it can be used to debug bootloaders and operating systems such as NuttX.
Four signals are required for debugging (in bold) while the rest is recommended.
GND
Power
Shared potential, common ground.
VREF
Power
The target reference voltage allows the debug probe to use level shifters on the signals.
SWDIO
I/O
Serial Wire Debug data pin.
SWCLK
Input
Serial Wire Debug clock pin.
nRST
Input
The reset pin is optional (n = active low).
SWO
Output
Single wire trace asynchronous data out can output ITM and DWT data.
TRACECK
Output
Trace clock for parallel bus.
TRACED[0-3]
Output
Trace synchronous data bus with 1, 2, or 4 bits.
The hardware reset pin is optional, as most devices can also be reset via the SWD lines. However, quickly resetting the device via a button can be great for development.
The SWO pin can emit low-overhead, real-time profiling data with nanosecond timestamping and is therefore strongly recommended to have accessible for debugging.
The TRACE pins require specialized debug probes to deal with the high bandwidth and subsequent datastream decoding. They are usually not accessible and are typically only used to debug very specific timing issues.
Flight controllers commonly provide a single debug port that exposes both the and .
The debug port location and pinouts for a subset of autopilots are linked below:
[Holybro Pixhawk 5X][holybro pixhawk 5x] (FMUv5x)
Solder pads
ARM 10-pin JTAG Connector (also used for FMUv2 boards including: mRo Pixhawk, HobbyKing HKPilot32).
The Pixhawk project has defines a standard pinout and connector type for different Pixhawk FMU releases:
FMUv2
10 pin ARM Debug
FMUv3
Pixhawk 2
6 pin SUR Debug
FMUv4
Pixhawk 3
FMUv5
Pixhawk 4 FMUv5
FMUv5X
Pixhawk 5X
FMUv6
Pixhawk 6
FMUv6X
Pixhawk 6X
:::note There FMU and Pixhawk versions are (only) consistent after FMUv5X. :::
This is used in FMUv4 and FMUv5.
The pinout is as shown below (pins required for debugging are bold):
1
VREF
2
Console TX
3
Console RX
4
SWDIO
5
SWDCLK
6
GND
The debug port definition includes the following solder pads (on board next to connector):
1
nRST
+3.3V
2
GPIO1
+3.3V
3
GPIO2
+3.3V
This port is specified for use in FMUv5x, FMUv6, FMUv6x.
The pinout is as shown below (pins required for debugging are bold):
1
VREF
2
Console TX
3
Console RX
4
SWDIO
5
SWDCLK
6
SWO
7
GPIO1
8
GPIO2
9
nRST
10
GND
The GPIO1/2 pins are free pins that can be used to generate signals in software for timing analysis with a logic analyzer.
There are several debug probes that are tested and supported for connecting to one or both of these interfaces:
An adapter to connect to the debug port may come with your flight controller or debug probe. Other options are given below.
It is the easiest way to connect:
You can also create custom cables for connecting to different boards or probes:
Connect SWDIO
, SWCLK
and GND
pins on the debug probe to the corresponding pins on the debug port.
Connect the VREF pin, if supported by the debug probe.
Connect the remaining pins, if present.
:::tip Where possible, we highly recommend that you create or obtain an adapter board rather than custom cables for connecting to SWD/JTAG debuggers and computers. This reduces the risk or poor wiring contributing to debugging problems, and has the benefit that adapters usually provide a common interface for connecting to multiple popular flight controller boards. :::
The formalize the port that must be used in each FMU version. However there are still many boards that use different pinouts or connectors, so we recommend you check the to confirm port location and pinout.
(FMUv5)
(FMUv5)
(FMU-v4pro)
6-pin JST GH Digikey: (vertical mount), (side mount)
6-pin JST GH Digikey: (vertical mount), (side mount)
:::tip Check your to confirm the port used. :::
The defines the Pixhawk Debug Mini, a 6-Pin SH Debug Port that provides access to both SWD pins and the .
The socket is a 6-pin JST SH - Digikey number: (vertical mount), (side mount).
You can connect to the debug port using a .
The defines Pixhawk Debug Full, a 10-Pin SH Debug Port that provides access to both SWD pins and the . This essentially moves the solder pads from beside the into the connector, and also adds an SWO pin.
The socket is a 10-pin JST SH - Digikey number: (vertical mount) or (side mount).
You can connect to the debug port using a .
Flight controllers commonly provide a that exposes both the and .
: commercial probe, no built-in serial console, requires adapter.
: integrated GDB server and serial console, requires adapter.
: best value, integrated serial console, adapter must be soldered.
The is highly recommended when debugging controllers that use one of the Pixhawk-standard debug connectors.
Flight controllers that use either the (10-pin SH) or (6-pin SH) debug port.
SWD debug probes that support the 10-pin ARM compatible interface standard used by the or 20-pin compatible with the Segger JLink or STLink.
The comes with an .
This has a ports for connecting to the (10-pin SH) and CUAV-standard DSU interface (but not the (6-pin SH)).
The M2 connector on the adaptor is 14-pin CN4 STDC14 (see the for more information). The cable used to connect the M2 and the STLinkv3-MINIE comes with the adaptor.
Some SWD come with adapters/cables for connecting to common Pixhawk . Probes that are known to come with connectors are listed below:
: comes with a connector for attaching to the
Some manufacturers provide cables to make it easy to connect the SWD interface and .
and include this debug cable:
See the for a guide on how to solder a custom cable.