[SOLVED!!!] How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Post Reply
att2
Posts: 16
Joined: Tue Jan 17, 2017 10:56 pm
languages_spoken: english
ODROIDs: Odroid c2
Location: Graz, Austria, Europe
Has thanked: 2 times
Been thanked: 1 time
Contact:

[SOLVED!!!] How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by att2 » Tue Sep 10, 2019 6:18 pm

Hello,

I am trying to enable more UART's. I am following the instructions on https://wiki.odroid.com/odroid-c2/appli ... /gpio/uart

HOWEVER, these instructions are for old meson64_odroidc2.dts files. If I convert the current file being used (at /media/boot/meson64_odroidc2.dts) to text format and try to edit it, I noticed that these sections that ought to be changed don't exist in that file:
-&i2c_a {
- status = "okay";
-
- /* Hardkernel I2C RTC */
- pcf8563: pcf8563@51 {
- status = "disabled";
- compatible = "nxp,pcf8563";
- reg = <0x51>;
- #clock-cells = <0>;
- };
-};
-
and
+++ b/arch/arm64/boot/dts/meson64_odroidc2.dts
@@ -31,6 +31,8 @@
aliases {
serial0 = &uart_AO;
serial1 = &uart_A;
+ serial2 = &uart_B;
+ serial3 = &uart_C;
};

gpu_dvfs_tbl: gpu_dvfs_tbl {
@@ -459,6 +461,32 @@
pinctrl-0 = <&a_uart_pins>;
};

+ uart_B: serial@c11084dc {
+ compatible = "amlogic, meson-uart";
+ reg = <0x0 0xc11084dc 0x0 0x18>;
+ interrupts = <0 75 1>;
+ status = "okay";
+ clocks = <&clock CLK_XTAL>;
+ clock-names = "clk_uart";
+ fifosize = < 64 >;
+ pinctrl-names = "default";
+ pinctrl-0 = <&b_uart_pins>;
+ resets = <&clock GCLK_IDX_UART1>;
+ };
+
+ uart_C: serial@c1108700 {
+ compatible = "amlogic, meson-uart";
+ reg = <0x0 0xc1108700 0x0 0x14>;
+ interrupts = <0 93 1>;
+ status = "okay";
+ clocks = <&clock CLK_XTAL>;
+ clock-names = "clk_uart";
+ fifosize = < 64 >;
+ pinctrl-names = "default";
+ pinctrl-0 = <&c_uart_pins>;
+ resets = <&clock GCLK_IDX_UART2>;
+ };
+
Please update your document for latest kernel 3.16.72-46, which is distributed on latest ubuntu 18.04.3 LTS image.
Last edited by att2 on Fri Sep 13, 2019 10:52 pm, edited 1 time in total.

att2
Posts: 16
Joined: Tue Jan 17, 2017 10:56 pm
languages_spoken: english
ODROIDs: Odroid c2
Location: Graz, Austria, Europe
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by att2 » Tue Sep 10, 2019 8:57 pm

Hello,
I am trying to solve my problems by myself, and I guess it partially works, but most likely I have introduced new problems. Bear with me.... ;)

What I did so far:
I figured that I have to edit the meson64_odroidc2.dtb again, so that's exactly what I did.
Note: I have zero understanding of the device tree blob configuration. I just guessed everything. What I did guess is :

