Using i.MX RT1050 UART Ports in Linux |
Unless you have reconfigured Linux to run the console on some interface other than the serial UART (LPUART1), the serial device driver is already enabled in your kernel configuration and Linux makes use of i.MX RT1050 LPUART1 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 RT1050 pins. More on that right below. Allocation of the i.MX RT1050 pins to specific I/O interfaces is defined in the projects/rootfs/rootfs.dts.IMXRT105X_NXPEVK file. For example, let's add LPUART8 to the system. Edit projects/rootfs/rootfs.dts.IMXRT105X_NXPEVK as follows:
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/ttyLP0 corresponds to LPUART1, /dev/ttyLP1 to LPUART2 and so on. Add the appropriate info:
Having updated your project configuration as described above, build the bootable Linux image (<project>.uImage) by running make in the project directory. There are several ways to deploy the resulted binary to the system, see Loading Linux images via Ethernet and TFTP and Installing Linux images to SD Card for example. Stop At U-Boot prompt and enable UART7 clocks:
After that, when you boot the newly installed Linux image on the target with run bootcmd, there will be a message in the kernel bootstrap print-out indicating that additional UARTs interfaces are available:
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 stadard 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 LPUART8 port is available at J23 connector of the NXP i.MX RT1050 EVK board, so you may connect your USB-UART converter as follows:
|