I'm trying to connect a GPS module to my RPI4B via an additional serial port, but it doesn't work for me.
I have connected loopbacks on 8&10, 21&24, 32&33 pins and configured my system as followed...
/boot/msdos/config.txt:
After my system is rebooted I had got three devices /dev/ttyu0, /dev/ttyu1 and /dev/ttyu2 and
I tested uarts working with the following script (got it from somewhere on the internet)
...and got...
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?
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
/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
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
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
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?