1.) I set i2c-a, i2c-c and i2c-d to "disabled". (I enabled i2c-b for the hardware clock).
i2c@c1108500 {
compatible = "amlogic, meson-i2c";
dev_name = "i2c-A";
status = "disabled";
...
i2c@c11087e0 {
compatible = "amlogic, meson-i2c";
dev_name = "i2c-C";
status = "disabled";
...
i2c@c1108d20 {
compatible = "amlogic, meson-i2c";
dev_name = "i2c-D";
status = "disabled";
2.) I added some serial stuff:
aliases {
serial0 = "/serial@c81004c0";
serial1 = "/serial@c11084c0";
serial2 = "/serial@c1108500";
serial3 = "/serial@c11087e0";
serial4= "/serial@c1108d20";
};

3.) For each of these aliases, I added a section, which is mostly based on the current serial section:
serial@c1108500 {
compatible = "amlogic, meson-uart";
reg = <0x0 0xc1108500 0x0 0x14>;
interrupts = <0x0 0x4b 0x1>;
status = "okay";
clocks = <0xd 0x2>;
clock-names = "clk_uart";
fifosize = <0x80>;
pinctrl-names = "default";
pinctrl-0 = <0x2e>;
};

serial@c11087e0 {
compatible = "amlogic, meson-uart";
reg = <0x0 0xc11087e0 0x0 0x14>;
interrupts = <0x0 0x5d 0x1>;
status = "okay";
clocks = <0xd 0x2>;
clock-names = "clk_uart";
fifosize = <0x80>;
pinctrl-names = "default";
pinctrl-0 = <0x2f>;
};

serial@c1108d20 {
compatible = "amlogic, meson-uart";
reg = <0x0 0xc1108d20 0x0 0x14>;
interrupts = <0x0 0x6f 0x1>;
status = "okay";
clocks = <0xd 0x2>;
clock-names = "clk_uart";
fifosize = <0x80>;
pinctrl-names = "default";
pinctrl-0 = <0x30>;
};
Note to 3.) -- I absolutely GUESSED the interrupt values! (!!!) If they work or not is yet to be tried out. (!)

Now I compiled it with the device tree compiler and placed the file to /media/boot as usual.

The linux system now happily gives me five serial devices /dev/ttyS0 to /dev/ttyS4 in the /dev tree, but I have yet to try out if that is really going to work with real hardware or not.

The dmesg complains about a few things:
...
[ 0.155545] Init pinux probe!
[ 0.156532] pinmux-gxbb c1109880.pinmux: Probed amlogic pinctrl driver
[ 0.156809] genirq: Setting trigger mode 8 for irq 241 failed (gic_set_type+0x0/0x128)
[ 0.156830] genirq: Setting trigger mode 8 for irq 242 failed (gic_set_type+0x0/0x128)
[ 0.156910] genirq: Setting trigger mode 8 for irq 241 failed (gic_set_type+0x0/0x128)
[ 0.156930] genirq: Setting trigger mode 8 for irq 242 failed (gic_set_type+0x0/0x128)
...
--> this is probably unrelated, but I'll show it anyway....
[ 0.271051] Unpacking initramfs...
[ 0.483372] hdmitx: plugin
[ 0.612329] 00ffffffffffff0023335948080000001c1b0103812f1a782e3585a656489a24
1250540000000101010101010101010101010101010101140040415823202010
0304dc0c1100001a000000fc0048444d490a2020202020202020000000fe0052
310a20202020202020202020000000fe0032303137313132330a202020200152


[ 0.612405] 020312f123097f078301000065030c001000011400404158232020100304dc0c
1100001a000000fc0048444d490a2020202020202020000000fe0052310a2020
2020202020202020000000fe0032303137313132330a20202020000000fe0048
414f595520454c45430a202000000000000000000000000000000000000000b0


