Mainstream embedded intelligent terminals, such as POS, logistics terminal, car navigation, industrial tablet, etc., all use Linux as the operating system (the essence of Android kernel is also Linux). When this kind of product needs to connect multiple peripherals, it is necessary to expand the external interface. The mainstream USB extension peripherals in PC industry have the problems of compatibility and stability in the practical application of embedded system, and the debugging is also complex. Therefore, at present, in the embedded field, the stable and universal extended peripheral mode is still serial port connection (including UART, RS232, RS485).
This project introduces the scheme of extending multiple serial ports of wk2x series UARTS under embedded Linux (Android), especially the ideas and principles of driver design scheme for serial port extension of embedded Linux.
The software of embedded system products mainly includes driver design, system transplantation and application App Design. This project mainly introduces the driver design of wk2x under Linux, which is the key and difficult point in the scheme design.
The driver of embedded system is the interface between Linux system kernel and device hardware, which maps system calls to specific operation of specific equipment for actual hardware. For specific relationship, please refer to the attached figure
Key points of scheme design:
In this way, the application program can operate the hardware device like the ordinary file. The user program only needs to care about the abstract file, and all the work dealing with the hardware is left to the driver. For example, to output a string of strings to the screen, we only need to write the string to the abstract file of the video card, and the real work of transferring the string to the video card is done by the driver.
In Linux, the driver is a part of the kernel. There are two loading methods when running in kernel mode
The driver can be statically compiled with the kernel. The disadvantage is that the kernel is relatively large, and if the driver fails, the whole system will crash;
It can also be compiled as a module and loaded dynamically when needed.
Wk2x serial port Android for opening Microelectronics The TTY standard device driver based on Linux kernel provides 2.6-3.0 / 3.1-4.4. The driver version above Linux 3.1 adopts DTS device tree architecture. These two versions are widely used at present and can be easily transplanted to other versions of Linux. The driver has been applied to many mass production platforms in Android 5.0-8.0 All of them worked stably for a long time.
Typical application cases:
At present, it has been successfully applied to Intel Atom, CSR, Qualcomm, MTK, Spreadtrum, Ruixin micro, Quanzhi, Junli, Junzheng and other master control platform solutions. In order to open microelectronics technology support, we can provide driver code source code for users, and help support users to transplant and adapt.