From owner-freebsd-arm@freebsd.org Mon Jun 24 11:30:21 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 B710415CA888 for ; Mon, 24 Jun 2019 11:30:21 +0000 (UTC) (envelope-from milan@obuch.sk) Received: from mailhost.netlabit.sk (mailhost.netlabit.sk [84.245.65.72]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F95C6AD1F for ; Mon, 24 Jun 2019 11:30:20 +0000 (UTC) (envelope-from milan@obuch.sk) Received: from zeta.dino.sk (fw3.dino.sk [84.245.95.254]) (AUTH: LOGIN milan) by mailhost.netlabit.sk with ESMTPA; Mon, 24 Jun 2019 13:30:17 +0200 id 00DD6324.5D10B449.0000D9DC Date: Mon, 24 Jun 2019 13:30:17 +0200 From: Milan Obuch To: Kaya Saman Cc: freebsd-arm@freebsd.org Subject: Re: Pine64-LTS and UART ports Message-ID: <20190624133017.5a9689b7@zeta.dino.sk> In-Reply-To: References: <371fe0f0-9f91-e4ba-ff4e-8338fe9d63de@optiplex-networks.com> <20190623235732.4439b707@zeta.dino.sk> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; i386-portbld-freebsd11.2) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_mailhost.netlabit.sk-55772-1561375817-0001-2" X-Rspamd-Queue-Id: 7F95C6AD1F X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of milan@obuch.sk designates 84.245.65.72 as permitted sender) smtp.mailfrom=milan@obuch.sk X-Spamd-Result: default: False [-3.72 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MV_CASE(0.50)[]; HAS_ATTACHMENT(0.00)[]; MX_GOOD(-0.01)[cached: mail.obuch.sk]; CTYPE_MIXED_BOGUS(1.00)[]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+]; ASN(0.00)[asn:16160, ipnet:84.245.64.0/18, country:SK]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; DMARC_NA(0.00)[obuch.sk]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[72.65.245.84.list.dnswl.org : 127.0.10.0]; IP_SCORE(-1.94)[ip: (-6.33), ipnet: 84.245.64.0/18(-3.17), asn: 16160(-0.26), country: SK(0.07)]; RCVD_COUNT_TWO(0.00)[2] 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 11:30:22 -0000 This is a MIME-formatted message. If you see this text it means that your E-mail software does not support MIME-formatted messages. --=_mailhost.netlabit.sk-55772-1561375817-0001-2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline 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: > > > >> Hi, > >> > >> I've attached an RS232c converter board to UART2 on my Pine64-LTS > >> board. I followed the pinout diagrams from here: > >> > > [ snip - no comment on this all ] > > > >> Based on my reading I created a 'hints' file for it: > >> > >> /boot/device.hints > >> hint.uart.2.disabled="0" > >> > >> but I'm not sure if this is correct? > >> > > 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="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 = "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="sun50i-a64-sid,sun50i-a64-ths,sun50i-a64-timer,sun50i-a64-opp" to fdt_overlays="sun50i-a64-sid,sun50i-a64-ths,sun50i-a64-timer,sun50i-a64-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 simplebus0 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. 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/overlays/pps-gpio-overlay.dts Regards, Milan --=_mailhost.netlabit.sk-55772-1561375817-0001-2 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=sun50i-a64-uart2.dtso /dts-v1/; /plugin/; / { compatible = "allwinner,sun50i-a64"; }; &uart2 { status = "okay"; }; --=_mailhost.netlabit.sk-55772-1561375817-0001-2--