Difference between revisions of "DESK-MX6-L/Pheripherals/UART"

From DAVE Developer's Wiki
Jump to: navigation, search
m (U0009 moved page AXEL Lite SOM/DESK-MX6-L/Pheripherals/UART to DESK-MX6-L/Pheripherals/UART: modifica gestione DESK come prodotto a se stante)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<section begin=History/>
+
<section begin="History" />
 
{| style="border-collapse:collapse; "
 
{| style="border-collapse:collapse; "
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
+
! colspan="4" style="width:100%; text-align:left" ; border-bottom:solid 2px #ededed" |History
 
|-  
 
|-  
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Version
+
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white" |Issue Date
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Issue Date
+
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white" |Notes
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
 
 
|-
 
|-
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|1.0.0
+
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |{{oldid|14093|2021/07/16}}
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|Oct 2020
+
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |First DESK-MX6-L release
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|First DESK release
 
 
|-
 
|-
 +
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |{{oldid|16263|2022/03/03}}
 +
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |DESK-MX6-L 3.0.0 release
 +
|-
 +
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |{{oldid|17001|2022/05/27}}
 +
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |Add RS282/RS485 setting mode
 +
|-
 +
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |2023/04/11
 +
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |DESK-MX6-L 4.0.0 release
 
|-
 
|-
 
|}
 
|}
<section end=History/>
+
<section end="History" />
<section begin=Body/>
+
<section begin="Body" />
  
 
==Peripheral UART ==
 
==Peripheral UART ==
Line 25: Line 31:
 
<pre>
 
<pre>
 
&uart2 {
 
&uart2 {
    pinctrl-names = "default";
+
fsl,uart-has-rtscts;
    pinctrl-0 = <&pinctrl_uart2_1>;
+
pinctrl-names = "default";
    fsl,uart-has-rtscts;
+
pinctrl-0 = <&pinctrl_dwm_uart2_1>;
    status = "okay";
+
status = "okay";
 
};
 
};
 
 
</pre>
 
</pre>
  
Line 37: Line 42:
 
<pre>
 
<pre>
 
     uart2 {
 
     uart2 {
         pinctrl_uart2_1: uart2_grp-1 {
+
         pinctrl_dwm_uart2_1: dwm_uart2_grp-1 {
 
             fsl,pins = <
 
             fsl,pins = <
 
                 MX6QDL_PAD_SD3_DAT4__UART2_RX_DATA 0x1b0b1
 
                 MX6QDL_PAD_SD3_DAT4__UART2_RX_DATA 0x1b0b1
Line 53: Line 58:
 
...
 
...
 
...
 
...
[    0.327639] 21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 67, base_baud = 5000000) is a IMX
+
[    0.302170] 21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 78, base_baud = 5000000) is a IMX
[    0.328239] 21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 68, base_baud = 5000000) is a IMX
+
[    0.303041] 21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 79, base_baud = 5000000) is a IMX
[    1.217209] console [ttymxc2] enabled
+
[    0.569731] printk: console [ttymxc2] enabled
[    1.221552] 21f0000.serial: ttymxc3 at MMIO 0x21f0000 (irq = 69, base_baud = 5000000) is a IMX
+
[    0.582478] 21f0000.serial: ttymxc3 at MMIO 0x21f0000 (irq = 80, base_baud = 5000000) is a IMX
[    1.230860] 21f4000.serial: ttymxc4 at MMIO 0x21f4000 (irq = 70, base_baud = 5000000) is a IMX
+
[    0.594030] 21f4000.serial: ttymxc4 at MMIO 0x21f4000 (irq = 81, base_baud = 5000000) is a IMX
 
...
 
...
 
...
 
...
 
root@imx6qxelk:~#
 
root@imx6qxelk:~#
 +
</pre>
 +
 +
==== Configuring the RS232/RS485 mode====
 +
