UART interface on Ubuntu

We need UART interface to connect with a serial device. By using the /dev/ttyS1, no serial data is found in the communication. How do I access UART_RX_AO_B / UART_TX_AO_B?

crw–w---- 1 root tty 244, 0 Apr 18 11:24 ttyS0
crw-rw---- 1 root dialout 244, 1 Apr 18 11:42 ttyS1

khadas@Khadas:/dev$ uname -a
Linux Khadas 3.14.29 #126 SMP PREEMPT Sat Feb 11 00:33:23 CST 2017 aarch64 aarch64 aarch64 GNU/Linux

You need to modify the file ‘linux/arch/arm64/boot/dts/kvim.dts’

@@ -848,7 +848,7 @@
uart_AO_B: serial@c81004e0 {

                compatible = "amlogic, meson-uart";
                reg = <0x0 0xc81004e0 0x0 0x18>;
                interrupts = <0 197 1>;
-               status = "disable";
+               status = "okay";
                clocks = <&clock CLK_XTAL>;
                clock-names = "clk_uart";
                fifosize = < 64 >;

After do that, you need to rebuild the kernel and reflash the kvim.dtb
The name of the port in “uart_AO_B” is ‘ttyS4’ and not ‘ttyS0’ or ‘ttyS1’ .

Vim:/dev # ls -l ttyS4                                                         
crw------- 1 root root 244,   4 2015-01-01 00:00 ttyS4

Thank you for your reply. May I know any guideline is given to rebuild the kernel? Where can I find the source code?

which version of your ubuntu rom ? Ubuntu server or Ubuntu mate ?

It is Ubnutu server (Vim_Ubuntu-server-16.04_V170211)

khadas@Khadas:/dev$ uname -a
Linux Khadas 3.14.29 #126 SMP PREEMPT Sat Feb 11 00:33:23 CST 2017 aarch64 aarch64 aarch64 GNU/Linux

You can follow this to build your ubuntu rom .
If you have some questions about it , I will replay for you.

I’m learning about Embedded Linux and Kernel Building.

I’d like to know where can I find in the kernel source that uart_AO_B: serial@c81004e0 is linked to ttyS4?

Where is it written?

You can take a look at:

Thank you! How about the i2c?
I didn’t find the aliases for it.

You can take a look at ‘device_id’

Thank you. So by default the i2c lines are not activated? (status = “disabled”)
If I want to use (I2C_SCK_A, I2C_SDA_A) and (I2C_SCK_B, I2C_SDA_B) on the GPIO header, I’ll have to write (status = “okay”) on i2c-a and i2c-b then recompile the mesongxl.dtsi file to load it via u-boot?

Yes,you are right.But the output file is kvim.dtb,you can load images with u-boot via tftp

Okay I got it! Thanks for all explanations :slight_smile:

I’ve made the modifications to the mesongxl.dtsi file and loaded the kvim.dts file via tftp.

/dev/i2c-2 shows up but the i2c lines doesn’t work.

You can see the outputs bellow:

khadas@Khadas:~/i2c-tools-1/tools$ ls /dev/i2c-*
/dev/i2c-0  /dev/i2c-1  /dev/i2c-2

khadas@Khadas:~/i2c-tools-1/tools$ sudo chmod 0777 /dev/i2c-*

khadas@Khadas:~/i2c-tools-1/tools$ ./i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --            
         
khadas@Khadas:~/i2c-tools-1/tools$ ./i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
30: -- -- -- -- -- -- -- -- 38 39 3a 3b 3c 3d 3e 3f 
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
70: 70 71 72 73 74 75 76 77            
         
khadas@Khadas:~/i2c-tools-1/tools$ ./i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
30: -- -- -- -- -- -- -- -- 38 39 3a 3b 3c 3d 3e 3f 
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
70: 70 71 72 73 74 75 76 77  

Does anyone ever used the I2C on the Khadas VIM?

You need to creata a new post.
Thanks

Done!
http://forum.khadas.com/t/use-i2c-on-khadas-vim/626