The NXP i.MX6 CPU has five UART interfaces, all of them capable of standard RS-232 serial communication.

On the ConnectCore 6 Plus:

  • UART1, UART3, and UART5 are available for peripheral use.

  • UART2 is connected to the Bluetooth chip (on modules with Bluetooth).

  • UART4 is used for the console (hard coded on the bootloader).

On the ConnectCore 6 Plus SBC:

  • UART1, UART3, and UART5 are available through an expansion connector.

  • UART5 is routed to the XBee connector for communicating with an XBee device.

  • UART1 and UART3 are 4-wires, RS-232 level.

  • UART5 is 4-wires, TTL level.

Kernel configuration

You can manage the UART driver support through the kernel configuration option:

  • IMX serial port support (CONFIG_SERIAL_IMX)

This option is enabled as built-in on the ConnectCore 6 Plus SBC kernel configuration file.

Kernel driver

The UART driver for the i.MX6 CPU is located at drivers/tty/serial/imx.c.

Device tree bindings and customization

The i.MX6 UART interface device tree binding is documented at Documentation/devicetree/bindings/serial/fsl-imx-uart.txt.

The UART interfaces are defined in the i.MX6 CPU, ConnectCore 6 Plus, and ConnectCore 6 Plus SBC device tree files.

Example: UART1

Definition of the bus

Common ConnectCore 6 Plus device tree
uart1: serial@02020000 {
                    compatible = "fsl,imx6q-uart", "fsl,imx21-uart";
                    reg = <0x02020000 0x4000>;
                    interrupts = <0 26 IRQ_TYPE_LEVEL_HIGH>;
                    clocks = <&clks IMX6QDL_CLK_UART_IPG>,
                         <&clks IMX6QDL_CLK_UART_SERIAL>;
                    clock-names = "ipg", "per";
                    dmas = <&sdma 25 4 0>, <&sdma 26 4 0>;
                    dma-names = "rx", "tx";
                    status = "disabled";
};

IOMUX configuration

Common ConnectCore 6 Plus device tree
uart1 {
        pinctrl_uart1: uart1 {
            fsl,pins = <
                MX6QDL_PAD_SD3_DAT6__UART1_RX_DATA 0x1b0b1
                MX6QDL_PAD_SD3_DAT7__UART1_TX_DATA 0x1b0b1
                MX6QDL_PAD_EIM_D19__UART1_CTS_B 0x1b0b1
                MX6QDL_PAD_EIM_D20__UART1_RTS_B 0x1b0b1
            >;
    };
};

Port enabling and parameters

ConnectCore 6 Plus SBC device tree
&uart1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_uart1>;
    uart-has-rtscts;
    digi,pwr-en-gpio = <&gpio2 26 GPIO_ACTIVE_HIGH>;
    status = "okay";
};

RS-485 support

RS-485 is a standard defining the electrical characteristics of drivers and receivers in balanced digital multipoint systems. RS-485 only specifies electrical characteristics of the generator and the receiver; it does not specify or recommend a communications protocol.

The i.MX6QP serial driver includes support for the RS-485 standard. No specific kernel configuration is necessary to support RS-485 over the serial interface. The device tree bindings are documented at Documentation/devicetree/bindings/serial/rs485.txt.

RS-485 half-duplex needs the RX and TX lines for data communication and the CTS line to control the RS-485 transceiver to either drive output or receive input from outside the chip.

In i.MX6QP CPUs, the CTS line is an output of the CPU that requests the transmitter to send data (effectively RTS). The RTS line is an input of the CPU that receives requests from receivers for stopping/resuming transmission (effectively CTS).

To enable RS-485 mode on a UART port, apply the following changes to the device tree node:

  • Add property linux,rs485-enabled-at-boot-time.

  • Optionally add property rs485-rts-active-high to define CTS line polarity as ACTIVE HIGH. Default polarity is ACTIVE LOW.

  • Optionally add property rs485-rx-during-tx to allow receiving data while sending data.

  • Optionally add property rs485-rts-delay = <a b> to define:

    • a: Delay in milliseconds between CTS line assertion and start of transmission.

    • b: Delay in milliseconds between end of transmission and CTS line de-assertion.

Example: Configure RS-485 port on ConnectCore 6 Plus SBC

By default, none of the UART ports on the ConnectCore 6 Plus SBC device tree are configured in RS-485 mode.

ConnectCore 6 Plus SBC device tree
&uart5 {
	linux,rs485-enabled-at-boot-time;
	rs485-rts-active-high;
	rs485-rx-during-tx;
	rs485-rts-delay = <1 1>;
	status = "okay";
};

UART user space usage

The UART bus driver exposes device data through the sysfs at /sys/class/tty/ttymxcN/, where N is the port index, starting at zero.

UART device interface

You can access UART devices from user space through the device node /dev/ttymxcN, where N is the port index, starting at zero.

For information about using the serial port from user space, refer to the Serial Programming Guide for POSIX Operating Systems.