Re: Enabling Raspberry Pi 4B Uarts, specifically uart3

From: John Rushford <jjrushford_at_gmail.com>
Date: Tue, 24 Jan 2023 18:43:56 UTC
Fred,

Looking at the pstat -t output, I see no data available on ttyu1.  I know that there is data coming from the GPS card as
I can see it when I switch OS to Debian.  This confirms the problem though with the additional uarts.

pstat -t
      LINE   INQ  CAN  LIN  LOW  OUTQ  USE  LOW   COL  SESS  PGID STATE
     ttyu0 23040    0    0 2304 23064    0 2307     7  1167  1167 ICOil
     ttyu1     0    0    0    0     0    0    0     4     0     0 IC
     ttyv0  1920    0    0  192  1984    0  199     7  1159  1159 Oil
     ttyv1  1920    0    0  192  1984    0  199     7  1160  1160 Oil
     ttyv2  1920    0    0  192  1984    0  199     7  1161  1161 Oil
     ttyv3  1920    0    0  192  1984    0  199     7  1162  1162 Oil
     ttyv4  1920    0    0  192  1984    0  199     7  1163  1163 Oil
     ttyv5  1920    0    0  192  1984    0  199     7  1164  1164 Oil
     ttyv6  1920    0    0  192  1984    0  199     7  1165  1165 Oil
     ttyv7  1920    0    0  192  1984    0  199     7  1166  1166 Oil
     ttyv8     0    0    0    0     0    0    0     0     0     0 -
     ttyv9     0    0    0    0     0    0    0     0     0     0 -
     ttyva     0    0    0    0     0    0    0     0     0     0 -
     ttyvb     0    0    0    0     0    0    0     0     0     0 -
     pts/0  7680    0    0  768  7688    0  769     0  1336  1420 Oi
     pts/1  7680    0    0  768  7688    0  769    36  1380  1380 Oi


