Pine64-LTS and UART ports
Milan Obuch
milan at obuch.sk
Mon Jun 24 11:30:22 UTC 2019
On Mon, 24 Jun 2019 10:59:26 +0100
Kaya Saman <kayasaman at 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 at optiplex-networks.com> 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
-------------- next part --------------
/dts-v1/;
/plugin/;
/ {
compatible = "allwinner,sun50i-a64";
};
&uart2 {
status = "okay";
};
More information about the freebsd-arm
mailing list