[ 0.612445] EDID Parser:
... ( now the more interesting serial stuff ! )
[ 0.675727] usbhid: USB HID core driver
[ 0.675883] ==uart0 reg addr = ffffff80002344c0
[ 0.675910] c81004c0.serial: ttyS0 at MMIO 0xc81004c0 (irq = 225, base_baud = 1500000) is a meson_uart
[ 2.722581] console [ttyS0] enabled
[ 2.726255] ==uart1 reg addr = ffffff80002364c0
[ 2.730514] c11084c0.serial: ttyS1 at MMIO 0xc11084c0 (irq = 58, base_baud = 1500000) is a meson_uart
[ 2.739865] ==uart2 reg addr = ffffff8000238500
[ 2.744150] c1108500.serial: ttyS2 at MMIO 0xc1108500 (irq = 107, base_baud = 1500000) is a meson_uart
[ 2.753521] meson_uart c11087e0.serial: could not find pctldev for node /odroid_hdmi/i2sdai0, deferring probe
[ 2.763207] ==uart3 reg addr = ffffff800023a7e0
[ 2.767687] c11087e0.serial: ttyS3 at MMIO 0xc11087e0 (irq = 125, base_baud = 1500000) is a meson_uart
[ 2.777061] meson_uart c1108d20.serial: could not find pctldev for node /odroid_hdmi/dit0, deferring probe
[ 2.786494] ==uart4 reg addr = ffffff800023cd20
[ 2.790974] c1108d20.serial: ttyS4 at MMIO 0xc1108d20 (irq = 143, base_baud = 1500000) is a meson_uart
...
[ 4.410513] remote: Driver init
[ 4.410756] gpio_key- gpio_key_probe
[ 4.410771] gpio-key c8100000.gpio_keypad: gpio_key: find key_name=0 fail
[ 4.410785] gpio-key: probe of c8100000.gpio_keypad failed with error -22
[ 4.411210] input: cec_input as /devices/virtual/input/input3
[ 4.411402] cectx c810023c.aocec: aml_cec_probe(): can't find hdmirx
[ 4.413359] ^A6--------------------------------------------------------
[ 4.413362] ^A6odroid_sysfs_init(321) : Sleep Enable !!
[ 4.413363] ^A6--------------------------------------------------------
[ 4.413549] input: vt-input as /devices/virtual/input/input4
[ 4.413639] ^A6Virtual-Key input driver registered!!
[ 4.414250] enter aml_soc_platform_pcm2bt_probe
[ 4.414567] divider=16,frac=33920000,SDMval=4523
[ 4.414723] enter aml_pcm_dai_probe
[ 4.414767] [aml-spdif-dai]enter aml_dai_spdif_init
[ 4.414830] aml_spdif_probe
[ 4.414962] enter spdif_dit_probe
[ 4.415007] pinmux-gxbb c1109880.pinmux: pin GPIOAO_6 already requested by c1108500.serial; cannot claim for spdif_codec
[ 4.415011] pinmux-gxbb c1109880.pinmux: pin-6 (spdif_codec) status -22
[ 4.415016] pinmux-gxbb c1109880.pinmux: could not request pin 6 (GPIOAO_6) from group audio_pin1 on device c1109880.pinmux
[ 4.415020] spdif-dit spdif_codec: Error applying setting, reverse things back
[ 4.415029] aml_spdif_pinmux_init can't get pinctrl
[ 4.415681] odroid_hdmi_snd odroid_hdmi: dit-hifi <-> I2S mapping ok
[ 4.416219] GACT probability on
[ 4.416234] Mirror/redirect action on
...
[ 4.418244] Mali DRM initialize, driver name: mali_drm, version 2.1
[ 4.418454] [drm] Initialized mali_drm 2.1.1 20140306 on minor 0
[ 4.418466] Mali DRM initialize, driver name: mali_drm, version 2.1
[ 4.418588] [drm] Initialized mali_drm 2.1.1 20140306 on minor 1
[ 4.418698] rtc_hctosys: unable to open rtc device (rtc0)
[ 4.419939] ^A6enter meson_pm_probe!
[ 4.420036] meson_pm_probe done
...
So what do you think, did I do this correctly or do you have any kind suggestions of how to get the other i2c-lines except i2c-b to work as serial lines ? (i2c-b is reserved for the rtc realtime clock in my special case)

The devices CAN be found in /dev now :
root@odroid:/tmp# ls -al /dev/ttyS*
crw--w---- 1 root tty 242, 0 Jan 28 2018 /dev/ttyS0
crw-rw-rw- 1 root dialout 242, 1 Jan 28 2018 /dev/ttyS1
crw-rw---- 1 root dialout 242, 2 Jan 28 2018 /dev/ttyS2
crw-rw---- 1 root dialout 242, 3 Jan 28 2018 /dev/ttyS3
crw-rw---- 1 root dialout 242, 4 Jan 28 2018 /dev/ttyS4

User avatar
tony.hong
Posts: 34
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 8 times
Been thanked: 4 times
Contact:

Re: How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by tony.hong » Wed Sep 11, 2019 9:31 am

