Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Jan 2023 12:55:10 -0700
From:      John Rushford <jjrushford@gmail.com>
To:        Fred Finster <fred@thegalacticzoo.com>
Cc:        freebsd-arm@freebsd.org
Subject:   Re: Testing All 5 Uarts on Raspberry Pi 4B
Message-ID:  <EEEEAF9A-1230-4999-A46D-FAD45CA95177@gmail.com>
In-Reply-To: <97c23a36-a98e-f83c-e0e2-02bbeee0fdfe@thegalacticzoo.com>
References:  <97c23a36-a98e-f83c-e0e2-02bbeee0fdfe@thegalacticzoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Fred,

I=E2=80=99ve updated the bug with the additional data you requested.  I =
have the GPS card wired:

VIN: pin 2, 5v
PPS: GPIO pin 18
GND: pin 5 ground.
RX: pin 4 TXD.   RX of the card is wired to TX on uart3=20
TX: pin 5 RXD.  TX on the card is wired to RX on uart3

FreeBSD shows no incoming data from the card and gpsd there is unable to =
read any data.  pstat -t shows no available data on ttyu1, where is it?

With the same pi and wiring shown above, booted into Debian, incoming =
data is fine from the card.  The gpsd daemon reads the data and I can =
get NTP to use the PPS signal to synchronize the pi clock.

John



