Hi, in the last weeks I'been trying to use the serial ports 5 and 6 (tty5, tty6) of the cubieboard2 using DTB but still not working.
First of all, I must said that i'm not a linux expert, only a linux user with some experience and all the information below is the result of multiple weeks of internet research.
for the moment i'm able to get the cubieboard2 to recognize the ports, and using a c++ program I write on all serial ports, i get a response from tty0 but can't get the gio pins of the serial ports 5 and 6 to work.
here is what I have done so far:
first, I downloaded the device tree compiler
sudo apt-get install device-tree-compiler
then, navigate to /boot/dtb and execute this command
dtc -I dtb -O dts sun7i-a20-cubieboard2.dtb > sun7i-a20-cubieboard2.dts
after that, modified to file using:
sudo nano sun7i-a20-cubieboard2.dts
and in this file, first I have to find the address of the serial ports navigating almost to the end of the file in this part:
__symbols__ {
….
uart0 = "/soc@01c00000/serial@01c28000";
uart1 = "/soc@01c00000/serial@01c28400";
uart2 = "/soc@01c00000/serial@01c28800";
uart3 = "/soc@01c00000/serial@01c28c00";
uart4 = "/soc@01c00000/serial@01c29000";
uart5 = "/soc@01c00000/serial@01c29400";
uart6 = "/soc@01c00000/serial@01c29800";
uart7 = "/soc@01c00000/serial@01c29c00";
……
}
then, copied the data about the ports I need (Uart5 and Uart6).
after copying the address of the ports, navigate to the beginning of the file and find the part named aliases and then copy the information from above.
aliases {
ethernet0 = "/soc@01c00000/ethernet@01c50000";
serial0 = "/soc@01c00000/serial@01c28000";
serial5 = "/soc@01c00000/serial@01c29400";
serial6 = "/soc@01c00000/serial@01c29800";
};
then, going down in the file, find the part where each serial port is defined and then copy the linux,phandle direction, it is needed later.
uart5@0 {
allwinner,pins = "PI10", "PI11";
allwinner,function = "uart5";
allwinner,drive = <0x0>;
allwinner,pull = <0x0>;
linux,phandle = <0x6c>;
phandle = <0x6c>;
};
uart6@0 {
allwinner,pins = "PI12", "PI13";
allwinner,function = "uart6";
allwinner,drive = <0x0>;
allwinner,pull = <0x0>;
linux,phandle = <0x6d>;
phandle = <0x6d>;
};
after that, keep looking for the part where all the serial ports status are declared using the address copied in the aliases part of the file, and change the status of the ports to enable from "disable" to "okay" and also, put the line pinctrl-0 = <linux,phandle>
serial@01c29400 {
compatible = "snps,dw-apb-uart";
reg = <0x1c29400 0x400>;
interrupts = <0x0 0x12 0x4>;
reg-shift = <0x2>;
reg-io-width = <0x4>;
clocks = <0x38 0x15>;
status = "okay";
pinctrl-0 = <0x6c>;
linux,phandle = <0x93>;
phandle = <0x93>;
};
serial@01c29800 {
compatible = "snps,dw-apb-uart";
reg = <0x1c29800 0x400>;
interrupts = <0x0 0x13 0x4>;
reg-shift = <0x2>;
reg-io-width = <0x4>;
clocks = <0x38 0x16>;
status = "okay";
pinctrl-0 = <0x6d>;
linux,phandle = <0x94>;
phandle = <0x94>;
};
then save the file, and compiled back using
dtc -O dtb -o sun7i-a20-cubieboard2.dtb -b 0 sun7i-a20-cubieboard2.dts
then reboot and to find out if the ports are now enable, i used
cat /proc/tty/driver/serial
and
dmesg | grep tty
in both cases I can see the new ports, but the pins associated to them don't seem to work
According to the information about the board, the pins for rx and tx for the serial ports 5 and 6 are:
but I can't see any signal coming from them.
I have also tried to check the pins directly using the formula:
Pin Number in linux = (Position of the letter in the alphabet -1)*32 + Board pin Number
tested this for PG0
G -> 7
(7-1)*32 +0 = 192
Using 192 chek the pin with:
echo 192 > /sys/class/gpio/export
after this, a new folder must appear on /sys/class/gpio/ called gpio192
then I assigned the direction of the pin with
echo out > /sys/class/gpio/gpio192/direction
and to change the status of the pin, I used the following commands
to turn on the pin with
echo 1 > /sys/class/gpio/gpio192/value
and to turn off with:
echo 0 > /sys/class/gpio/gpio192/value