PX4 usually runs on autopilot controller hardware that provides an ARM Serial Wire Debug (SWD) interface. SWD is a low pin-count physical interface for JTAG debugging on ARM-processors. It can be used with an SWD-compatible debug probe (e.g. Segger J-Link EDU Mini, Dronecode Probe, etc.) to set breakpoints in PX4 and step through the code running on a real device.
The SWD interface can also be used to add a new bootloader and/or firmware on a completely empty board (one that does not have the USB bootloader installed).
This topic explains how to connect the SWD interface on different boards (debugging itself is then covered in the associated debugging topics).
The SWD interface consists of the following pins.
Pin | Signal Type | Description |
---|---|---|
Vref |
Output | Target reference voltage. Some JTAG adapters require the Vref voltage to set the voltage on the SWD lines. For example, SEGGER J-Link Debug Probes require Vref . |
SWDIO |
I/O | Single bi-directional data pin. |
SWCLK |
Output | Clock signal. |
GND |
- | Ground pin. |
While not "part" of SWD, an autopilot may also have an Serial Wire Output (SWO) trace output pin. If present this should also be connected.
Pin | Signal Type | Description |
---|---|---|
SWO |
Output | Serial Wire Output trace output pin. This may be used in combination with SWD to emit real-time trace data. |
Flight controllers commonly provide a single debug port that exposes both the SWD Interface and System Console. This must be connected to an SWD debug probe using an "appropriate" connector.
This connector may come with your flight controller or debug probe. Other options are given below.
The Holybro Pixhawk Debug Adapter is highly recommended when debugging controllers that use one of the Pixhawk-standard debug connectors.
It is the easiest way to connect:
- Flight controllers that use either the Pixhawk Debug Full (10-pin SH) or Pixhawk Debug Mini (6-pin SH) debug port, and
- SWD debug probes that support the 10-pin ARM compatible interface standard used by the Segger JLink Mini or 20-pin compatible with the Segger Jlink or STLink.
Some SWD debug probes come with adapters/cables for connecting to common Pixhawk debug ports. Probes that are known to come with connectors are listed below:
- DroneCode Probe: comes with a connector for attaching to the Pixhawk Debug Mini
Some manufacturers provide cables to make it easy to connect the SWD interface and System Console.
- CUAV V5nano and CUAV V5+ include this debug cable:
You can also create custom cables for connecting to different boards or probes:
- Connect
SWDIO
,SWCLK
andGND
pins on the debug probe to the corresponding pins on the autopilot. - Connect the
VRef
pin, if required by the debug adapter that is being used. - Connect the
SWO
pin, 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. :::
Flight controllers commonly provide a single debug port that exposes both the SWD Interface and System Console.
The Pixhawk Connector Standards 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 documentation for your autopilot to confirm port location and pinout.
The debug port location and pinouts for a subset of autopilots are linked below:
Autopilot | Connector |
---|---|
Holybro Pixhawk 5X (FMUv5x) | Pixhawk Debug Full |
Holybro Durandal | Pixhawk Debug Mini |
Holybro Kakute F7 | Solder pads |
Holybro Pixhawk 4 Mini (FMUv5) | Pixhawk Debug Mini |
Holybro Pixhawk 4 (FMUv5) | Pixhawk Debug Mini |
Drotek Pixhawk 3 Pro (FMU-v4pro) | Pixhawk Debug Mini |
CUAV V5+ | 6-pin JST GH Digikey: BM06B-GHS-TBT(LF)(SN)(N) (vertical mount), SM06B-GHS-TBT(LF)(SN)(N) (side mount) |
CUAV V5nano | 6-pin JST GH Digikey: BM06B-GHS-TBT(LF)(SN)(N) (vertical mount), SM06B-GHS-TBT(LF)(SN)(N) (side mount) |
3DR Pixhawk | 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:
:::tip Check your specific board to confirm the port used. :::
FMU Version | Pixhawk Ver. | Debug Interface |
---|---|---|
FMUv2 | Pixhawk / Pixhawk 1 | 10 pin ARM Debug |
FMUv3 | Pixhawk 2 | 6 pin SUR Debug |
FMUv4 | Pixhawk 3 | Pixhawk Debug Mini |
FMUv5 | Pixhawk 4 FMUv5 | Pixhawk Debug Mini |
FMUv5X | Pixhawk 5X | Pixhawk Debug Full |
FMUv6 | Pixhawk 6 | Pixhawk Debug Full |
FMUv6X | Pixhawk 6X | Pixhawk Debug Full |
:::note There FMU and Pixhawk versions are (only) consistent after FMUv5X. :::
The Pixhawk Connector Standard defines the Pixhawk Debug Mini, a 6-Pin SH Debug Port that provides access to both SWD pins and the System Console.
This is used in FMUv4 and FMUv5.
The pinout is as shown below (SWD pins highlighted):
Debug Port | Pin |
---|---|
1 | Vtref |
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):
Debug Port | Pin | Voltage |
---|---|---|
Pad | Signal | Volt |
1 | NRST (reset) | +3.3V |
2 | GPIO1 (free GPIO) | +3.3V |
3 | GPIO2 (free GPIO) | +3.3V |
The socket is a 6-pin JST SH - Digikey number: BM06B-SRSS-TBT(LF)(SN) (vertical mount), SM06B-SRSS-TBT(LF)(SN)(side mount).
You can connect to the debug port using a cable like this one.
The Pixhawk Connector Standard defines Pixhawk Debug Full, a 10-Pin SH Debug Port that provides access to both SWD pins and the System Console. This essentially moves the solder pads from beside the Pixhawk Debug Mini into the connector, and also adds an SWO pin.
This port is specified for use in FMUv5x, FMUv6, FMUv6x.
The pinout is as shown below (SWD pins highlighted):
Debug Port | Pin |
---|---|
1 | Vtref |
2 | Console TX |
3 | Console RX |
4 | SWDIO |
5 | SWDCLK |
6 | SWO |
7 | NFC GPIO |
8 | PH11 |
9 | nRST |
10 | GND |
The socket is a 10-pin JST SH - Digikey number: BM10B-SRSS-TB(LF)(SN) (vertical mount) or SM10B-SRSS-TB(LF)(SN) (side mount).
You can connect to the debug port using a cable like this one.
The following section outlines some popular debug probes and adaptors for connecting them to autopilots running PX4.
The Segger JLink EDU Mini is an inexpensive and popular SWD debug probe. The probe's connector pinout looks like the image below (connect to this using an ARM 10-pin mini connector like FTSH-105-01-F-DV-K).
The pin mapping to connect the J-Link Edu Mini to Pixhawk Debug Mini is shown below (note, the -
indicates a pin that is not required for SWD).
Debug Port | J-Link Mini |
---|---|
1 (Vtref) | 1 |
2 (Console TX) | - |
3 (Console RX) | - |
4 (SWDIO) | 2 |
5 (SWDCLK) | 4 |
6 (GND) | 3 or 5 |
:::tip From the table above you can infer the connections for autopilots that do not use the standard port. :::
The Dronecode Probe is a generic JTAG/SWD + UART console adapter compatible with most ARM Cortex based designs, and in particular with Pixhawk series flight controllers (and other hardware that PX4 supports).
The probe's USB interface exposes two separate virtual serial port interfaces: one for connecting to the System Console (UART) and the other for an embedded GDB server (SWD interface).
The probe provides a DCD-M connector cable for attaching to the Pixhawk Debug Mini.
:::note The 6-pos DF13 connector that comes with the probe cannot be used for SWD debugging (it is for using the System Console). :::
:::note The Dronecode Probe is based on the Black Magic Probe. :::
The Black Magic Probe is much like the Dronecode probe but does not come with the same adapters for directly connecting to Pixhawk series flight controllers.
Adapters can be purchased separately:
- Drone Code Debug Adapter (1 BIT SQUARED).
You've now connected the flight controller to an SWD debug probe!
The following topics explain how to start on-target debugging: