SWD/JTAG 调试接口

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 (actually performing debugging is then covered in the associated debugging topics).

SWD Interface Definition

The SWD interface consists of the following pins.

针脚Signal Type参数描述

参考压

输出

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

输出

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.

针脚Signal Type参数描述

SWO

输出

Serial Wire Output trace output pin. This may be used in combination with SWD to emit real-time trace data.

Connecting SWD Debuggers to PX4 Hardware

Connect SWDIO, SWCLK and GND pins on the debug probe to the corresponding pins on the autopilot.

In addition:

  • Connect the VRef pin, if required by the debug adapter that is being used.

  • Connect the SWO pin, if present.

Some SWD debug probes come with adapters/cables for connecting to common Pixhawk debug ports. You can also create custom cables for connecting to different boards or probes.

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.

Autopilot Debug Ports

Flight controllers commonly provide a debug port that exposes both the SWD Interface and System Console.

The Pixhawk Connector Standards attempts to standardise this port. However since many boards use different pinouts or connectors, we recommend you check the documentation for your autopilot to confirm port location and pinout.

The debug port location and pinouts for a small subset of autopilots are linked below:

飞控Connector

ARM 10-pin JTAG Connector (also used for FMUv2 boards including: mRo Pixhawk, HobbyKing HKPilot32).

6-pin JST GH Digikey: BM06B-GHS-TBT(LF)(SN)(N) (vertical mount), SM06B-GHS-TBT(LF)(SN)(N) (side mount)

6-pin JST GH Digikey: BM06B-GHS-TBT(LF)(SN)(N) (vertical mount), SM06B-GHS-TBT(LF)(SN)(N) (side mount)

Solder pads

Check the autopilot topics if your flight controller is not listed.

Pixhawk Standard Debug Ports

The Pixhawk project has defines a standard pinout and connector type for different Pixhawk FMU releases:

Check your specific board to confirm the port used.

FMU VersionPixhawk Ver.Debug Interface

FMUv2

10 pin ARM Debug

FMUv3

Pixhawk 2

6 pin SUR Debug

FMUv4

Pixhawk 1/2

FMUv5

Pixhawk 4 FMUv5

FMUv5X

Pixhawk 5X

FMUv6

Pixhawk 6

FMUv6X

Pixhawk 6

Pixhawk Debug Mini (6-Pin SH Debug Port)

The Pixhawk Connector Standard defines a 6-Pin SH Debug Port that provides access to both SWD pins and the System Console.

The pinout is as shown below (SWD pins highlighted):

Debug调试端口针脚

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调试端口针脚Voltage

Pad

信号

电压

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.

Pixhawk Debug Full (10-Pin SH Debug Port)

The Pixhawk Connector Standard defines 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 6-Pin SH Debug Port into the connector, and also adds an SWO pin.

The pinout is as shown below (SWD pins highlighted):

Debug调试端口针脚

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.

Debug Probes

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 6-Pin SH Debug Port is shown below (note, the - indicates a pin that is not required for SWD).

Debug调试端口J-Link Mini

1 (Vtref)

1

2 (Console TX)

-

3 (Console RX)

-

4 (SWDIO)

2

5 (SWDCLK)

4

6 (GND)

3 or 5

From the table above you can infer the connections for autopilots that do not use the standard port.

Dronecode Probe

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 6-Pin SH Debug Port.

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:

后续步骤

You've now connected the flight controller to an SWD debug probe!

The following topics explain how to start on-target debugging:

Last updated