Serial Port Mapping
Last updated
Last updated
This topic shows how to determine the mapping between USART/UART serial port device names (e.g. "ttyS0") and the associated ports on a flight controller, such as TELEM1
, TELEM2
, GPS1
, RC SBUS
, Debug console
.
The instructions are used to generate serial port mapping tables in flight controller documentation. For example: .
:::note The function assigned to each port does not have to match the name (in most cases), and is set using a . Usually the port function is configured to match the name, which is why the port labelled GPS1
will work with a GPS out of the box. :::
This section shows how to get the mappings for NuttX builds on STMxxyyy architectures by inspecting the board configuration files. The instructions use FMUv5, but can similarly be extended for other FMU versions/NuttX boards.
The default.px4board lists a number of serial port mappings (search for the text "SERIAL_PORTS").
From :
Alternatively you can launch boardconfig using make px4_fmu-v5 boardconfig
and access the serial port menu
Search for the text "ART" until you find a section like with entries formatted like CONFIG_STM32xx_USARTn=y
(where xx
is a processor type and n
is a port number). For example:
The entries tell you which ports are defined, and whether they are UART or USART.
Copy the section above and reorder numerically by "n". Increment the device number ttySn alongside (zero based) to get the device-to-serial-port mapping.
For flight controllers that have an IO board, determine the PX4IO connection from board_config.h by searching for PX4IO_SERIAL_DEVICE
.
So the PX4IO is on ttyS6
(we can also see that this maps to UART8, which we already knew from the preceding section).
The final mapping is:
UART1
/dev/ttyS0
GPS
USART2
/dev/ttyS1
TELEM1 (flow control)
USART3
/dev/ttyS2
TELEM2 (flow control)
UART4
/dev/ttyS3
TELEM4
USART6
/dev/ttyS4
RC SBUS
UART7
/dev/ttyS5
Debug Console
UART8
/dev/ttyS6
PX4IO
:::note Contributions welcome! :::
The nsh/defconfig allows you to determine which ports are defined, whether they are UART or USARTs, and the mapping between USART/UART and device. You can also determine which port is used for the .
Open the board's defconfig file, for example:
To get the DEBUG console mapping we search the for SERIAL_CONSOLE
. Below we see that the console is on UART7:
For example, :
In the the resulting table is: