4.4. UART Configuration
Attention
By default UART0 is used as a login terminal. Do not change this, unless there is a compelling reason to do so.
We have made the decision to use UART5 for the telemetry communication with the FCU. UART4 is connected to the debug port of the FCU.
4.4.1. Enable UARTs
Edit the config file
sudo vim /boot/firmware/config.txt
and append the dtoverlay=
lines for the required UARTs.
dtoverlay=uart2
dtoverlay=uart4
dtoverlay=uart5
4.4.2. UART-KERNELS-Pin Mapping
The UART functions in the following table depend on whether Raspberry Pi is used in a UUV or for the gantry controlling computer.
UART |
KERNELS |
Tx/Rx GPIOs |
---|---|---|
0 |
|
|
1 |
||
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
4.4.3. Pinout
4.4.4. UART Rule
Create the file /etc/udev/rules.d/50-serial.rules
with the following content:
KERNEL=="ttyAMA[0-9]*", GROUP="dialout", ENV{SERIAL_MARKER}="fcu_serial"
# uart4
ENV{SERIAL_MARKER}=="fcu_serial", SUBSYSTEM=="tty", KERNELS=="fe201800.serial", SYMLINK+="fcu_debug"
# uart5
ENV{SERIAL_MARKER}=="fcu_serial", SUBSYSTEM=="tty", KERNELS=="fe201a00.serial", SYMLINK+="fcu_data"
KERNEL=="ttyAMA[0-9]*", GROUP="dialout", ENV{SERIAL_MARKER}="serial_marker"
# uart2
ENV{SERIAL_MARKER}=="serial_marker", SUBSYSTEM=="tty", KERNELS=="fe201400.serial", SYMLINK+="teensy_data"
# uart4
ENV{SERIAL_MARKER}=="serial_marker", SUBSYSTEM=="tty", KERNELS=="fe201800.serial", SYMLINK+="fcu_debug"
# uart5
ENV{SERIAL_MARKER}=="serial_marker", SUBSYSTEM=="tty", KERNELS=="fe201a00.serial", SYMLINK+="fcu_data"
KERNEL=="ttyAMA[0-9]*", GROUP="dialout", ENV{SERIAL_MARKER}="motor_serial"
# uart2
ENV{SERIAL_MARKER}=="motor_serial", SUBSYSTEM=="tty", KERNELS=="fe201400.serial", SYMLINK+="motor_x"
# uart4
ENV{SERIAL_MARKER}=="motor_serial", SUBSYSTEM=="tty", KERNELS=="fe201800.serial", SYMLINK+="motor_y"
# uart5
ENV{SERIAL_MARKER}=="motor_serial", SUBSYSTEM=="tty", KERNELS=="fe201a00.serial", SYMLINK+="motor_z"
You can apply these changes by
$ sudo udevadm control --reload-rules && sudo udevadm trigger
To check, that the rule is applied correctly, you can execute
ls /dev/fcu* -l
ls /dev/motor* -l
The output should show symbolic links for the serial devices:
lrwxrwxrwx 1 root root 7 Dec 11 14:57 /dev/fcu_debug -> ttyAMA1
lrwxrwxrwx 1 root root 7 Dec 11 14:57 /dev/fcu_tele -> ttyAMA2
lrwxrwxrwx 1 root root 7 Aug 7 01:00 /dev/motor_x -> ttyAMA2
lrwxrwxrwx 1 root root 7 Aug 7 01:00 /dev/motor_y -> ttyAMA3
lrwxrwxrwx 1 root root 7 Aug 7 01:00 /dev/motor_z -> ttyAMA4
Note
The ttyAMA
numbers might differ, depending on the UARTs you have activated.
4.4.5. Identify KERNELS
To identify the KERNELS paramter of a certain ttyAMA
device, execute the following command.
$ udevadm info --name=/dev/ttyAMA1 --attribute-walk
1looking at device '/devices/platform/soc/fe201800.serial/tty/ttyAMA1':
2KERNEL=="ttyAMA1"
3SUBSYSTEM=="tty"
4DRIVER==""
5
6looking at parent device '/devices/ platform/soc/fe201800.serial':
7KERNELS=="fe201800.serial"
8SUBSYSTEMS=="amba"
9DRIVERS=="uart-pl011"
10ATTRS{driver_override}=="(null)"
11ATTRS{id}=="00241011"
12ATTRS{irq0}=="14"
13
14looking at parent device '/devices/ platform/soc':
15KERNELS=="soc"
16SUBSYSTEMS=="platform"
17DRIVERS==""
18ATTRS{driver_override}=="(null)"
19
20looking at parent device '/devices/ platform':
21KERNELS=="platform"
22SUBSYSTEMS==""
23DRIVERS==""
Attention
The ttyAMAx
number is not specific for the UART device and depends on how many UARTs are activated.