Some of the I2C channels can change UART(serial). Not all.

Ref: https://dn.odroid.com/S905/DataSheet/S9 ... V1.1.4.pdf

Serial node name in dts is serial@[base register address].

uart register list (Ref: p.310 S905_Public_Datasheet_V1.1.4.pdf)
UART0 0xc11084c0 ~ 0xc11084d4 -> serial@0xc11084c0
UART1 0xc11084dc ~ 0xc11084f0 -> serial@0xc11084dc
UART2 0xc1108700 ~ 0xc1108714 -> serial@0xc1108700
UART0-A0 0xc81004c0 ~ 0xc81004d4 -> serial@0xc81004c0

GPIO pins have several functions. (Ref: p.83 S905_Public_Datasheet_V1.1.4.pdf)
GPIODV.24 and GPIODV.25(pin 3, 5) can be set to UART_B(func 5) or I2C_A(func 6) by chance.

0xc1108500 in 'i2c@0xc1108500' means I2C0 base address(0xC1100000 + 0x2140 *4). (Ref: p.306 S905_Public_Datasheet_V1.1.4.pdf)

So, probably, your dtb won't work.

I'm going to do some tests. If I successfully add additional serial ports, I will leave a comment on how.

User avatar
tony.hong
Posts: 34
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 8 times
Been thanked: 4 times
Contact:

Re: How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by tony.hong » Wed Sep 11, 2019 12:28 pm

Test1

I followed https://wiki.odroid.com/odroid-c2/appli ... /gpio/uart.

The serial test was successful. But I don't know what kind of change.

Test2

In /media/boot, I decompiled the dtb file into a dts file, edited the dts file, and then compiled it to a dtb file.

Check-points are 'pinctrl-0' and 'reset' property.

a value of pinctrl-0 is mapped to pinmux or pinconfig using 'phandle' when executing 'make dtbs' command.

'phandle' is automatically set to a series of numbers.

Code: Select all

$ cd /media/boot
$ dtc -I dtb -O dts meson64_odroidc2.dtb -o meson64_odroidc2.dts
$ vim meson64_odroidc2.dts
I deleted 'i2c@c1108500' node(i2c-A).

I checked that the last phandle value is 0x42, and added a phandle property to b_uart and c_uart nodes as shown below.

Code: Select all

		b_uart {
			amlogic,setmask = <0x2 0x30000000>;
			amlogic,pins = "GPIODV_24", "GPIODV_25";
			linux,phandle = <0x43>;
			phandle = <0x43>;
		};

		c_uart {
			amlogic,setmask = <0x1 0xc0000>;
			amlogic,pins = "GPIOY_13", "GPIOY_14";
			linux,phandle = <0x44>;
			phandle = <0x44>;
		};
Then I added below code between 'serial@c11084c0' and 'canvas' nodes.
I copied and pasted Values of 'reset' property from the dts file decompiled from the dtb file in Test 1.

Code: Select all

	serial@c11084dc {
		compatible = "amlogic, meson-uart";
		reg = <0x0 0xc11084dc 0x0 0x14>;
		interrupts = <0x0 0x4b 0x1>;
		status = "okay";
		clocks = <0xd 0x2>;
		clock-names = "clk_uart";
		fifosize = <0x40>;
		pinctrl-names = "default";
		pinctrl-0 = <0x42>;
		reset = <0xd 0x30>;
	};

	serial@c1108700 {
		compatible = "amlogic, meson-uart";
		reg = <0x0 0xc1108700 0x0 0x14>;
		interrupts = <0x0 0x5d 0x1>;
		status = "okay";
		clocks = <0xd 0x2>;
		clock-names = "clk_uart";
		fifosize = <0x40>;
		pinctrl-names = "default";
		pinctrl-0 = <0x43>;
		reset = <0xd 0x4f>;
	};

Code: Select all

$ mv meson64_odroidc2.dtb meson64_odroidc2.dtb.old
$ dtc -I dts -O dtb meson64_odroidc2.dts -o meson64_odroidc2.dtb
$ sudo reboot
The serial test was as successful as test 1.
These users thanked the author tony.hong for the post:
att2 (Thu Sep 12, 2019 7:59 am)

