Pi-4 Activating additional UART ports
The new Pi-4 features additional hardware UART ports but I've been unable to find any documentation explaining how to access them.
Can anyone help?
Can anyone help?
Re: Pi-4 Activating additional UART ports
An updated ARM Peripherals document is going to be released soon that will cover the additional UARTs and I2C buses on the Pi 4B.
I think it has been mentioned somewhere about the GPIOs that they are available on and which ALT modes need to be selected.
I think it has been mentioned somewhere about the GPIOs that they are available on and which ALT modes need to be selected.
Unreadable squiggle
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 4489
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Pi-4 Activating additional UART ports
Code: Select all
$ dtoverlay -a | grep uart
Code: Select all
$ dtoverlay -h uart2
Code: Select all
$ raspi-gpio funcs
Re: Pi-4 Activating additional UART ports
Thanks for the answers. I'll look forward to seeing the new documentation.
In the meantime, can anyone suggest what I would need to add to /boot/config.txt to activate one of the new ports?
Thanks,
Mike
In the meantime, can anyone suggest what I would need to add to /boot/config.txt to activate one of the new ports?
Thanks,
Mike
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 4489
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Pi-4 Activating additional UART ports
Code: Select all
dtoverlay=uart3 # without flow control pins
dtoverlay=uart3,ctsrts # with flow control pins
Re: Pi-4 Activating additional UART ports
And how do we enable a serial terminal on each uart?
Re: Pi-4 Activating additional UART ports
Can more than 1 UART be used at the same time?
Unless specified otherwise my response is based on the latest and fully updated RPi OS Bullseye w/ Desktop OS.
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 4489
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Pi-4 Activating additional UART ports
To create a console on a UART, add "console=ttyAMAn,115200" to /boot/cmdline.txt, where n is a small integer - look in /dev to get the right number.
All 4 extra UARTs can be used at the same time provided their pins don't clash with something else you need.
All 4 extra UARTs can be used at the same time provided their pins don't clash with something else you need.
Re: Pi-4 Activating additional UART ports
raspi-gpio does not exist on existing raspian lite images, how do I install that?PhilE wrote: ↑Sat Jul 06, 2019 7:09 amRun on a Pi 4, this will show all of the alternate functions available on the 4.Code: Select all
$ raspi-gpio funcs
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 4489
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Pi-4 Activating additional UART ports
sudo apt-get install raspi-gpio
Re: Pi-4 Activating additional UART ports
Also shouldn't the serial setting also set uart 0 to terminal mode, I know mine doesn't.
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 4489
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Pi-4 Activating additional UART ports
The default kernel command line includes console=serial0, which the firmware translates to ttyAMA0 or ttyS0 as necessary. I don't think it would be appropriate to automatically create consoles on all enabled UARTs - many people would want to use them for something else.
Re: Pi-4 Activating additional UART ports
Yea, but maybe add a way to do it from raspi-config?
-
- Posts: 3
- Joined: Thu Mar 29, 2018 12:14 pm
Re: Pi-4 Activating additional UART ports
I'm also interested in enabling a second UART
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 4489
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Pi-4 Activating additional UART ports
Do you feel there is some information missing from the posts above?
-
- Posts: 3
- Joined: Thu Mar 29, 2018 12:14 pm
Re: Pi-4 Activating additional UART ports
Sorry... I ran under the impression that some documentation is still pending. But you did say
How do I enable all of them. For instance
uart1 being enabled by default, pi 4 having 4 extra uarts. Correct me if I'm wrong.
Code: Select all
dtoverlay=uart3 # without flow control pins
dtoverlay=uart3,ctsrts # with flow control pins
Code: Select all
dtoverlay=uart2,uart3,uart4,uart5
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 4489
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Pi-4 Activating additional UART ports
You need one dtoverlay= for each overlay. Anything else on the line is treated as a parameter. If you don't want to use the flow control signals then a fully loaded system would be:
I'm sure you can guess how to enable flow control for any/all of them.
Note that the kernel will reject attempts to enable UARTs where the pins are in use by something else (e.g. UART0, UART1 or one of the I2C ports), or it might even disable the other thing, so make sure what you are trying to do is possible.
Code: Select all
dtoverlay=uart2
dtoverlay=uart3
dtoverlay=uart4
dtoverlay=uart5
Note that the kernel will reject attempts to enable UARTs where the pins are in use by something else (e.g. UART0, UART1 or one of the I2C ports), or it might even disable the other thing, so make sure what you are trying to do is possible.
Re: Pi-4 Activating additional UART ports
Hi All,
I have followed the above, but can not figure out how to open an additional UART. I normally use /dev/ttyS0 or serial0, so have tried ttyS2, AMA2, serial2 etc... is there a step I am missing in enabling this, or has the addressing/binding changed with the 4?
I have enabled uart2 by adding to the /boot/config.txt:
dtoverlay=uart2
MW
I have followed the above, but can not figure out how to open an additional UART. I normally use /dev/ttyS0 or serial0, so have tried ttyS2, AMA2, serial2 etc... is there a step I am missing in enabling this, or has the addressing/binding changed with the 4?
I have enabled uart2 by adding to the /boot/config.txt:
dtoverlay=uart2
MW
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 4489
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Pi-4 Activating additional UART ports
On my Pi4 it appears as /dev/ttyAMA1 - there are no "serial<x>" aliases for the additional UARTs yet.
What other interface do you have enabled? uart2 attempts to use GPIOs 0 & 1 (0-3 if you're enabled RTS/CTS), so it won't work if something else (e.g. i2c0/i2c_vc) has grabbed 0 & 1.
What other interface do you have enabled? uart2 attempts to use GPIOs 0 & 1 (0-3 if you're enabled RTS/CTS), so it won't work if something else (e.g. i2c0/i2c_vc) has grabbed 0 & 1.
Re: Pi-4 Activating additional UART ports
Hello,
Thanks for the reply. I have installed Buster (full) out of the box, so unless those pins are doing something by default, I don't know.
/dev/ttyAMA1 does appear, can be opened, but there is no traffic. Traffic is present when using GPIO14/15 (TX/RX checked)
Also, using:
shows both AMA0 and AMA1, even though
No overlays loaded
This is with /boot/config.txt configured with:
It would appear that the uart does not load correctly (as seen with dtoverlay -l), unless I force
This is a strange one, indeed.
MW
Thanks for the reply. I have installed Buster (full) out of the box, so unless those pins are doing something by default, I don't know.
/dev/ttyAMA1 does appear, can be opened, but there is no traffic. Traffic is present when using GPIO14/15 (TX/RX checked)
Also, using:
Code: Select all
ls -l /dev/ttyA*
Code: Select all
dtoverlay -l says:
This is with /boot/config.txt configured with:
Code: Select all
dtoverlay=uart2
Code: Select all
sudo dtoverlay uart2
MW
Re: Pi-4 Activating additional UART ports
Update:
No idea why, but this is now working on AMA1. Must be a combination of me manually using sudo and loading and unloading, as I haven't changed anything in config.txt, or changed pins.
MW
No idea why, but this is now working on AMA1. Must be a combination of me manually using sudo and loading and unloading, as I haven't changed anything in config.txt, or changed pins.
MW
-
- Posts: 1
- Joined: Mon Aug 05, 2019 11:54 am
Re: Pi-4 Activating additional UART ports
Hello.
Thanks to this topic, I managed to run additional UART ports. But I have problems with running the raspberry again. I've come to the point that restarting will block one uart port connected to Gpio-0, Gpio-1 (TXD2, RXD2) pins. I have to unplug these pins each time I start the system. Is there any solution to this problem?
greetings
Thanks to this topic, I managed to run additional UART ports. But I have problems with running the raspberry again. I've come to the point that restarting will block one uart port connected to Gpio-0, Gpio-1 (TXD2, RXD2) pins. I have to unplug these pins each time I start the system. Is there any solution to this problem?
greetings
-
- Posts: 2
- Joined: Fri Dec 29, 2017 3:32 pm
Re: Pi-4 Activating additional UART ports
Hi everyone
Thanks for how to uarts activated on RPI-4. I added overlay lines (like below) to "/boot/config.txt" on my RPI-4
I have tested RX/TX for all activated uarts.
The results are below.
OK : There is no problem about transmit and receive.
NOK : Not worked.
uart1: OK
uart2: OK
uart3: NOK
uart4: OK
uart5: TX OK but RX not OK
There is a problem for uart3 and uart5.
I didn't understand why uart3 not worked and uart5 semi worked...
Please help me.
Regards
Thanks for how to uarts activated on RPI-4. I added overlay lines (like below) to "/boot/config.txt" on my RPI-4
Code: Select all
[all]
enable_uart=1
dtoverlay=uart2
dtoverlay=uart3
dtoverlay=uart4
dtoverlay=uart5
The results are below.
OK : There is no problem about transmit and receive.
NOK : Not worked.
uart1: OK
uart2: OK
uart3: NOK
uart4: OK
uart5: TX OK but RX not OK
There is a problem for uart3 and uart5.
I didn't understand why uart3 not worked and uart5 semi worked...
Please help me.
Regards
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 4489
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Pi-4 Activating additional UART ports
I suggest you start by running the following to establish whether the configuration has been successful:
On my Pi4B I get the following:
The config.txt contains:
(The miniuart overlay uses ttyS0 for Bluetooth, freeing /dev/ttyAMA0).
I deliberately reversed the order of the UART overlays to demonstrate that ordering here makes no difference to the ttyAMA numbering. Using this script: and moving my PC serial cable around the pins I found the following mapping:
In other words, transmitting works on all 5 PL011/ttyAMA UARTs.
Running "cat /dev/ttyAMA<x>" on each of the different UARTs in turn and moving the TX pin of the PC serial port around the various RXD pins produced the RX mapping: Be aware that if you have a console running ttyAMA0 (or any UART) then it will compete for your input, so you may have to try a few times.
Code: Select all
$ raspi-gpio get 0-15
$ ls /dev/ttyAMA*
Code: Select all
raspi-gpio get 0-15
GPIO 0: level=1 fsel=3 alt=4 func=TXD2 pull=NONE
GPIO 1: level=1 fsel=3 alt=4 func=RXD2 pull=UP
GPIO 2: level=1 fsel=4 alt=0 func=SDA1 pull=UP
GPIO 3: level=1 fsel=4 alt=0 func=SCL1 pull=UP
GPIO 4: level=1 fsel=3 alt=4 func=TXD3 pull=NONE
GPIO 5: level=1 fsel=3 alt=4 func=RXD3 pull=UP
GPIO 6: level=1 fsel=0 func=INPUT pull=UP
GPIO 7: level=1 fsel=0 func=INPUT pull=UP
GPIO 8: level=1 fsel=3 alt=4 func=TXD4 pull=NONE
GPIO 9: level=1 fsel=3 alt=4 func=RXD4 pull=UP
GPIO 10: level=0 fsel=0 func=INPUT pull=DOWN
GPIO 11: level=0 fsel=0 func=INPUT pull=DOWN
GPIO 12: level=1 fsel=3 alt=4 func=TXD5 pull=NONE
GPIO 13: level=1 fsel=3 alt=4 func=RXD5 pull=UP
GPIO 14: level=0 fsel=4 alt=0 func=TXD0 pull=NONE
GPIO 15: level=1 fsel=4 alt=0 func=RXD0 pull=UP
pi@raspberrypi:~$ ls /dev/ttyAMA*
/dev/ttyAMA0 /dev/ttyAMA1 /dev/ttyAMA2 /dev/ttyAMA3 /dev/ttyAMA4
Code: Select all
enable_uart=1
dtoverlay=pi3-miniuart-bt
dtoverlay=uart5
dtoverlay=uart4
dtoverlay=uart3
dtoverlay=uart2
I deliberately reversed the order of the UART overlays to demonstrate that ordering here makes no difference to the ttyAMA numbering. Using this script:
Code: Select all
#!/bin/sh
sudo stty -F /dev/ttyAMA0 115200
sudo stty -F /dev/ttyAMA1 115200
sudo stty -F /dev/ttyAMA2 115200
sudo stty -F /dev/ttyAMA3 115200
sudo stty -F /dev/ttyAMA4 115200
while true; do
sudo sh -c "echo 0 > /dev/ttyAMA0"
sudo sh -c "echo 1 > /dev/ttyAMA1"
sudo sh -c "echo 2 > /dev/ttyAMA2"
sudo sh -c "echo 3 > /dev/ttyAMA3"
sudo sh -c "echo 4 > /dev/ttyAMA4"
sleep 1
done
Code: Select all
GPIO14 = TXD0 -> ttyAMA0
GPIO0 = TXD2 -> ttyAMA1
GPIO4 = TXD3 -> ttyAMA2
GPIO8 = TXD4 -> ttyAMA3
GPIO12 = TXD5 -> ttyAMA4
Running "cat /dev/ttyAMA<x>" on each of the different UARTs in turn and moving the TX pin of the PC serial port around the various RXD pins produced the RX mapping:
Code: Select all
GPIO15 = RXD0 -> ttyAMA0
GPIO1 = RXD2 -> ttyAMA1
GPIO5 = RXD3 -> ttyAMA2
GPIO9 = RXD4 -> ttyAMA3
GPIO13 = RXD5 -> ttyAMA4
-
- Posts: 3974
- Joined: Thu Dec 27, 2012 4:05 am
- Location: Québec, Canada
Re: Pi-4 Activating additional UART ports
Is it me but enabling uart2 is irrelevant since GPIO0 and GPIO1 are not available!
Unless it is possible to disable I2C0.
Why every body want uart2?
uart5 is the best one to enable if you need I2c and SPI.
Unless it is possible to disable I2C0.
Why every body want uart2?
uart5 is the best one to enable if you need I2c and SPI.