Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jun 2019 15:06:21 +0100
From:      Kaya Saman <kayasaman@optiplex-networks.com>
To:        Milan Obuch <milan@obuch.sk>
Cc:        freebsd-arm@freebsd.org
Subject:   Re: Pine64-LTS and UART ports
Message-ID:  <d0719fbf-b4d5-aec7-bcad-1a9157b63e69@optiplex-networks.com>
In-Reply-To: <20190624133017.5a9689b7@zeta.dino.sk>
References:  <371fe0f0-9f91-e4ba-ff4e-8338fe9d63de@optiplex-networks.com> <20190623235732.4439b707@zeta.dino.sk> <ae92ac02-ce53-18fe-9eab-8b17e8d52cd2@optiplex-networks.com> <20190624133017.5a9689b7@zeta.dino.sk>

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

On 6/24/19 12:30 PM, Milan Obuch wrote:
> On Mon, 24 Jun 2019 10:59:26 +0100
> Kaya Saman <kayasaman@optiplex-networks.com> wrote:
>
>> On 6/23/19 10:57 PM, Milan Obuch wrote:
>>> On Sun, 23 Jun 2019 21:42:16 +0100
>>> Kaya Saman <kayasaman@optiplex-networks.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d0719fbf-b4d5-aec7-bcad-1a9157b63e69>