How to use UART0 on Raspberry Pi 3+

How to use UART0 on Raspberry Pi 3+

September 14, 2018 0 By Klemen

Have you ever tried to connect a device with UART interface to the Raspberry Pi but you needed baudrate of 921600 baud/s? The only UART interface on Raspberry Pi 3  accessible through GPIO pins that supports that kind of speed out of the box is the UART0, which is used by the system console and Bluetooth chip. Complete instructions can be found here.

The process is simple and requires just a few steps.

1. Update

First we need to update the system.

$ sudo apt-get update 
$ sudo apt-get upgrade
$ sudo rpi-update
$ sudo reboot

2. Disable Bluetooth

We need to disable the Bluetooth that uses the UART0 interface so we can use it later. This can be done by editing the file /boot/config.txt by adding the line dtoverlay=pi3-disable-bt at the end of the file.

$ sudo nano /boot/config.txt
# now add the line to the end of file
dtoverlay=pi3-disable-bt

We have to disable the HCI UART interface by disabling the hciuart systemd service and rebooting it after that

$ sudo systemctl disable hciuart
$ sudo reboot

3. Disable console

Now we have to disable the console to properly access the UART0 serial interface. This can be done by removing the console=serial0,115200 from the /boot/cmdline.txt file.

$ sudo nano /boot/cmdline.txt
# content of the original file
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
# content of the edited file /boot/cmdline.txt 
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

To finish the process we have to reboot the system.

$ sudo reboot

/dev/ttyAMA0  serial interface can now be used as a serial UART interface for communication with external devices.