FreeBSD 13.1 ARM (Allwinner A20) ... 2nd uart??

Sorry guys, I've trying several days now to get a 2nd uart (first one is console) configured on an FreeBSD 13.1-release installed on a SD Card on a Cubieboard2. Yes, I know, this isn't the newest hardware anymore.. but the problem is similar on olimex, odroid or even raspberry boards.

I can't fiddle out how to tell the kernel that there is a 2nd uart..and I've read many things in the meantime...

there is a sysutils/u-boot-cubieboard2 port for the u-boot, that gets installed at /usr/local/share/u-boot/u-boot-cubieboard2
I've followed the instructions from the README file there and installed the u-boot on the sd-card. The system is running fine so far.
I've patched the /usr/ports/sysutils/u-boot-cubieboard2/work/u-boot-2023.01/arch/arm/dts/sun7i-a20-cubieboard2.dts file as follows:

Code:
--- arch/arm/dts/sun7i-a20-cubieboard2.dts.orig 2023-01-09 17:07:33.000000000 +0100
+++ arch/arm/dts/sun7i-a20-cubieboard2.dts      2023-06-21 18:59:42.198262000 +0200
@@ -55,6 +55,7 @@
 
        aliases {
                serial0 = &uart0;
+               serial1 = &uart2;
        };
 
        chosen {
@@ -221,6 +222,11 @@
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_pb_pins>;
+       status = "okay";
+};
+&uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart2_pi_pins>, <&uart2_cts_rts_pi_pins>;
        status = "okay";
 };
I've copied over the resulting sun7i-a20-cubieboard2.dtb file to /boot/dtb and /boot/msdos/dtb and after an reboot I've got
finally an

Code:
...
uart0: <16750 or compatible> mem 0x1c28000-0x1c283ff irq 49 on simplebus0
uart0: console (115384,n,8,1)
uart1: <16750 or compatible> mem 0x1c28800-0x1c28bff irq 51 on simplebus0
gpioc1: <GPIO controller> on axp2xx_pmu0
..

in the dmesg output, but the resulting device /dev/ttyu1 and /dev/cuau1 seems to be not functional. I've shorted PI18 and PI19 (which should be the corresponding TxD and RxD Pins) and tried to opened the line with kermit, I don't get any echo on cuau1 or ttyu1..
(I know that I have to set an option to enable HW flowcontrol somewhere..but that test should work w/o...)

What I'm missed here?

Edit: Sorry, please ignore for now. I'm an idiot. There is no connector available for PI18 and PI19..after changing the definition of uart3 and the Pins PG6 and 7 things started to work....

Regards,
Holm

Code:
Connecting to /dev/cuau1, speed 9600
 Escape character: Ctrl-X (ASCII 24, CAN): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
?Carrier required but not detected.
***********************************
 Hint: To CONNECT to a serial device that
 is not presenting the Carrier Detect signal,
 first tell C-Kermit to:

   SET CARRIER-WATCH OFF

***********************************

(~/) C-Kermit>set carrier off
(~/) C-Kermit>conn
Connecting to /dev/cuau1, speed 9600
 Escape character: Ctrl-X (ASCII 24, CAN): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
Das ist ein Test
(Back at cubie2)
----------------------------------------------------
(~/) C-Kermit>set baud 57600
/dev/cuau1, 57600 bps
(~/) C-Kermit>conn
Connecting to /dev/cuau1, speed 57600
 Escape character: Ctrl-X (ASCII 24, CAN): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
Das ist noch ein Test......
 
Why are you directly modfying the dtb. You should be using device tree overlays.

You should be using overlays like this:


Are you sure you have the right device names? uart2 is actually UART0 for the system console.

So for an additional UART you want to use an overlay and pins uart3 or greater for a system console port at UART1

The names are screwy. Once you figure that out you will be OK.
 
So the process here is:
Scrape the dts
Compile the dts into dtb with dtc
Place dtb in /boot/dtb/overlays/
Add entry in /boot/loader.conf to initilize device tree overlays at boot. fdt_overlays="your-dtb-name"
 
Please notice in the above overlays that some pins behave differently with regards to services offered over the pins. Some pins are suitable for a serial port and some only uart.

So lets say you pick overlay of UART4. It will still end up on uart1 system port.
FreeBSD simply assigns the next free uart device name regardless of source device name or pins used.
 
My experience here comes from BPi-M1 with A20.
On this board UART7 overlay is used but I still use the same repository as above.
So which UART overlay to use for your board is what you need to investigate.


This is where UART4 came from.
It looks like what you need.
 
I'm using uart3 now with the definition:
Code:
&uart3 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart3_pg_pins>, <&uart3_cts_rts_pg_pins>;
        uart-has-rtscts;
        status = "okay";
};

uart3 Works..but hw flow control not.
I'm using a Cubieboard2 and the console is uart0 (serial0), uart3 uses the Pins PG6,7,8,9.

I have tried to understand what's going on with u-boot and the environment, since the HW is
rater old, I've got mostly outdated things from the web...

>FreeBSD simply assigns the next free uart device name regardless of source device name or pins used.

..that I'm already found out, since uart1 is detected in dmesg, but uart3 should be... at least it is consistent now to the device names, since in the dts file is defined that serial1 is uart3 .. und so ist should be come up as ttyu1..what is does anyways..

I think I've rad somewhere about a neccessary config Value "CONFIGxxxx" for including the code for hardware handshake.. can't find it at the moment...or is that the wrong way?

BTW: I've read about overlays ...shouldn't the have the extension dtbo? is that the same format as dtb?

I'll try to use overlays tomorrow, its 10:31 PM here, enough for today :)

Regards,
Holm
 
shouldn't the have the extension dtbo? is that the same format as dtb?
Either is allowed.
When you scrape an overlay you can use whatever name you wish.

uart1.dts would be fine.

The compiled file can be either dtb or dtbo.
 
Notice UART3 overlay uses pairs(of usable pins).
a and b
Linux has accommodations for the extra info
param_uart4_pins=a
Where FreeBSD might not.

You could edit the DTS and drop the pairs crap.
 
Back
Top