When the UART5 (aka <code>/dev/ttymxc4</code> device in Linux) is properly configured using the hardware jumpers (see [[AXEL_Lite_SOM/AXEL_Lite_Evaluation_Kit/Interfaces_and_Connectors/UARTs#UART5 | Interfaces and Connectors - UART5]] EVK page), the MultiProtocol transceiver pins has to be initialized for setting the related user selectable modes: the RS232 or RS485 mode can be selected with the <code>gpio-leds</code> class and the led <code>rs232_on</code>.
 +
 +
From <code>imx6q-sbcx-cb0012.dts</code> or <code>imx6dl-sbcx-cb0012.dts</code>:
 +
 +
<pre>
 +
    leds {
 +
compatible = "gpio-leds";
 +
pinctrl-names = "default";
 +
pinctrl-0 = <&pinctrl_rs232_485_422_1>;
 +
 +
rs232_485_422 {
 +
gpios = <&gpio7 13 GPIO_ACTIVE_HIGH>;
 +
linux,default-trigger = "default-on";
 +
};
 +
 +
rs232_on {
 +
gpios = <&gpio5 29 GPIO_ACTIVE_LOW>;
 +
linux,default-trigger = "default-on";
 +
};
 +
    };
 +
</pre>
 +
 +
===== RS232 mode =====
 +
This is the default protocol mode; this can be also activated (when different) using the following command:
 +
<pre class="workstation-terminal">
 +
root@desk-mx6:~# echo 0 > /sys/class/leds/rs232_on/brightness
 +
</pre>
 +
 +
===== RS485 mode =====
 +
This mode can be activated using the following command:
 +
<pre class="workstation-terminal">
 +
root@desk-mx6:~# echo 255 > /sys/class/leds/rs232_on/brightness
 
</pre>
 
</pre>
  
Line 73: Line 113:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6:~# stty -F /dev/ttymxc1 115200 -echo
+
root@desk-mx6:~# stty -F /dev/ttymxc3 115200 -echo
root@desk-mx6:~# cat /dev/ttymxc1 &
+
root@desk-mx6:~# cat /dev/ttymxc3 &
 
[2] 555
 
[2] 555
root@desk-mx6:~# echo "Test loopback" > /dev/ttymxc1
+
root@desk-mx6:~# echo "Test loopback" > /dev/ttymxc3
 
root@desk-mx6:~# Test loopback
 
root@desk-mx6:~# Test loopback
 
</pre>
 
</pre>

Latest revision as of 17:04, 8 January 2024

History
Issue Date Notes

2021/07/16

First DESK-MX6-L release

2022/03/03

DESK-MX6-L 3.0.0 release

2022/05/27

Add RS282/RS485 setting mode
2023/04/11 DESK-MX6-L 4.0.0 release


Peripheral UART[edit | edit source]

Device tree configuration[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the AXELLite SOM:

From imx6qdl-sbcx-revb-common.dtsi:

&uart2 {
	fsl,uart-has-rtscts;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_dwm_uart2_1>;
	status = "okay";
};

From imx6qdl-axelcommon.dtsi:

    uart2 {
        pinctrl_dwm_uart2_1: dwm_uart2_grp-1 {
            fsl,pins = <
                MX6QDL_PAD_SD3_DAT4__UART2_RX_DATA 0x1b0b1
                MX6QDL_PAD_SD3_DAT5__UART2_TX_DATA 0x1b0b1
                MX6QDL_PAD_SD3_CMD__UART2_CTS_B 0x1b0b1
                MX6QDL_PAD_SD3_CLK__UART2_RTS_B 0x1b0b1
            >;
        };

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

...
...
[    0.302170] 21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 78, base_baud = 5000000) is a IMX
[    0.303041] 21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 79, base_baud = 5000000) is a IMX
[    0.569731] printk: console [ttymxc2] enabled
[    0.582478] 21f0000.serial: ttymxc3 at MMIO 0x21f0000 (irq = 80, base_baud = 5000000) is a IMX
[    0.594030] 21f4000.serial: ttymxc4 at MMIO 0x21f4000 (irq = 81, base_baud = 5000000) is a IMX
...
...
root@imx6qxelk:~#

Configuring the RS232/RS485 mode[edit | edit source]

When the UART5 (aka /dev/ttymxc4 device in Linux) is properly configured using the hardware jumpers (see Interfaces and Connectors - UART5 EVK page), the MultiProtocol transceiver pins has to be initialized for setting the related user selectable modes: the RS232 or RS485 mode can be selected with the gpio-leds class and the led rs232_on.

From imx6q-sbcx-cb0012.dts or imx6dl-sbcx-cb0012.dts:

    leds {
	compatible = "gpio-leds";
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_rs232_485_422_1>;

	rs232_485_422 {
		gpios = <&gpio7 13 GPIO_ACTIVE_HIGH>;
		linux,default-trigger = "default-on";
	};

	rs232_on {
		gpios = <&gpio5 29 GPIO_ACTIVE_LOW>;
		linux,default-trigger = "default-on";
	};
    };
RS232 mode[edit | edit source]

This is the default protocol mode; this can be also activated (when different) using the following command:

root@desk-mx6:~# echo 0 > /sys/class/leds/rs232_on/brightness
RS485 mode[edit | edit source]

This mode can be activated using the following command:

root@desk-mx6:~# echo 255 > /sys/class/leds/rs232_on/brightness

Usage with stty[edit | edit source]

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

UART1 <-> ttymxc0
UART2 <-> ttymxc1
UART3 <-> ttymxc2
UART4 <-> ttymxc3
...
root@desk-mx6:~# stty -F /dev/ttymxc3 115200 -echo
root@desk-mx6:~# cat /dev/ttymxc3 &
[2] 555
root@desk-mx6:~# echo "Test loopback" > /dev/ttymxc3
root@desk-mx6:~# Test loopback

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