att2
Posts: 16
Joined: Tue Jan 17, 2017 10:56 pm
languages_spoken: english
ODROIDs: Odroid c2
Location: Graz, Austria, Europe
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by att2 » Wed Sep 11, 2019 7:49 pm

Tony, you are a hero! UART-B is now working here !! :D :D :D :D
tony.hong wrote:
Wed Sep 11, 2019 12:28 pm
...

Code: Select all

$ cd /media/boot
$ dtc -I dtb -O dts meson64_odroidc2.dtb -o meson64_odroidc2.dts
$ vim meson64_odroidc2.dts
I deleted 'i2c@c1108500' node(i2c-A).
Additional question : Do I also have to delete the other i2c@xxxxxx nodes (i2c-c, i2c-d) when I want them to work as serial ?

att2
Posts: 16
Joined: Tue Jan 17, 2017 10:56 pm
languages_spoken: english
ODROIDs: Odroid c2
Location: Graz, Austria, Europe
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by att2 » Wed Sep 11, 2019 8:54 pm

So far, I could not get UART-C to work. Do I have to disable or enable anything in the i2c-c or i2c-d section, etc. ?

User avatar
tony.hong
Posts: 34
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 8 times
Been thanked: 4 times
Contact:

Re: How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by tony.hong » Thu Sep 12, 2019 3:31 pm

Maybe I got some mistakes.

I think I wrote the wrong value for 'pinctrl-0'.

Code: Select all

	serial@c11084dc {
		compatible = "amlogic, meson-uart";
		reg = <0x0 0xc11084dc 0x0 0x14>;
		interrupts = <0x0 0x4b 0x1>;
		status = "okay";
		clocks = <0xd 0x2>;
		clock-names = "clk_uart";
		fifosize = <0x40>;
		pinctrl-names = "default";
		pinctrl-0 = <0x43>;
		reset = <0xd 0x30>;
	};

	serial@c1108700 {
		compatible = "amlogic, meson-uart";
		reg = <0x0 0xc1108700 0x0 0x14>;
		interrupts = <0x0 0x5d 0x1>;
		status = "okay";
		clocks = <0xd 0x2>;
		clock-names = "clk_uart";
		fifosize = <0x40>;
		pinctrl-names = "default";
		pinctrl-0 = <0x44>;
		reset = <0xd 0x4f>;
	};
But I can not test this now. Tomorrow is the Chuseok holiday, Korean traditional big holiday.
I'm on my way to see my parents. So I don't have any odroid now.

Would you try above code?
These users thanked the author tony.hong for the post:
att2 (Fri Sep 13, 2019 8:13 pm)

att2
Posts: 16
Joined: Tue Jan 17, 2017 10:56 pm
languages_spoken: english
ODROIDs: Odroid c2
Location: Graz, Austria, Europe
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by att2 » Fri Sep 13, 2019 10:24 pm

Hello Tony,
I just tried it and all 4 serial lines now work perfectly! We were sending out data with ...
echo 85 > /dev/ttyS0 (ttyS1, S2, S3)
...in an endless loop and we can see the outgoing traffic on all 4 serial lines on the oscilloscope!
It just works fine! Thank you so much !!!
These users thanked the author att2 for the post:
tony.hong (Sat Sep 14, 2019 11:37 am)

User avatar
mad_ady
Posts: 6530
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 163 times
Been thanked: 125 times
Contact:

Re: [SOLVED!!!] How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by mad_ady » Sat Sep 14, 2019 12:38 am

Should be wiki-fied so it doesn't get lost.

User avatar
tony.hong
Posts: 34
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 8 times
Been thanked: 4 times
Contact:

Re: [SOLVED!!!] How to enable UART_B and UART_C ports with new kernel 3.16.72-46?

Unread post by tony.hong » Mon Sep 16, 2019 10:13 am

Hello mad_ady,

I don't know much about 'device tree'.
After studying the device tree, I will try to wiki-fy this.

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 3 guests