A while ago I wrote an article on how to turn your Raspberry Pi into a serial console server. As we all know by default a Pi has a serial console port - er a TTL port controlled a UART (Universal Asynchronous Receiver-Transmitter). In order to connect it to a standard serial port you need a nullmodem and a serial-ttl converter.
I started poking around in /boot/overlays/README to see how else that same port could be used (maybe as a client?) but found more UARTs?!? It turns out that the Pi 4b in fact has a total of 5 TTL ports (1 console, plus extra)!
Port | TX GPIO | TX PIN | RX GPIO | RX PIN | Device |
---|---|---|---|---|---|
uart0 | 14 | 8 | 15 | 10 | /dev/ttyAMA0 |
uart1 | 14 | 8 | 15 | 10 | /dev/ttyAMA1 |
uart2 | 0 | 27 | 1 | 28 | /dev/ttyAMA2 |
uart3 | 4 | 7 | 5 | 29 | /dev/ttyAMA3 |
uart4 | 8 | 24 | 9 | 21 | /dev/ttyAMA4 |
uart5 | 12 | 32 | 13 | 33 | /dev/ttyAMA5 |
But wait there are 6 ports, plus uart1 and uart0 both use the same pins. You can remap uart1 to GPIO 32/33 or GPIO 40/41 but that’s only used with the computing modules. So uart1 is basically non-functional.
To enable uarts use the following entries in /boot/firmware/config.txt to enable individual uarts. dtoverlay=uart2 dtoverlay=uart3 dtoverlay=uart4 dtoverlay=uart5
I’m actually using this in production. The idea is that I want Raspi A to act as a terminal client and Raspi B to be the console I’m connecting to:
Raspi A (Client) | Raspi B (Console) |
---|---|
27 PIN TXD | 10 PIN RXD |
28 PIN RXD | 8 PIN TXD |
6 PIN GND | 6 PIN GND |
You’ll need a utility like screen:
apt-get install screen
Execute this from Raspi A
screen /dev/ttyAMA2 115200
You should see the console login screen from Raspi B!
Created: 2025-02-07 | Modified: 2025-02-07 |