Arm Embedded systems often encounter multiple serial port application requirements, and arm chip system native UART number is limited, so it is necessary to extend more interfaces through other high-speed bus. In this paper, Toradex based on the NXPI.MX6D/6Q processor Apalis i.mx6d/q arm computer module, the Linux system through the Exar scheme to expand the 8-channel serial port.
The Apalis i.mx6d/q module itself can support up to 5 UART serial port outputs. Compatible with high speed tia/eia-232f (up to 5mbit/s). Supports 7, 8, or 9 (for RS485) bit data, 1 or 2-bit stop bits. UART1 is a full-featured serial port, the rest of the serial port can also support RTS and CTS signals.
In Linux systems, a serial port is usually reserved for application debugging development and system upgrade. Although SSH and other functions can also be used for remote network access and system debugging, but for embedded products, system startup, especially Uboot startup information, can help function debugging and problem locating. This part of the information can only be exported from the serial port. The Toradex module also needs to be Uboot when updating the Linux BSP.
Apalis the remaining 4 serial ports of the I.MX6Q/D module, in addition to the use of TTL level directly control the corresponding peripherals, can also be extended to rs232/rs485/rs422 commonly used industrial control port. For more serial port requirements, there are many ways to implement serial port expansion, such as via USB, SPI, Memory Bus, i²c and PCIe bus. Memory bus and PCIe have higher real-time capability relative to other buses, and can expand more serial ports on the same interface. For the number of serial ports and high-real-time data of the application can be preferred to choose these two expansion scenarios. At the same time, Memory bus and PCIe belong to high-speed signal bus, in the PCB cabling needs some special considerations. Toradex also provides free PCB design guidance for this purpose. We'll show you how to extend the 8-way serial port using the EXAR xr17v358 scheme based on the PCIe bus.
1). xr17v358 Program Introduction and Driver download
xr17v358 expansion of the 8 serial ports are supported rts/cts or DTR/DSR flow control function, each serial port with 256 bytes of FIFO, independent clock output, support half-duplex RS485, the maximum transmission speed of Mbps. The xr17v358 is connected to the Apalis i.mx6q/d using the PCIe 2.0 Gen 1 to ensure high-speed data transmission in real time. EXAR currently provides Windows and Linux drivers for xr17v358. Here we use its newest Linux drivers and migrate to the Apalis i.mx6 platform. Driver Source Download Address http://www.exar.com/common/content/document.ashx?id=20121
2). Configuring the compilation Environment
Before compiling, you also need to download the Linux kernel for Apalis i.mx6 and the cross-compilation tool.
a). Apalis i.mx6 Linux Kernel download
$ git clone-b toradex_imx_3.14.28_1.0.0_ga-nextgit://git.toradex.com/linux-toradex.git
b). Cross-Compilation tool download
$ wgethttp://releases.linaro.org/14.11/components/toolchain/binaries/arm-linux-gnueabihf/ Gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz
$ tar xvfgcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz
$ LN-SGCC-LINARO-4.9-2014.11-X86_64_ARM-LINUX-GNUEABIHF Gcc-linaro
$ Export Arch=arm
$ export path=~/gcc-linaro/bin/: $PATH
$ Export cross_compile=arm-linux-gnueabihf-
Note: The above path requires a directory that corresponds to the actual decompression of the cross-compilation tool.
c). Compile the Linux kernel and provide the necessary configuration files for xr17v358.
$ make Apalis_imx6_defconfig
$ make-j4 Uimage loadaddr=10008000
d). Compile xr17v358 Driver
Edit the Makefile file and point kernel_src to the directory where the Linux kernel resides
KERNEL_SRC =/home/ban/toradex/oe-core-tegra/linuxkernel/v2.5/mx6/toradex_imx_3.14.28_1.0.0_ga-next/ Linux-toradex
Keep running the make command to compile to ensure that the ARCH, path, and Cross_compile parameters mentioned above are still valid.
$ make
Successful compilation generates kernel module files for ARM processors Xr17v35x.ko
$ file Xr17v35x.ko
Xr17v35x.ko:ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), buildid[sha1]= 399121B7862105B185E24B45BA3522F14158295E, not stripped
e). Install the driver
Copy the Xr17v35x.ko to the Apalis i.mx6 module and install
root@apalis-imx6:~# Insmod Xr17v35x.ko
[151.156648] Exar PCIe (xr17v35x) serial driver revision:2.0
root@apalis-imx6:~# Lspci
00:00.0 PCI bridge:device 16C3:ABCD (REV01)
01:00.0 PCI BRIDGE:PLX Technology, Inc.pex 8605 PCI Express 4-port Gen2 Switch (rev AA)
02:01.0 PCI BRIDGE:PLX Technology, Inc.pex 8605 PCI Express 4-port Gen2 Switch (rev AA)
02:02.0 PCI BRIDGE:PLX Technology, Inc.pex 8605 PCI Express 4-port Gen2 Switch (rev AA)
02:03.0 PCI BRIDGE:PLX Technology, Inc.pex 8605 PCI Express 4-port Gen2 Switch (rev AA)
03:00.0 Serial Controller:exar corp.device 0358 (rev.)
The corresponding serial device files ttyXR0 to ttyXR7 appear in the/dev directory.
root@apalis-imx6:/dev# ls
AutoFS network_latency Tty18 tty60
Block Network_throughput tty19 tty61
Bus null Tty2 tty62
Char Port Tty20 tty63
Console PPP Tty21 Tty7
Cpu_dma_latency PTMX Tty22 Tty8
Cuse ptp0 tty23 Tty9
Disk pts tty24 ttyXR0
Dri ram0 tty25 ttyXR1
FB ram1 tty26 ttyXR2
Fb0 ram10 tty27 ttyXR3
FB1 ram11 tty28 ttyXR4
FB2 ram12 tty29 ttyXR5
FB3 ram13 tty3 ttyXR6
FD ram14 tty30 ttyXR7
f). Setting the baud rate
After the root@apalis-imx6:~# stty-f/dev/ttyxr0115200 driver is loaded, it can be used in Linux as normal as other serial ports.