4

I have Ubuntu 20.04 (32 bit) installed on RPI4 (4GB). I have loopback wire installed on Pin 8,10.

I need to use Bluetooth and also basic serial communication over Pin 8,10 to communicate with a Roboclaw motor controller.

Did install RASPI-CONFIG on Ubuntu using script at https://github.com/EmilGus/install_raspi-config but even though it installed successfully it loads with improper boot configuration error. That led me to /boot/firmware directory where I found config.txt, cmdline.txt etc. I removed the console=...

$ dmesg | grep tty
[    0.001061] printk: console [tty0] enabled
[    1.919367] fe201000.serial: ttyAMA0 at MMIO 0xfe201000 (irq = 29, base_baud = 0) is a PL011 rev2
[    1.924677] fe215040.serial: ttyS0 at MMIO 0x0 (irq = 31, base_baud = 62500000) is a 16550

So doesn't look like I disabled the console. How do I do that?

$ ls -l /dev/ttyS[0123]
crw-rw---- 1 root dialout 4, 64 Jun 27 12:32 /dev/ttyS0
$ ls -l /dev/serial
lrwxrwxrwx 1 root root 7 Apr  1 11:23 /dev/serial1 -> ttyAMA0

Second when I run sudo minicom -b 115200 -o -D /dev/ttyS0 (with loopback in place - verified correctly installed)

I see no characters. No verification of communication with serial.

Tried to change baud, parity, flow control settings with no effect.

Also have a simple serial test python which also fails to send/receive over serial at /dev/ttyS0 whether I run with sudo or without.

UPDATE I got an updated install script (same github link above) and now have successfully installed RASPI-CONFIG, however while I can run it the directory structure on the RPi4 w/ Ubuntu 20.04 is different enough that it fails to find the config files it tries to change.

$ sudo raspi-config
grep: /boot/cmdline.txt: No such file or directory
sed: can't read /boot/cmdline.txt: No such file or directory
sed: can't read /boot/cmdline.txt: No such file or directory

I presume that are other Raspberry Pi 4 owners who intend to use the serial port and there's got to be a way to do what RASPI-CONFIG is trying to do on Ubuntu.

I've found the files in /boot/firmware

What should I change manually in them that RASPI-CONFIG would do via script?

3
  • Hi! Are you sure the port is enabled? It's disabled by default. I think you can do these things with the raspi-config command. Have you tried it? Unfortunately I don't have a Raspberry-PI here myself so I can't test. Have a look here: raspberrypi.org/documentation/configuration/uart.md
    – Rein
    Jun 29, 2020 at 19:26
  • Have confirmed have enable_uart=1 in config.txt and and have a working version of RASPI-CONFIG which claims to set the serial port correctly but still no communication over pins 8.10
    – BenignFun
    Jul 16, 2020 at 19:52
  • @BenignFun did you solved the problem? i stucked with same as yours...
    – Analysis
    Nov 7, 2020 at 6:00

5 Answers 5

5

I had a bunch of trouble talking to a roboclaw motor on an rpi4 (model B) under Ubuntu 20.04 (64 bit). I was able to resolve it, though I had to disable Bluetooth to get there. Unfortunately, I'm not sure at this point how to get there without disabling Bluetooth. Reader beware.

Confirmed this works with 5 roboclaw motor controllers on the same serial bus.

That said, here's how I did it (note that this is cliffsnotes of this procedure):

  1. Disable [email protected]
    sudo systemctl stop [email protected]
    sudo systemctl disable [email protected]
    sudo systemctl mask [email protected]
    
  2. Setup udev rules
    • put below content in new file /etc/udev/rules.d/10-local.rules
      KERNEL=="ttyS0", SYMLINK+="serial0" GROUP="tty" MODE="0660"
      KERNEL=="ttyAMA0", SYMLINK+="serial1" GROUP="tty" MODE="0660"
      
    • Reload udev rules: sudo udevadm control --reload-rules && sudo udevadm trigger
  3. Add user to tty group: sudo adduser ubuntu tty
  4. Delete substring console=serial0,115200 from /boot/firmware/cmdline.txt
  5. Add newline dtoverlay=disable-bt to /boot/firmware/config.txt (I put it right under the cmdline=cmdline.txt line)
  6. Restart
  7. (Optional) Feel free to test with this script: https://github.com/nasa-jpl/osr-rover-code/blob/foxy-devel/scripts/roboclawtest.py

