Introduction
I think in general the serial port configuration in PX4 is quite confusing. According to this documentation: Serial Port Configuration | PX4 User Guide (main), we can select which serial ports to use for MAVLink telemetry, GPS, OSD, etc. by their conceptual “TELEM x” (x being 1, 2, 3, or 4) ports.
Confusion
However, as you can check in the parameter reference, we can also select “GPS x” (x = 1, 2, or 3), or even Radio Controller, Wifi Port, and EXT2.
I can understand that “TELEM x” and “GPS x” ports are quite intuitive, at least on Pixhawk boards where the corresponding ports are correctly marked.
However, regarding the “Radio Controller”, “Wifi port”, and “EXT2”, they definitely are confusing (e.g. I am guessing Radio Controller corresponds to the “RC/SBUS” on Pixhawk boards?).
Also, the exact matching between the “TELEM x” (PX4) and the actual “USART x” (STM32, for example) is quite vague, as the only common connection between those concept is the “/dev/ttySx” naming (NuttX convention):
And, the “/dev/ttySx” seems to be ordered automatically in the NuttX code:
And this is actually all documented here: Serial Port Mapping | PX4 User Guide (main)
Question
So well, I was in general just very confused about how the whole UARTx, TELEM x, MAV_x_CONFIG concepts are all related, but it seems like I have answered my question myself.
To summarize:
- USART index for each “/dev/ttyS{x}” equals to the "x+1"th USART configured to use in
nuttx-config/nsh/defconfig
file - Each “/dev/ttyS{x}” is connected to certain conceptual functions (e.g. TELEM port, GPS port) in the
default.px4board
file - When you select the TELEM / GPS / RC ‘port’ for the MAV_x_CONFIG parameters, it is essentially directly mapping the corresponding USART port, that can be traced back via the point 1 above.
Other
Note, some ideas on hiding the confusing MAV_x_CONFIG
parameters were raised in Configurable serial ports · Issue #6905 · mavlink/qgroundcontrol · GitHub.
Also, all the ‘serial port names’ seems to be determined via this script: