From nobody Tue Jan 24 19:55:10 2023 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P1d4B4gZbz3bMF2 for ; Tue, 24 Jan 2023 19:55:22 +0000 (UTC) (envelope-from jjrushford@gmail.com) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P1d4B2pBDz3trG for ; Tue, 24 Jan 2023 19:55:22 +0000 (UTC) (envelope-from jjrushford@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-il1-x12b.google.com with SMTP id r19so7548311ilt.7 for ; Tue, 24 Jan 2023 11:55:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hkjfU5Tdk2TZLUFnhUtBgenE1zM1S5z/Id26RzHD8bU=; b=CjQ3KN2vqPq2k3kyBQgyBjkEMCbvvroo9l/vJ8oWaYGYPDtefw6nHLHU7+yIeGpyow 7D0K4F0Y5Rd/Tg3qajBsjG77HE13k4haOuW3MpvnWwlUKhpZH5JgdQEiHinKKjbXtHq5 UkqcUJNTXa4myYY3rvAZ1v1JmfCDC2K8Ym9+jnN6lanUwvPNvn7sviZMdzYulMpfENwi 7hFNg/X5vjudCo7GaAVsCD3mNTTP1fvyGhINFX0vwfET4Y81Ultdjx2ExgOzNnErGIwJ GGh+ha1fTQ/5fz+ZTnagD3kbpLkcuZ05O1VjB9ry/4KFCOq0JaenmOQ8Hm2bOLivXBW/ K2Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hkjfU5Tdk2TZLUFnhUtBgenE1zM1S5z/Id26RzHD8bU=; b=QPbLnPwqUZISe4d8DhKgCxxmqtwWwNDAQyBZJuDxHsYfsZZeR9EmG+dNhny6+fLcyW cI3riHYhtF8seIwo08HMMvsXv7+Qtgg4C4mMONkINb1glExwb4R2HoTHqxx96mnsizZD eWL3K/Xx4OE3uTUmYh7oREFrFsUVJ2oARh9VBLgv0Q/z9BI5MmHUjt+SRVhq73ZT1pk3 naf3bXBVqc++KdVSCUWNpg/Xy2ToqLVm84H7U4xV8KQdCHPibvSTt9Ps41jcYPCD1Zn2 2qvzIoDDQMWRtMKpQK+ZP3BnuPeNrleTcJj11GNnz5H8fNVbQSqIYmTRxRbgdwLUgAK/ YLlQ== X-Gm-Message-State: AFqh2kpsrRjyrZk1TZ8eFSoi4DdbVFF6SQBdVxrliiGo3WUw6+yQws6L PS7Hapm19LgESwm78SCrIygjh9KBPR+oCg== X-Google-Smtp-Source: AMrXdXu3i7Dy6jAKpfr9dNOXg3sAeFhE3x0r8tAwvGy02aezNw4Lf1hV6yqBLxP2IyFsSSMTz3OO4A== X-Received: by 2002:a05:6e02:1ca7:b0:30e:ed6d:ef37 with SMTP id x7-20020a056e021ca700b0030eed6def37mr27466614ill.6.1674590121328; Tue, 24 Jan 2023 11:55:21 -0800 (PST) Received: from smtpclient.apple ([2601:280:587f:1450:84e6:9743:8888:b2e8]) by smtp.gmail.com with ESMTPSA id g16-20020a92d7d0000000b0030c332915aasm916591ilq.49.2023.01.24.11.55.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2023 11:55:20 -0800 (PST) Content-Type: text/plain; charset=utf-8 List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.101.1.3\)) Subject: Re: Testing All 5 Uarts on Raspberry Pi 4B From: John Rushford In-Reply-To: <97c23a36-a98e-f83c-e0e2-02bbeee0fdfe@thegalacticzoo.com> Date: Tue, 24 Jan 2023 12:55:10 -0700 Cc: freebsd-arm@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <97c23a36-a98e-f83c-e0e2-02bbeee0fdfe@thegalacticzoo.com> To: Fred Finster X-Mailer: Apple Mail (2.3731.300.101.1.3) X-Rspamd-Queue-Id: 4P1d4B2pBDz3trG X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N 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 = 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 = >=20 >=20 > Re: Pi-4 Activating additional UART ports > = >=20 > Mon Jan 06, 2020 10:36 am = >=20 > On all Pis, UART0 is a PL011 that appear to Linux as ttyAMA, and = UART1 is an 8250 clone that appears as ttyS0. On a Pi4, UART2-5 are = additional PL011s that also appear as ttyAMA. 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 > */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 >=20 >> On Jan 21, 2023, at 8:18 PM, Mark Millard wrote: >> On Jan 21, 2023, at 18:34, John Rushford = 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 = >=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 = >=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" 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