RPI4 additional serial ports do not work

I'm trying to connect a GPS module to my RPI4B via an additional serial port, but it doesn't work for me.
Bash:
[root@rhino /]# uname -a
FreeBSD rhino.xxx 13.0-STABLE FreeBSD 13.0-STABLE #0 stable/13-n249182-6f840e49af37: Sun Jan 30 01:48:22 +04 2022     root@xxx:/usr/obj/usr/src/arm64.aarch64/sys/RPI4_RHINO  arm64
I have connected loopbacks on 8&10, 21&24, 32&33 pins and configured my system as followed...
/boot/msdos/config.txt:
INI:
dtparam=audio=on,i2c_arm=on,spi=off,uart1=off
gpio=2,3=a0
dtoverlay=uart4
dtoverlay=uart5
gpio=8,9,12,13=a4
enable_uart=1
After my system is rebooted I had got three devices /dev/ttyu0, /dev/ttyu1 and /dev/ttyu2 and dmesg records:
Bash:
[root@rhino /]# dmesg | grep uart
uart0: <PrimeCell UART (PL011)> mem 0x7e201000-0x7e2011ff irq 16 on simplebus0
uart1: <PrimeCell UART (PL011)> mem 0x7e201800-0x7e2019ff irq 44 on simplebus0
uart2: <PrimeCell UART (PL011)> mem 0x7e201a00-0x7e201bff irq 45 on simplebus0
I tested uarts working with the following script (got it from somewhere on the internet)

Python:
import serial
import time
test_string = "[serial port test]".encode('utf-8')
port_list = ["/dev/ttyu0", "/dev/ttyu1", "/dev/ttyu2" ]
for port in port_list:
  ok = False
  try:
    buff = bytearray(len(test_string))
    serialPort = serial.Serial(port, 115200, timeout = 2, writeTimeout = 2)
    bytes_sent = serialPort.write(test_string)
    time.sleep(1)
    bytes_read = serialPort.readinto(buff)
    ok = bytes_read == bytes_sent
    serialPort.close()
  except IOError:
    pass
  print("port %s is %s" % (port, "OK" if ok else "NOT OK"))

...and got...
Bash:
[root@rhino /]# ~/src/uart_loopback.py
port /dev/ttyu0 is OK
port /dev/ttyu1 is NOT OK
port /dev/ttyu2 is NOT OK
Of course I also tested this with a real GPS module connected and it only worked on uart0(1). I see NMEA strings when the module is connected to pins 8 and 10 but
see nothing when it connected to pins 24 and 21 nor pins 32 and 33.

What did I wrong or what I maybe forgot to do?
 
Did you download rpi-firmware package for the overlays?
Have you tried moving the overlay settings to /boot/loader.conf ?

When adding a 4 port serial card to FreeBSD I must edit /boot/device.hints on amd64.
 
Yes I installed the sysutils/rpi-firmware (as a package), copied overlays "uart4.dtbo" and "uart5.dtbo" to "/boot/msdos/overlays" and load them via /boot/msdos/config.txt (that way I can set the option "ctsrts" in the next step).
And as a result I got their device drivers in devfs but no data exchanges through them. Moreover, when I inaccuratelly touch the wires I expect to see some digital noise in the terminal windows but I see nothing.
I believe that this make no difference how to load overlays, from loader.conf or from config.txt, but I'll try to load them the way You suggest.

About /boot/device.hints, the "aarch64" has an FDT and onboard uarts are already defined in the FDT for RPI4 (The overlays mostly set "status = 'okay'"). I think, why would be need to define them once more by the "hints"?
 
Alas, no miracle happened... Moving uart overlay loading from /boot/msdos/config.txt to /boot/loader.conf didn't get uart4 or uart5 to work for me.
Tried to add the "bootdelay=-2" option to /boot/msdos/uEnv.txt but without success too, the system booting stops when uart0 receives any data.

Keeping look for something that could allow me to boot RPI4 with active GPS. If this even possible without using, erm... a bistable self-locking trigger (works good for about 5-7 years on RPI2)?
 
I just bought some GPS modules for Hummingboard and I will share my work when I get them.
 
Back
Top