Jump to content

Problem enablig tty5 and tty6 on cubieboard2 with kernel 4.7.3 using DTB


EdrZero

Recommended Posts

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:

 
U14 (Next to SATA Connector)
SPIO0
48 PI13 (SPI0-MISO/UART6-RX/EINT25) 47 PI11 (SPI0-CLK/UART5-RX/EINT23)
46 PI12 (SPI0-MOSI/UART6-TX/EINT24) 45 PI10 (SPI0-CS/UART5-TX/EINT22)
 
a very good graphic with the cubieboard pinput can be found here:
 

 

 

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 

 
this works like a charm with PG0 and PG2, but it doesn't work with PI13 and PI12
 
PI13
I ->9th letter of the alphabet
 
Pin Number in Linux= (9-1)*32 + 13
Pin Number in Linux=269
 
can anyone help me to get the serials ports to work? can you tell me what I'm doing wrong??
 
Thanks
Link to comment
Share on other sites

Yes, after almost a year I decided to look again and finally find the answer.

This time I tried with UART4, change the pins and everything as I posted, and then, only one more step was needed to make it work.

 

first, you have to read the file /boot/dtb/overlay/README.sun7i-a20-overlays

in there you will find all the information about the overlays. 

 

then go to /boot/armbianEvn.txt and put this at the end of the file:

 

overlays=uart4
param_uart4_pins=a

 

then restart and Bingo!! UART4 now works like a charm!!!

 

Hope this helps.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines