Using Vybrid UART Ports in Linux Print


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

First thing you need to do is enable additional UART interfaces in the kernel configuration. To do so, start the kernel configuration GUI (make kmenuconfig from the project directory) and proceed to the following menu: System Type -> Freescale MXC Implementations -> Vybrid UART configuration. In there, enable those UART ports you require in your specific application, for instance:

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 Vybrid pins. More on that right below.

Allocation of the Vybrid pins to specific I/O interfaces is defined for the Emcraft VF6 System-On-Module in linux/arch/arm/mach-mvf/board-emcraft-vybrid-som.c. When you have enabled UART interfaces that you require in your application, make sure that there is appropriate code in board-emcraft-vybrid-som.c that routes the UART signals to those Vybrid pins that you have allocated for UART in your design. For example, for UART1 there is the following code defined in board-emcraft-vybrid-som.c:

static iomux_v3_cfg_t mvf600_pads[] = {



Please refer to the VF6-SOM_UART_allocation.pdf for detailed information on allocation of the UART interfaces per Vybrid pins. Where an UART interface is available in the breadboard area of the SOM-BSB-EXT development baseboard, the document provides information regarding how to access those interfaces on the baseboard.

There must be a device node in the target root file system for each UART port to allow accessing it using standard Linux interfaces. The device nodes for serial ports are conventionally referred to as/dev/ttymxcn. Note also that that ttymxc0 corresponds to UART0, ttymxc1 to UART1 and so on. Make sure there is a device node for your UART interface in your <project>.initramfs file:

nod /dev/ttymxc0 0666 0 0 c 207 16
nod /dev/ttymxc1 0666 0 0 c 207 17
nod /dev/ttymxc2 0666 0 0 c 207 18
nod /dev/ttymxc3 0666 0 0 c 207 19
nod /dev/ttymxc4 0666 0 0 c 207 20
nod /dev/ttymxc5 0666 0 0 c 207 21

Each device node for the UART ports must have a unique minor number, the count starts with 16 for UART0 (/dev/ttymxc0). All UART ports share a single major number (207).

Having updated your project configuration as described above, build the bootable Linux image (<project>.uImage) by running make in the project directory. The procedure described here explains how to install Linux image (uImage) to the target.

When you boot the newly installed Linux image on the target, there will be a message in the kernel bootstrap print-out indicating that additional UARTs interfaces are available:

Serial: MVF driver
imx-uart.0: ttymxc0 at MMIO 0x40027000 (irq = 93) is a IMX
console [ttymxc0] enabled
imx-uart.1: ttymxc1 at MMIO 0x40028000 (irq = 94) is a IMX
imx-uart.5: ttymxc5 at MMIO 0x400aa000 (irq = 98) is a IMX

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".

As a simple test, the following command can be used to send a file to UART1 :

~ # cat test.file >/dev/ttymxc1
~ #