From owner-freebsd-arm@freebsd.org Mon Jun 24 14:06:25 2019 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5563F15CE568 for ; Mon, 24 Jun 2019 14:06:25 +0000 (UTC) (envelope-from kayasaman@optiplex-networks.com) Received: from x-ray.optiplex-networks.com (mail.optiplex-networks.com [212.159.80.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 029C46F99E for ; Mon, 24 Jun 2019 14:06:23 +0000 (UTC) (envelope-from kayasaman@optiplex-networks.com) Received: from localhost (localhost [127.0.0.1]) by x-ray.optiplex-networks.com (Postfix) with ESMTP id C7542721FC4; Mon, 24 Jun 2019 15:06:21 +0100 (BST) Received: from x-ray.optiplex-networks.com ([127.0.0.1]) by localhost (x-ray.optiplex-networks.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id tKlDkJUnpQQN; Mon, 24 Jun 2019 15:06:21 +0100 (BST) Received: from localhost (localhost [127.0.0.1]) by x-ray.optiplex-networks.com (Postfix) with ESMTP id 6FDCC72C7A3; Mon, 24 Jun 2019 15:06:21 +0100 (BST) X-Virus-Scanned: amavisd-new at x-ray.optiplex-networks.com Received: from x-ray.optiplex-networks.com ([127.0.0.1]) by localhost (x-ray.optiplex-networks.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id EcwCHvpMom4M; Mon, 24 Jun 2019 15:06:21 +0100 (BST) Received: from x220.optiplex-networks.com (unknown [192.168.0.192]) by x-ray.optiplex-networks.com (Postfix) with ESMTPSA id 5DD69721FC4; Mon, 24 Jun 2019 15:06:21 +0100 (BST) Subject: Re: Pine64-LTS and UART ports To: Milan Obuch Cc: freebsd-arm@freebsd.org References: <371fe0f0-9f91-e4ba-ff4e-8338fe9d63de@optiplex-networks.com> <20190623235732.4439b707@zeta.dino.sk> <20190624133017.5a9689b7@zeta.dino.sk> From: Kaya Saman Message-ID: Date: Mon, 24 Jun 2019 15:06:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <20190624133017.5a9689b7@zeta.dino.sk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 029C46F99E X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of kayasaman@optiplex-networks.com designates 212.159.80.20 as permitted sender) smtp.mailfrom=kayasaman@optiplex-networks.com X-Spamd-Result: default: False [-3.95 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MX_GOOD(-0.01)[cached: mail.optiplex-networks.com]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.91)[-0.912,0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6871, ipnet:212.159.64.0/18, country:GB]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_COUNT_FIVE(0.00)[6]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[optiplex-networks.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; IP_SCORE(-0.73)[asn: 6871(-3.58), country: GB(-0.09)] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jun 2019 14:06:25 -0000 On 6/24/19 12:30 PM, Milan Obuch wrote: > On Mon, 24 Jun 2019 10:59:26 +0100 > Kaya Saman wrote: > >> On 6/23/19 10:57 PM, Milan Obuch wrote: >>> On Sun, 23 Jun 2019 21:42:16 +0100 >>> Kaya Saman wrote: >>> =20 >>>> Hi, >>>> >>>> I've attached an RS232c converter board to UART2 on my Pine64-LTS >>>> board. I followed the pinout diagrams from here: >>>> =20 >>> [ snip - no comment on this all ] >>> =20 >>>> Based on my reading I created a 'hints' file for it: >>>> >>>> /boot/device.hints >>>> hint.uart.2.disabled=3D"0" >>>> >>>> but I'm not sure if this is correct? >>>> =20 >>> Hi, >>> >>> short comment - in arm world, there is no device.hints file used, >>> it is moved into dtb file. You should use overlay to enable uart2, >>> which will then be used in /boot/loader.conf file - there should be >>> line >>> >>> fdt_overlays=3D"sun50i-a64-sid,sun50i-a64-ths,sun50i-a64-timer,sun50i= -a64-opp" >>> >>> I did not tried it myself yet, so I can't write exactly what to use, >>> important part in dtso file you should create is >>> >>> &uart2 { status =3D "okay"; >>> } >>> >>> because uart2 is disabled in shipped dtb. Look in dts overlays >>> directories for some examples, maybe you could search in this >>> mailing list archive, too... or someone with more knowledge could >>> tell more. >>> >>> Regards, >>> Milan >> >> Thanks Milan for the tip!! >> >> >> I am now going through these links: >> >> https://forums.freebsd.org/threads/fdt-overlays-in-freebsd.52530/ >> >> http://freebsd.1045724.x6.nabble.com/Allwinner-dtb-overlays-on-CURRENT= -Also-flashrom-SPI-td6271021.html >> >> >> There doesn't seem to be too much information on how to create the >> Overlays. I found the .dtso files in the /usr/src/sys directory so I >> am guessing that one needs to compile the Overlays into the kernel? >> > In order to create an overlay, I found simple way to do it using > antrastructure already presented in out source tree... > > First, you need to create overlay source file. Other overlays for arm64 > devices are located in /usr/src/sys/dts/arm64/overlays directory, so I > put sun50i-a64-uart2.dtso file there too. See attachment - all it does > is just enabling uart2. Everything else is already present in dtb. > > Then you need compile this overlay. You could invoke dtc manually, it > is not hard, but easier is using infrastructure - I just did > > cd /usr/src/sys/dts/arm64/overlays > make > > and all overlays are created. Observe the output messages. > > Now you need to install overlay for uart2. > > cp /tmp/sun50i-a64-uart2.dtbo /boot/dtb/overlays/ > > I compared files in /tmp and /boot/dtb/overlays directories just to be > sure I am not far off, all corresponding files were the same size. > > Last step, activate this overlay. In /boot/loader.conf, change line > > fdt_overlays=3D"sun50i-a64-sid,sun50i-a64-ths,sun50i-a64-timer,sun50i-a= 64-opp" > > to > > fdt_overlays=3D"sun50i-a64-sid,sun50i-a64-ths,sun50i-a64-timer,sun50i-a= 64-opp,sun50i-a64-uart2" > > That's it. Now reboot. You should see > > applying DTB overlay '/boot/dtb/overlays/sun50i-a64-uart2.dtbo' > > message on the very start of boot process, and later > > uart1: <16750 or compatible> mem 0x1c28800-0x1c28bff irq 33 on simplebu= s0 > uart1: fast interrupt > uart1: PPS capture mode: DCD > > After boot finishes, you should find now /dev/cuau1 file in addition > to /dev/cuau0 present from the start. You should be able to use > > cu -l /dev/cuau1 -s 115200 > > (or other speed as necessary) to communicate with device connected to > uart2 port. Notice the numbering - as we did not enable physical uart1 > port, it is skipped when attaching drivers, so physical port uart2 is > numbered as uart1 device, thus creating cuau1 entry in dev directory. > If you decide to use physical port uart1, exactly the same method > should work, then numbering devices and physical ports would match. > > Hope this helps. It is not rocket science, and if all you need is just > enable the device already present in dtb with right bindings, it is > really simple. Yep, I think I have a handle on things now. I will try this soon :-)=20 Many thanks for this! > > One additional note - in your original mail you are mentioning PPS_SYNC > in kernel. Off top of my head, if you would like to connect GPS > receiver with PPS output to get precise time source, you need either > serial port with modem control lines or an additional GPIO pin. I did > not look for the details, but I think uart2 port on Pine is just three > wires, so the latter is actually the case, and you need gpiopps driver > as well. I did not work with this yet, so I can't comment on this > issue. Just pointer to another overlay source: > > https://github.com/raspberrypi/linux/blob/rpi-4.9.y/arch/arm/boot/dts/o= verlays/pps-gpio-overlay.dts > > Regards, > Milan Yes, the GPS receiver will connect to the CTS port on UART2. From the=20 link in my original post that is Pin E27 on the Euler bus. I have currently tested this with the USB serial adapter (yes high=20 latency but just for testing), from the ucom man page: =A0=A0=A0=A0=A0=A0=A0=A0 1=A0=A0=A0=A0 Capture pulses on the CTS line. =A0=A0=A0=A0=A0=A0=A0=A0 2=A0=A0=A0=A0 Capture pulses on the DCD line. So then it is just a matter of adding: hw.usb.ucom.pps_mode=3D1 into the=20 /boot/loader.conf. Of course this is for USB ;-) Regards, Kaya