DESK-MX8M-L/Peripherals/UART

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes

2021/12/30

First DESK-MX8M-L release

2023/02/27

DESK-MX8M-L-2.0.0 release

2023/08/22

DESK-MX8M-L-4.0.0 release
2024/04/11 DESK-MX8M-L-4.1.0 release


Peripheral UART[edit | edit source]

Device tree configuration[edit | edit source]

ORCA SOM[edit | edit source]

Here below an example of device tree modifications to standard DAVE's kit for the ORCA SOM:

From imx8mp-mito8mplus.dtsi:

...
...
&uart4 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart4_j8>;
	assigned-clocks = <&clk IMX8MP_CLK_UART4>;
	assigned-clock-parents = <&clk IMX8MP_SYS_PLL1_80M>;
	/*fsl,uart-has-rtscts;*/
	status = "disabled";
};
...
...
&iomuxc {
...
...
	pinctrl_uart4: uart4grp {
		fsl,pins = <
			MX8MP_IOMUXC_ECSPI2_SCLK__UART4_DCE_RX		0x140
			MX8MP_IOMUXC_ECSPI2_MOSI__UART4_DCE_TX		0x140
			MX8MP_IOMUXC_ECSPI2_MISO__UART4_DCE_CTS		0x140
			MX8MP_IOMUXC_ECSPI2_SS0__UART4_DCE_RTS		0x140
		>;
	};

	pinctrl_uart4_j8: uart4grp {
		fsl,pins = <
			MX8MP_IOMUXC_UART4_TXD__UART4_DCE_TX	0x140
			MX8MP_IOMUXC_UART4_RXD__UART4_DCE_RX	0x140
		>;
	};
...

MITO 8M Mini[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the MITO 8M Mini SOM:

From imx8mm-mito8mmini.dtsi:

...
...
&uart1 {
	assigned-clocks = <&clk IMX8MM_CLK_UART1>;
	assigned-clock-parents = <&clk IMX8MM_SYS_PLL1_80M>;
	status = "disabled";
};
...
...
&iomuxc {
...
...
	pinctrl_uart1: uart1grp {
		fsl,pins = <
			MX8MM_IOMUXC_UART1_RXD_UART1_DCE_RX	0x140
			MX8MM_IOMUXC_UART1_TXD_UART1_DCE_TX	0x140
			MX8MM_IOMUXC_UART3_RXD_UART1_DCE_CTS_B	0x140
			MX8MM_IOMUXC_UART3_TXD_UART1_DCE_RTS_B	0x140
		>;
	};
...
...


From imx8mm-mito8mmini-sbcx.dts:

...
...

/ {
	regulators: regulators {
...
...
		/* enable ISL3330IAZ on SBCX at boot */
		reg_uart1_en: uart1_en {
			compatible = "regulator-fixed";
			regulator-name = "uart1_en";
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_uart1_en>;
			regulator-min-microvolt = <3300000>;
			regulator-max-microvolt = <3300000>;
			gpio = <&gpio3 24 GPIO_ACTIVE_HIGH>;
			enable-active-high;
			regulator-always-on;
			regulator-boot-on;
		};
...
...
	};
};
...
...
&uart1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart1>;
	fsl,uart-has-rtscts;
	status = "okay";
};
...
...
&iomuxc {
...
...
	pinctrl_uart1_en: uart1_en {
		fsl,pins = <
			MX8MM_IOMUXC_SAI5_RXD3_GPIO3_IO24			 0x19
		>;
	};

...
...


Accessing the peripheral in ORCA SOM[edit | edit source]

Linux messages at boot time[edit | edit source]

...
...
[    0.836042] 30860000.serial: ttymxc0 at MMIO 0x30860000 (irq = 31, base_baud = 5000000) is a IMX
[    0.843116] 30880000.serial: ttymxc2 at MMIO 0x30880000 (irq = 32, base_baud = 5000000) is a IMX
[    0.851863] 30890000.serial: ttymxc1 at MMIO 0x30890000 (irq = 33, base_baud = 1500000) is a IMX
[    0.860354] printk: console [ttymxc1] enabled
...
...

Usage with stty[edit | edit source]

N.B. UART mapping respect to ttymxcX is the following one:

UART1 (RS232) <-> ttymxc0
UART2 (Serial Port) <-> ttymxc1
UART3 (UART) <-> ttymxc2
UART4 (RS485) <-> ttymxc3
...
root@desk-mx8mp:~# stty -F /dev/ttymxc0 115200 -echo -raw
root@desk-mx8mp:~# cat /dev/ttymxc0 > test_ttymxc0.log &
[1] 1868
root@desk-mx8mp:~# echo "Test loopback" > /dev/ttymxc0
root@desk-mx8mp:~# cat test_ttymxc0.log
Test loopback

root@desk-mx8mp:~#

Accessing the peripheral in MITO 8M Mini[edit | edit source]

Linux messages at boot time[edit | edit source]

...
...
[    0.812632] 30860000.serial: ttymxc0 at MMIO 0x30860000 (irq = 40, base_baud = 5000000) is a IMX                                                                                                                                           
[    0.860368] 30890000.serial: ttymxc1 at MMIO 0x30890000 (irq = 42, base_baud = 1500000) is a IMX                                                                                                                                           
[    0.869035] printk: console [ttymxc1] enabled
...
...

Usage with stty[edit | edit source]

N.B. UART mapping respect to ttymxcX is the following one:

UART1 (RS232/RS485/RS422 port DB9) <-> ttymxc0
UART2 (Serial Port) <-> ttymxc1
UART3 (PMOD) <-> ttymxc2
UART4 (UART for Cortex-M4) <-> ttymxc3
...
root@desk-mx8mm:~# dmesg | grep tty^C
root@desk-mx8mm:~# stty -F /dev/ttymxc0 115200 -echo -raw
root@desk-mx8mm:~# cat /dev/ttymxc0 > test_ttymxc0.log &
[1] 1313
root@desk-mx8mm:~# echo "Test loopback" > /dev/ttymxc0
root@desk-mx8mm:~# cat test_ttymxc0.log 
Test loopback

root@desk-mx8mm:~#

Additional information[edit | edit source]

Serial ports can be used through the standard serial programming API.

For detailed information, please refer to the Serial Programming HOWTO at Serial-Programming-HOWTO