UART ===== This guide will show you how to use the UART channels on the phyCORE-i.MX8X development kit Carrier Board. .. image:: ../../images/phycore-imx8x/pcm-065_uart.webp :width: 800px .. note:: Please note that the PCB version 1491.1 has a different location for the X59 header. In more recent revisions of the carrier board (1491.2) the header was relocated to be closer to the center of the board. .. image:: ../../images/phycore-imx8x/pcm-065_uart-x59-1491-2-header-correction.webp :width: 400px The UART channels correspond to the following connectors and system paths. .. list-table:: UART Channels :header-rows: 1 * - Hardware Interface - Connector - Sysfs Path * - UART0 - X51 (Micro USB) - /dev/ttyLP0 * - UART1 - X99 (DB9 - RS232) - /dev/ttyLP1 * - UART2 - X59 (General Purpose Header) - /dev/ttyLP2 .. note:: All of the UART interfaces have muxing options available. Please refer to our :ref:`BootingEssentials-8X` page for more information. The FTDI device connected to UART0 also provides access to the M40_UART0 through the same connector (not supported in i.MX8X ALPHA1 release). The connector X99 allows for the use of UART1 a General Purpose (GP) UART (ttyLP1), which is translated to RS-232 levels. Note this UART is muxed with BT functionality. The connector X59 allows for the use of UART2 a General Purpose (GP) UART (ttyLP2). Note this UART is muxed with the CAN interface and an overlay must be applied in U-Boot. Requirements -------------- * Micro-USB Cable (Included in kit) * UART0 * `RS-232 to USB adapter cable `_ * UART1 * `USB to TTL Cable 3 pin `_ * UART2 * 3x `M/M Jumper Wire `_ * UART2 Hardware Setup ---------------- **UART0 (Debug)** * This is the default communication interface with the development kit. .. image:: ../../images/phycore-imx8x/pcm-065_uart0.webp :width: 500px **UART1** * Connect the RS-232 to USB adapter cable between the Host PC and X99. .. image:: ../../images/phycore-imx8x/pcm-065_uart1.webp :width: 500px **UART2** .. note:: This is not a standard UART and requires the use of female to female jumper wires. Additionally, UART2 is muxed with the CAN interface through Switch S6 on the carrier board. * Change S6 to UART2 .. image:: ../../images/phycore-imx8x/pcm-065_uart2.webp :width: 500px * Using female to female jumper wires, connect between the pins of connector X59 and the RS-232 to USB adapter cable using the table and images below. Connect the other end of the RS-232 cable to your host PC. .. list-table:: TTL Cable and X59 Header Signals :stub-columns: 1 * - GND - Black Connecter - Pin 9 (X59) * - TXD - Orange Connecter - Pin 6 (X59) * - RXD - Yellow Connecter - Pin 5 (X59) .. image:: ../../images/phycore-imx8x/pcm-065_uart2_x59-pin-out.webp :width: 500px .. image:: ../../images/phycore-imx8x/pcm-065_uart2-x59-ttl.webp :width: 500px * With the default console (UART0) connected, power on the kit and stop in U-Boot. * Apply the device tree overlay that enables the UART2 interface. Then boot into Linux. .. code-block:: none :caption: Target (U-boot) setenv overlay_files phytec-imx8qxp-uart2.dtbo boot UART1 & UART2 Communication ----------------------------- * Open a terminal on your host PC, choose the COM port associated with the UART channel and make sure it has the following port settings. .. list-table:: COM Port Settings :header-rows: 0 * - Baud Rate - 115200 * - Data - 8-bit * - Parity - none * - Stop Bit - 1 * - Flow Control - none * In Linux setup which UART channel you would like to use (/dev/ttyLP1 or /dev/ttyLP2) and then echo a test message through the UART channel to your other opened terminal. .. code-block:: none :caption: Target (Linux) stty -F /dev/ttyLP1 115200 echo 'Testing GP UART!' > /dev/ttyLP1 .. code-block:: none :caption: Expected Output Testing GP UART! * Now set up your default UART0 channel to listen for data from the UART channel you are using (/dev/ttyLP1 or /dev/ttyLP2). .. code-block:: none :caption: Target (Linux) cat /dev/ttyLP1 * Type something into your secondary UART console and hit enter. .. code-block:: none :caption: UART1 or UART2 Console Input Testing! .. code-block:: none :caption: Expected Output Testing! * Use Ctrl+C to stop UART0 from listening for new data. Enabling UART1 or UART2 as an Additional Serial Console --------------------------------------------------------- * From the default UART channel (UART0), use system control to enable and start the desired UART channel (/dev/ttyLP1 or /dev/ttyLP2). .. note:: Note that this setting will persist between boots but will not affect the default console in U-Boot and Linux. * Enable your desired UART channel in system control. .. code-block:: none :caption: Target (Linux) systemctl enable serial-getty@ttyLP1.service .. code-block:: none :caption: Expected Output Created symlink /etc/systemd/system/getty.target.wants/serial-getty@ttyLP1.service -> /lib/systemd/system/serial-getty@.service. * Start the service for the UART channel. .. code-block:: none :caption: Target (Linux) systemctl start serial-getty@ttyLP1.service * You should now see the login prompt on the console linked to your desired UART channel. Type "root" to login. .. code-block:: none :caption: UART1 or UART2 Console Output imx8x-phycore-kit login: * Test the console input/output using the echo command. .. code-block:: none :caption: Target (Linux) echo "hello from ttyLP0" > /dev/ttyLP1 .. code-block:: none :caption: UART1 or UART2 Console Output hello from ttyLP0 .. code-block:: none :caption: UART1 or UART2 Console Input echo "hello from ttyLP1" > /dev/ttyLP0 .. code-block:: none :caption: Expected Output (Linux) hello from ttyLP1 * Use the following commands to disable the new serial console. .. code-block:: none :caption: Target (UART1 Linux Console) systemctl stop serial-getty@ttyS4.service systemctl disable serial-getty@ttyS4.service