Using i.MX 6SoloX UART Ports in Linux Print

 

Unless you have reconfigured Linux to run the console on some interface other than the serial UART (UART1), the serial device driver is already enabled in your kernel configuration and Linux makes use of i.MX 6SoloX UART1 for the serial console and the high-level shell. This application note explains how to enable additional UART ports in Linux.

Do not enable any UART interfaces except for those that you plan to use in your application. For one thing, unless an UART interface is actually required, you want to keep it in reset in order to save some power. Another consideration is that UART signals may conflict with other I/O interfaces on the i.MX 6SoloX pads. More on that right below.

Allocation of the i.MX 6SoloX pins to specific I/O interfaces is defined in the projects/rootfs/rootfs.dts and linux/arch/arm/boot/dts/imx6sx.dtsi files.

For example, UART5 is defined as follows:

  • A node for UART5 is defined in linux/arch/arm/boot/dts/imx6sx.dtsi:
  • soc { ... aips2: aips-bus@02100000 { ... uart5: serial@021f4000 { compatible = "fsl,imx6sx-uart", "fsl,imx21-uart"; reg = <0x021f4000 0x4000>; interrupts = ; clocks = <&clks IMX6SX_CLK_UART_IPG>, <&clks IMX6SX_CLK_UART_SERIAL>; clock-names = "ipg", "per"; dmas = <&sdma 33 4 0>, <&sdma 34 4 0>; dma-names = "rx", "tx"; status = "disabled"; }; ... }; ... };

  • The UART5 interface is enabled, and the UART5 signals are configured on the i.MX 6SoloX pads KEY_ROW3, KEY_COL3, KEY_COL2, and KEY_ROW2 in projects/rootfs/rootfs.dts:
  • &uart5 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart5>; status = "okay"; fsl,uart-has-rtscts; }; &iomuxc { ... pinctrl_uart5: uart5grp { fsl,pins = < MX6SX_PAD_KEY_ROW3__UART5_RX 0x1b0b1 MX6SX_PAD_KEY_COL3__UART5_TX 0x1b0b1 MX6SX_PAD_KEY_COL2__UART5_RTS_B 0x1b0b1 MX6SX_PAD_KEY_ROW2__UART5_CTS_B 0x1b0b1 >; }; ... }

    There must be a device node in the target root file system for each UART port to allow accessing it using standard Linux interfaces. In the rootfs project, this device node is created by Linux automatically during the system bootup. Note that /dev/ttymxc0 corresponds to UART1, /dev/ttymxc1 to UART2 and so on. The appropriate alias is defined in linux/arch/arm/boot/dts/imx6sx.dtsi:

    aliases { ... serial4 = &uart5; ... };

When you boot the Linux image on the target, there is a message in the kernel bootstrap print-out indicating that the UART interface is available:

...
21f4000.serial: ttymxc4 at MMIO 0x21f4000 (irq = 294, base_baud = 1500000) is a IMX
...
/ # ls -l /dev/ttymxc4
crw------- 1 root root 207, 20 Jan 1 1970 /dev/ttymxc4

Typically, UART ports are used to connect various equipment such as modems, sensors, additional computers and so on. In Linux, serial ports are accessed from C-level user space code using the standard POSIX APIs. These APIs are extensively defined in various materials available in the Internet. For instance, try googling for something like this "How to access serial ports in C".

The UART5 port is available at the P12 connector of the Emcraft SLX-SOM-BSB development baseboard, so you may connect your USB-UART converter as follows:

i.MX 6SoloX Pad i.MX 6SoloX Function Emcraft SLX-SOM-BSB
Board Connection
KEY_ROW3 UART5_RXD P12.10
KEY_COL3 UART5_TXD P12.8
KEY_COL2 UART5_RTS P12.11
KEY_ROW2 UART5_CTS P12.13
GND GND P12.39

 

As a very simple test you may just loopback the RX and TX lines of UART5 on the Emcraft SLX-SOM-BSB board (short P12.10 and P12.8), and use the following commands to send/receive text to/from UART5:

  • Configure port and start the reader process:
  • / # stty -echo raw speed 115200 < /dev/ttymxc4
    / # cat /dev/ttymxc4 &

  • Write a string to UART5 and observe the echo coming from reader:
  • / # echo "Hello from IMX6SoloX over UART" > /dev/ttymxc4
    Hello from IMX6SoloX over UART
    / #