On Jan 24, 2023, at 10:11 AM, John Rushford <jjrushford@gmail.com> wrote:
> 
> Fred,
> 
> This is my /boot/loader.conf.  After rebooting, no change and no data on uart3.  BTW, FreeBSD does 
> not create a /dev/ttyU1.  From the config.txt with dtoverlay=uart3, FreeBSD creates a /dev/ttyu1
> 
> ucom_load="YES"
> umodem_load="YES"
> usb_template_load="YES"
> hw.usb.template=3
> umodem_load="YES"
> umodem_load="YES"
> # Multiple console (serial+efi gop) enabled.
> boot_multicons="YES"
> boot_serial="YES"
> # Disable the beastie menu and color
> beastie_disable="YES"
> loader_color="NO"
> kern.vty=vt
> gpiopps_load="YES"This is my /boot/loader.conf:
> 
> /boot/msdos/config.txt:
> 
> cat msdos/config.txt:
> 
> [all]
> arm_64bit=1
> dtparam=audio=on,i2c_arm=on,spi=on
> dtoverlay=mmc
> dtoverlay=disable-bt
> device_tree_address=0x4000
> kernel=u-boot.bin
> dtoverlay=pps-gpio,gpiopin=18
> dtoverlay=uart3
> enable_uart=1
> 
> [pi4]
> # hdmi_safe=1
> armstub=armstub8-gic.bin
> 
> # dmesg|grep uart
> uart0: <PrimeCell UART (PL011)> mem 0x7e201000-0x7e2011ff irq 16 on simplebus0
> uart0: console (115200,n,8,1)
> uart1: <PrimeCell UART (PL011)> mem 0x7e201600-0x7e2017ff irq 43 on simplebus0
> 
> The memory address 0x7e201600 corresponds to that assigned to uart3 in: src/freebsd-src/sys/contrib/device-tree/src/arm/bcm2711.dtsi 
> 
> Still no data seen
> 
> thanks
> John Rushford
> 
> 
>> On Jan 24, 2023, at 6:09 AM, Fred Finster <fred@thegalacticzoo.com> wrote:
>> 
>> */
>> /*
>> 
>> */From:/*<bugzilla-noreply_at_freebsd.org>
>> */Date:/*Sun, 22 Jan 2023 21:36:36 UTC
>> 
>> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269104
>> 
>>           Bug ID: 269104
>>          Summary: The uarts2 - uarts5 do not function on raspberry pi 4B
>>          Product: Base System
>>          Version: 13.1-RELEASE
>>         Hardware: arm64
>>               OS: Any
>>           Status: New
>>         Severity: Affects Only Me
>>         Priority: ---
>>        Component: arm
>>         Assignee: freebsd-arm@FreeBSD.org
>>         Reporter: jjrushford@gmail.com
>> 
>> I’ve tried using the additional serial ports that are available with a
>> raspberry pi 4B by enabling them in config.txt and when I try to read data on
>> them, I see nothing.
>> 
>> Specifically, I’ve wired an Adafruit ultimate GPS to uart3, gpio pins 4 and 5.
>> I’ve built the RPI-firmware port and copied the uart0-5 dtb’s  to
>> /boot/msdos/overlays.  I then enable uart3 in /boot/msdos/config.txt with
>> dtoverlay=uart3 and reboot. After boot, I see that FreeBSD has created
>> /dev/ttyu1 and /dev/cuau1 in the dev tree for uart3.  When I try reading from
>> ttyu1 or cuau1, I do not see any data whatsoever.  I’ve set the baud rate to
>> 9600 and disabled flow control but still no data is seen.  If I change the
>> wiring to use ttyu0, gpio pins 14 and 15, I do see data there.
>> 
>> Just to verify the hardware, I installed a different SD card with raspberry pi
>> OS, Debian, and enabled uart3 in config.txt.  When I read the /dev/ttyAMA1 I do
>> see the NMEA time stamps coming in uart3 at 9600 baud with no issue.  Next I
>> reboot back to FreeBSD 13.1, I cannot see any data from The GPS card on ttyu1
>> or cuau1.
>> 
>> -- 
>> You are receiving this mail because:
>> You are the assignee for the bug.
>> 
>> In the aarch64 arm64 Raspberry Pi FreeBSD, maybe you need to enable some kernel modules
>> kldstat
>> kldload ucom umodem usb_template
>> sysctl hw.usb.template=3
>> 
>> add in file /boot/loader.conf
>> 
>> ucom_load="YES"
>> umodem_load="YES"
>> usb_template_load="YES"
>> hw.usb.template=3
>> 
>> 
>> *cu -s 9600 -l /dev/ttyU1 What do you see? or rather cu? :>)  Do report back success or failure or changes necessary to make work, please. *https://forums.raspberrypi.com/viewtopic.php?t=244827&sid=f4a784a3c40ed0940e6fbb9f81af5015&start=25#p1590882  <https://forums.raspberrypi.com/viewtopic.php?t=244827&sid=f4a784a3c40ed0940e6fbb9f81af5015&start=25#p1590882>
>> 
>> 
>>    Re: Pi-4 Activating additional UART ports
>>    <https://forums.raspberrypi.com/viewtopic.php?t=244827&sid=f4a784a3c40ed0940e6fbb9f81af5015&start=25#p1590882>
>> 
>> Mon Jan 06, 2020 10:36 am <https://forums.raspberrypi.com/viewtopic.php?p=1590882&sid=3091c9b0b98ce61a2a9be011e1ef5386#p1590882>
>> 
>> On all Pis, UART0 is a PL011 that appear to Linux as ttyAMA<n>, and UART1 is an 8250 clone that appears as ttyS0. On a Pi4, UART2-5 are additional PL011s that also appear as ttyAMA<n>. The number starts at 0 for the first enabled PL011 and counts up through all the enabled interfaces. The numbering is stable for any given combination of UARTs, but enabling or disabling one can change the number assignments of others.
>> 
>> /PL011 appear to FreeBSD/*as /dev/ttyUx   So I wonder if one has to enable ucom and umodem and usb_template to view serial data comming back over what looks like a USB to serial interface?  Your thoughts? https://ghostbsd-arm64.blogspot.com/2023/01/hookup-gdb-to-black-magic-probe-v23.html *
>> 
>> My setup trying to connect to USB serial port under X86_64 FreeBSD 13 to a Black Magic Probe
>> 
>> 
>> -- 
>> Fred  Finster
>> fred@thegalacticzoo.com
>> +1 971-718-9144
>> https://GhostBSD-ARM64.blogspot.com
>> https://ghostbsd.org
>> 
>