2

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?

BenignFun
  • 21
  • 1
  • 1
  • 2
  • 2
    If 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 Jul 15 '20 at 17:32
  • 1
    What are you actually trying to connect to via serial? – CoderMike Jul 15 '20 at 20:47
  • 1
    Using 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 Jul 15 '20 at 22:18

2 Answers2

7

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 serial-getty@ttyS0.service && sudo systemctl disable serial-getty@ttyS0.service
  • make sure you have pyserial installed if you're using the python serial library, not python-serial from apt.
  • 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
achille
  • 171
  • 4
  • 1
    Thanks! 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 Jan 05 '22 at 01:42
0

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
REZIER
  • 1
  • 1