Note that after this set up, you need to use ttyAMA0 (or alias serial1), not ttyS0. The first uses the full hardware UART, the second uses a "mini-UART" implementation that seems to not work so well under Ubuntu 20.04 (at least with the roboclaw, in my hardware setup. YMMV.). Some more discussion here on GitHub.

2

I have a setup using both Bluetooth/hci0 and the miniUART/ttyS0 at the same time with Ubuntu 20.04 (Ubuntu 5.4.0-1034.37-raspi 5.4.101) 64bit on Raspberry Pi 4 Model B Rev 1.1 (4G memory). Here is what I did:

  1. Back up the original config.txt and cmdline.txt files

    sudo cp -pr /boot/firmware/cmdline.txt /boot/firmware/cmdline.txt-orig
    sudo cp -pr /boot/firmware/config.txt /boot/firmware/config.txt-orig
    
  2. Edit /boot/firmware/config.txt to comment out the enable_uart=1 like below,

    #enable_uart=1
    
    cmdline=cmdline.txt
    
  3. Remove the console setting console=serial0,115200 from /boot/firmware/cmdline.txt

  4. Disable the Serial Service which used the miniUART

    sudo systemctl stop [email protected]
    sudo systemctl disable [email protected]
    sudo systemctl mask [email protected]
    
  5. Add the user which will use the miniUART to tty and dialout group

    sudo adduser ${USER} tty
    sudo adduser ${USER} dialout
    
  6. Finally, reboot Ubuntu 20.04, then both hci0 and /dev/ttyS0 can work at the same time for me.

Detailed documentation about the UART can be found at https://www.raspberrypi.org/documentation/configuration/uart.md

0

A simple solution is to use a USB to TTL Adapter to connect the roboclaw to a USB on the pi rather than UART GPIO pins. This will work out of the box without the need for config changes on the pi other than specifying the USB port in the roboclaw driver code. In my experience it is best to use a SiLabs CP2012 based USB to TTL adaptor (as for example sold by adafruit or available on amazon ) as that chipset is widely supported on linux and other OS'es and certainly on Ubuntu does not need custom drivers.

0

On my system (Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-1044-raspi aarch64)) , I followed @user1502422 steps to enable UART and Bluetooth:

Back up the original config.txt and cmdline.txt files

sudo cp -pr /boot/firmware/cmdline.txt /boot/firmware/cmdline.txt-orig sudo cp -pr /boot/firmware/config.txt /boot/firmware/config.txt-orig Edit /boot/firmware/config.txt to comment out the enable_uart=1 like below,

#enable_uart=1

cmdline=cmdline.txt Remove the console setting console=serial0,115200 from /boot/firmware/cmdline.txt

Disable the Serial Service which used the miniUART

sudo systemctl stop [email protected] sudo systemctl disable [email protected] sudo systemctl mask [email protected] Add the user which will use the miniUART to tty and dialout group

sudo adduser ${USER} tty sudo adduser ${USER} dialout Finally, reboot Ubuntu 20.04, then both hci0 and /dev/ttyS0 can work at the same time for me.

However, in my /boot/firmware/config.txt I added dtoverlay=miniuart-bt and did not comment out enable_uart=1, see here:

dtoverlay=miniuart-bt
enable_uart=1

Note: I would have added this as a comment but i can't.

-1

exactly the same problem I also have. A workaround for the wrong path of the raspi-config script may be a softlink like

ln -s /boot/firmware/cmdline.txt /boot/cmdline.txt

But this doesn't solve the origin problem. I'm sorry.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .