I've been struggling to get my RPi4 serial working over pins 8,10.
I have both a Raspberry OS image and an Ubuntu 18.04 image for the RPi4. In either case, when I use RASPI-CONFIG to disable console and enable uart, I'm still unable to use minicom to see characters or to receive data over serial.
dmesg | grep tty
console [tty1] enabled
serial: ttyAMA0 at MMIO is a PL011 rev2
serial: ttySo at MMIO is a 16550
ls -l /dev/serial*
/dev/serial0 -> ttyS0
/dev/serial1 -> ttyAMA0
setserial -g /dev/tty*
/dev/ttyAMA0, UART undefined, Port: 0x0000, IRQ: 19
/dev/ttyS0, UART: 16550, Port 0x0000, IRQ: 21
sudo minicom -o -D /dev/serial0 or 1
no characters reflected back with loopback in place
enable_uart=1 is in config.txt
I'm getting the exact same results on both Ubuntu 18.04 and Raspberry OS. Neither enables the serial port to work. What else could I try or am I missing?
-
2If you loop TX with RX on the same device you can see the char that you send is also received on the same device. This is a common trouble shooting pratice for serial devices.MatsK– MatsK2020年07月15日 17:32:33 +00:00Commented Jul 15, 2020 at 17:32
-
1What are you actually trying to connect to via serial?CoderMike– CoderMike2020年07月15日 20:47:36 +00:00Commented Jul 15, 2020 at 20:47
-
1Using a loopback wire for the test. Ultimately connecting to Roboclaw motor driver via serial. It does not indicate it needs a level shifter but I'm now wondering if my past experimentation with the connection to the Roboclaw put 5v on Rx somwhow.BenignFun– BenignFun2020年07月15日 22:18:28 +00:00Commented Jul 15, 2020 at 22:18
2 Answers 2
Here's some things I needed to do specifically to connect to a device like the Roboclaw. I got this to work on Ubuntu20.04, Ubuntu18.04 and raspberry pi OS (raspbian)
- add
enable_uart=1
to/boot/config.txt
- remove
console=serial0,115200
from/boot/firmware/cmdline.txt
on Ubuntu and/boot/cmdline.txt
on Raspberry Pi OS - disable the serial console:
sudo systemctl stop [email protected] && sudo systemctl disable [email protected]
- make sure you have
pyserial
installed if you're using the python serial library, notpython-serial
fromapt
. - create the following udev file:
KERNEL=="ttyS0", SYMLINK+="serial0" GROUP="tty" MODE="0660"
KERNEL=="ttyAMA0", SYMLINK+="serial1" GROUP="tty" MODE="0660"
and reload your udev rules: sudo udevadm control --reload-rules && sudo udevadm trigger
- change the group of the new serial devices
sudo chgrp -h tty /dev/serial0
sudo chgrp -h tty /dev/serial1
- The devices are now under the tty group. Need to add the user to the tty group and dialout group:
sudo adduser $USER tty
sudo adduser $USER dialout
- update the permissions for group read on the devices
sudo chmod g+r /dev/ttyS0
sudo chmod g+r /dev/ttyAMA0
- reboot
-
1Thanks! You saved my day. I had issues with the serial port probably conflicting with BT on RPi Zero 2W and RPi 3 A+ with Ubuntu Server 20.04. Now it works as expected!Serhii Korol– Serhii Korol2022年01月05日 01:42:05 +00:00Commented Jan 5, 2022 at 1:42
I found how to fix UARTs of raspberry by using another UARTs of raspberry pi 4 because rpi4 has 6 UARTs port .
Example :
- UART0 , UART1 , UART2 , UART3 , UART4 , UART5
My Devices :
- RPI : Raspberry Pi 4 Model B (MASTER)
- OS : Ubuntu Mate 20.04
- SLAVE : Teensy 4.1 (Communicate with raspberry pi 4)
References
You can enable UARTs on RPi4 by editing files /boot/firmware/config.txt and add
dtoverlay=uartx
x is the number of your UARTs
or
Use can use my python script to enable UARTs and testing serial communication
Question (What is path of UARTs):
- /dev/ttyACM0 - /dev/ttyACM5