> On Jan 24, 2023, at 5:53 AM, Fred Finster <fred@thegalacticzoo.com> =
wrote:
>=20
> TOP POST answer : =
https://forums.raspberrypi.com/viewtopic.php?t=3D244827  Testing of all =
5 UARTS near bottom of this URL link
>=20
> =
https://forums.raspberrypi.com/viewtopic.php?t=3D244827&sid=3D9955627b0e78=
44c752f46b5ae55ef684&start=3D75 Page 4 URL link
>=20
> *I copied and pasted below.  I /apologize in advance for troubles I am =
inflicting on text only email viewers.  I have set my Thunderbird/*
>=20
> */email to send out only text email.   Fred/*
>=20
> FreeBSD creates /dev/ttyu1
>=20
> Sounds like  you need to disable bt???? Adding "dtoverlay=3Ddisable-bt" =
switches the UART roles so that UART0 is mapped to 14 & 15 (Alt0), =
leaving UART1 unmapped.
>=20
>=20
> =
https://forums.raspberrypi.com/viewtopic.php?t=3D244827&sid=3Df4a784a3c40e=
d0940e6fbb9f81af5015&start=3D25#p1590882 =
<https://forums.raspberrypi.com/viewtopic.php?t=3D244827&sid=3Df4a784a3c40=
ed0940e6fbb9f81af5015&start=3D25#p1590882>
>=20
>=20
>     Re: Pi-4 Activating additional UART ports
>     =
<https://forums.raspberrypi.com/viewtopic.php?t=3D244827&sid=3Df4a784a3c40=
ed0940e6fbb9f81af5015&start=3D25#p1590882>
>=20
> Mon Jan 06, 2020 10:36 am =
<https://forums.raspberrypi.com/viewtopic.php?p=3D1590882&sid=3D3091c9b0b9=
8ce61a2a9be011e1ef5386#p1590882>
>=20
> 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.
>=20
> Adding "enable_uart=3D1" to config.txt on a Pi4 enables ttyS0 (UART1) =
on GPIOs 14 & 15 (Alt5), leaving UART0 driving the Bluetooth interface =
on 30-33 (Alt3). Adding "dtoverlay=3Ddisable-bt" switches the UART roles =
so that UART0 is mapped to 14 & 15 (Alt0), leaving UART1 unmapped.
>=20
> As rpdom says, you can only enable one function on any pin at once, =
and enabling the same alternate function (e.g. RXD0) on multiple pins =
usually results in failure (outputs tend to work, inputs don't, but it =
is essentially undefined behaviour).
>=20
> *//*
>=20
> */
> /*
>=20
> */From:/*John Rushford <jjrushford_at_gmail.com>
> */Date:/*Sun, 22 Jan 2023 03:27:38 UTC
>=20
> Mark,
>=20
> Thanks for the reply.  I only have =E2=80=9Cdtoverlay=3Duart3=E2=80=9D =
in the config.txt and with that entry, FreeBSD creates /dev/ttyu1 and =
/dev/cuau1 along with the .init and .lock files.
> So, I tried with this entry in /etc/ttys and it was of no help, still =
no data:
>=20
> 	ttyu1 "none" vt100 on secure
>=20
> thanks
> John
> jjrushford@gmail.com <mailto:jjrushford@gmail.com>
>=20
>> On Jan 21, 2023, at 8:18 PM, Mark Millard <marklmi@yahoo.com> wrote:
>> On Jan 21, 2023, at 18:34, John Rushford <jjrushford@gmail.com> =
wrote:
>>> I have installed FreeBSD 13.1 on a raspberry PI 4b rev 1.4 and I am =
trying to use the additional serial ports that are available with the PI =
4 with an Adafruit ultimate GPS card.
>>> I found that it was problematic using the first serial port ttyu0 on =
GPIO pins 14 and 15 as data on the line from the GPS would interrupt the =
boot process and I verified that I was in fact able see data time stamps =
from the GPS card on the first uart port once I got FreeBSD to boot.
>>> Now since I do not wish to use the first serial port, I=E2=80=99ve =
built the rpi-firmware port and copied all the uart dtb=E2=80=99s to =
/boot/msdos/overlays and I=E2=80=99ve tried enabling the uart=E2=80=99s =
in /boot/msdos/config.txt with =E2=80=9Cdtoverlay=3Duart3=E2=80=9D for =
example.  Enabling them does in fact  result in device entries created =
for them in /dev but, I am unable to see any data on the corresponding =
ttyuX or cuauX ports.
>>> Just to eliminate a wiring error, I installed another SD card with =
Raspberry PI OS, enabled uart3 and I am able to see data on uart3 =
without any issue confirming I have everything wired up properly.
>>> With FreeBSD, I have set the proper baud rate on the ports and =
I=E2=80=99ve tried disabling flow control on them, using stty, but no =
matter what I do, I never see any data on them.  Unless I=E2=80=99m =
missing something, I can only conclude there is some bug in FreeBSD =
preventing me from using these additional serial ports.  Has anyone here =
on this mailing list been able to use them?  If so, what does it take?
>> You did not mention /etc/ttys editing. So I wonder if you
>> changed any of the lines like, say,
>> # Serial terminals
>> # The 'dialup' keyword identifies dialin lines to login, fingerd etc.
>> ttyu0   "/usr/libexec/getty 3wire"      vt100   onifconsole secure
>> ttyu1   "/usr/libexec/getty 3wire"      vt100   onifconsole secure
>> ttyu2   "/usr/libexec/getty 3wire"      vt100   onifconsole secure
>> ttyu3   "/usr/libexec/getty 3wire"      vt100   onifconsole secure
>> to use, say, none instead of "/usr/libexec/getty 3wire", and other
>> related edits.
>> But I've not tried to get any extra serial ports going on
>> an RPi4B. So the above is just guess work about something
>> to experiment with.
>> =3D=3D=3D
>> Mark Millard
>> marklmi at yahoo.com
>=20
> https://forums.raspberrypi.com/viewtopic.php?t=3D244827 Testing All 5 =
Uarts on Raspberry Pi 4B near bottom of this URL link.
>=20
> Question has anybody here on FreeBSD arm mailing list group made some =
or all of the Raspbian Linux Tools operational on FreeBSD? Maybe this is =
a simple recompile with a couple modifications?
>=20
> I should just try myself first.  Just checking that NO ONE ELSE has =
already completed a Tool and is willing to share.
>=20
> raspi-gpio,  rasp-imager,  rasp-config, dtoverlay
>=20
>=20
> I suggest you start by running the following to establish whether the =
configuration has been successful:
>=20
> $ raspi-gpio get 0-15 $ ls /dev/ttyAMA*
>=20
> raspi-gpio get 0-15 GPIO 0: level=3D1 fsel=3D3 alt=3D4 func=3DTXD2 =
pull=3DNONE GPIO 1: level=3D1 fsel=3D3 alt=3D4 func=3DRXD2 pull=3DUP =
GPIO 2: level=3D1 fsel=3D4 alt=3D0 func=3DSDA1 pull=3DUP GPIO 3: level=3D1=
 fsel=3D4 alt=3D0 func=3DSCL1 pull=3DUP GPIO 4: level=3D1 fsel=3D3 alt=3D4=
 func=3DTXD3 pull=3DNONE GPIO 5: level=3D1 fsel=3D3 alt=3D4 func=3DRXD3 =
pull=3DUP GPIO 6: level=3D1 fsel=3D0 func=3DINPUT pull=3DUP GPIO 7: =
level=3D1 fsel=3D0 func=3DINPUT pull=3DUP GPIO 8: level=3D1 fsel=3D3 =
alt=3D4 func=3DTXD4 pull=3DNONE GPIO 9: level=3D1 fsel=3D3 alt=3D4 =
func=3DRXD4 pull=3DUP GPIO 10: level=3D0 fsel=3D0 func=3DINPUT pull=3DDOWN=
 GPIO 11: level=3D0 fsel=3D0 func=3DINPUT pull=3DDOWN GPIO 12: level=3D1 =
fsel=3D3 alt=3D4 func=3DTXD5 pull=3DNONE GPIO 13: level=3D1 fsel=3D3 =
alt=3D4 func=3DRXD5 pull=3DUP GPIO 14: level=3D0 fsel=3D4 alt=3D0 =
func=3DTXD0 pull=3DNONE GPIO 15: level=3D1 fsel=3D4 alt=3D0 func=3DRXD0 =
pull=3DUP pi@raspberrypi:~$ ls /dev/ttyAMA* /dev/ttyAMA0 /dev/ttyAMA1 =
/dev/ttyAMA2 /dev/ttyAMA3 /dev/ttyAMA4
>=20
> config.txt   file contains
>=20
> enable_uart=3D1 dtoverlay=3Dpi3-miniuart-bt dtoverlay=3Duart5 =
dtoverlay=3Duart4 dtoverlay=3Duart3 dtoverlay=3Duart2
>=20
> (The miniuart overlay uses ttyS0 for Bluetooth, freeing /dev/ttyAMA0).
>=20
> The help info shows the GPIOs used by each new UART - 0-3 for UART 2, =
4-7 for 3, 8-11 for 4 and 12-15 for 5. This does mean that UART 5 =
overlaps with the standard UARTs on 14 & 15, but UART 5 has its flow =
control signals there - TXD5 and RXD5 appear on 12 & 13.
>=20
>   I wonder, as GPIO 14 and 15 already used for uart0, how could Uart5
>   flow control use GPIO 14 & 15 ?
>=20
> By not enabling UART0.
>=20
>=20
> I deliberately reversed the order of the UART overlays to demonstrate =
that ordering here makes no difference to the ttyAMA numbering. Using =
this script:
>=20
> Code:Select all =
<https://forums.raspberrypi.com/viewtopic.php?t=3D244827#>;
>=20
> |#!/bin/sh sudo stty -F /dev/ttyAMA0 115200 sudo stty -F /dev/ttyAMA1 =
115200 sudo stty -F /dev/ttyAMA2 115200 sudo stty -F /dev/ttyAMA3 115200 =
sudo stty -F /dev/ttyAMA4 115200 while true; do sudo sh -c "echo 0 > =
/dev/ttyAMA0" sudo sh -c "echo 1 > /dev/ttyAMA1" sudo sh -c "echo 2 > =
/dev/ttyAMA2" sudo sh -c "echo 3 > /dev/ttyAMA3" sudo sh -c "echo 4 > =
/dev/ttyAMA4" sleep 1 done |
>=20
> and moving my PC serial cable around the pins I found the following =
mapping:
>=20
> Code:Select all =
<https://forums.raspberrypi.com/viewtopic.php?t=3D244827#>;
>=20
> |GPIO14 =3D TXD0 -> ttyAMA0 GPIO0 =3D TXD2 -> ttyAMA1 GPIO4 =3D TXD3 =
-> ttyAMA2 GPIO8 =3D TXD4 -> ttyAMA3 GPIO12 =3D TXD5 -> ttyAMA4 |
>=20
> In other words, transmitting works on all 5 PL011/ttyAMA UARTs.
>=20
> Running "cat /dev/ttyAMA<x>" on each of the different UARTs in turn =
and moving the TX pin of the PC serial port around the various RXD pins =
produced the RX mapping:
>=20
> Anyone know of Top Hats for a Raspberry Pi 4 that brings all 5 uarts =
to a 3.3V TTL level and drive some LEDs to see TX and RX activity, plus =
MAX232 style drivers to shift
>=20
> from 3.3 Volt level to + - ~10V RS-232 drive level to a DB-9 IBM =
compatible D shell Connector?  With possibly a RS-485 driver style =
connection for long wiring runs?
>=20
> Does this exist?  or  Should one fire up KiCAD and design such a board =
specifically for Raspberry Pi 4B 5 uarts?  Probably a market size of 10 =
- 50 boards world wide, not much?
>=20
> Hope this works for you John R.
>=20
> --=20
> Fred  Finster
> fred@thegalacticzoo.com
> +1 971-718-9144
> https://GhostBSD-ARM64.blogspot.com
> https://ghostbsd.org
>=20
>=20




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?EEEEAF9A-1230-4999-A46D-FAD45CA95177>