Who has UNIX 1. source code? Thank you very much. If you have it, send it to huxiongjiao@163.com.

Hello, design and application of embedded Linux system

Abstract: With the rapid development of embedded Linux system, embedded Linux has developed into an important branch of embedded operating system. This paper introduces the design of embedded Linux and several popular embedded Linux systems.

Keywords: embedded Linux

I. Introduction

Embedded Systems is a computer system that integrates operating system and functional software into computer hardware system according to the requirements of application, so as to realize the integration of software and hardware. Embedded system appeared in the late 196s. It was originally used to control electromechanical telephone exchanges, and now it has been widely used in industrial manufacturing, process control, communication, instruments, meters, automobiles, ships, aviation, aerospace, military equipment, consumer products and many other fields. The number of embedded systems far exceeds that of all kinds of general computer systems: the core CPU of computer systems, with an annual global output of about 2 billion, of which more than 8% are used in all kinds of highly specialized embedded systems.

generally speaking, any special software and hardware system with microprocessor can be called embedded system. Compared with general computing platforms, embedded systems often have the characteristics of single function, small size, low power consumption, high reliability, good tailoring, high integration of software and hardware, and relatively low computing power. For many years, there is no operating system in embedded devices for two main reasons: first, devices such as washing machines, microwave ovens and refrigerators only need a simple control program to manage a limited number of buttons and indicator lights, and there is no need to use the operating system; Secondly, it often only has limited hardware resources, which is not enough to support an operating system.

however, with the development of hardware, the embedded system becomes more and more complex, and many functions are gradually added to the initial control program, many of which can be provided by the operating system. As a result, Embedded Operating Systems appeared in the late 197s, which greatly simplified the design of application programs, effectively guaranteed the quality of software and shortened the development cycle. Simple ES generally does not use operating system, but only contains some control processes. However, with the increase of complexity of embedded operating system, simple process control cannot meet the requirements of the system, so it is necessary to consider using operating system as system software. Therefore, the embedded operating system came into being.

with the wide application of EOS, the industry has launched some successful EOS products. To sum up, EOS should have the following characteristics: compact, real-time, detachable, solidified code, weak interaction, strong stability and unified interface. At present, the most widely used EOS products include: Vxwork, QNX, PalmOS, WindowsCE, pSOS, Hopen OS (independently developed by domestic Kaisi Group) and so on. Among them, Vxwork is the most widely used and has the highest market share. Its outstanding feature is its strong real-time performance (priority preemption and rotation scheduling). Besides, its reliability and scalability are quite good. QNX is a very scalable system, and its core is less than one trillion with real-time POSIX environment and a complete window system. In contrast, the core of Microsoft WinCE is huge, and its real-time performance is not satisfactory. However, due to the friendly user interface of Windows series and API familiar to programmers, and bundled with IE, Office and other applications, it is gradually gaining more market share. Compared with these commercial operating systems, Linux has attracted more and more attention.

second, an overview of embedded Linux

Linux is a mature and stable network operating system. Implanting Linux into embedded devices has many advantages. First of all, the source code of Linux is open, and anyone can obtain and modify it to develop their own products. Secondly, Lirmx can be customized, and its system kernel is only about 134kB. A core program with Chinese system and graphical user interface can also be less than 1MB, and it is equally stable. In addition, it is compatible with most Unix systems, and the development and transplantation of application programs are quite easy. At the same time, because of its good portability, people have successfully made Linux run on hundreds of hardware platforms.

however, Linux is not specially designed for real-time applications, so if you want to run Linux in an embedded system with high real-time requirements, you must add real-time software modules to it. The kernel space where these modules run is the part of the operating system that realizes process scheduling, interrupt handling and program execution, so the wrong code may destroy the operating system, thus affecting the reliability and stability of the whole system. Linux has been widely used in the embedded field because of its many advantages, and a considerable number of embedded Linux systems have appeared. Representative ones include: uClinux, ETLinux, ThinLinux, LOAF, etc. ETLinux is usually used in small industrial computers, especially PC/14 modules. ThinLinux is aimed at dedicated camera servers, X-1 controllers, MP3 players and other similar embedded applications. LOAF is the abbreviation of Linux on a flop, which runs on the 386 platform.

III. Advantages of Linux as an embedded operating system

The advantages of Linux as an embedded operating system mainly include the following points:

1. It can be applied to various hardware platforms. Linux has been transplanted to various hardware platforms, which is very attractive for research and development projects with limited funds and time. The prototype can be transplanted to the specific hardware after being developed on the standard platform, which speeds up the development process of software and hardware. Linux uses a unified framework to manage hardware, and the change from one hardware platform to another has nothing to do with the upper application. Linux can be configured at will, without any license or business partnership, and the source code can be obtained for free. This makes it possible to adopt Linux as the operating system without any disputes about copyright. There is no doubt that this will save a lot of development costs. Built-in network support, but the embedded system has higher and higher requirements for network support. The high modularity of Linux makes it very easy to add components.

2. Linux is a general operating system similar to Unix, which is kernel-based, has complete memory access control, and supports a large number of hardware (including X86, Alpha, ARM and Motorola). Its program source code is all open, and anyone can modify it and distribute it under the GNU General Public License. In this way, developers can customize the operating system to meet their special needs.

3. Linux has perfect development tools that Unix users are familiar with, and almost all Unix system application software has been transplanted to Linux. Linux also provides a powerful network function, with a variety of optional window managers (X Windows). Its powerful language compilers GCC and C++ can also be easily obtained, which are not only mature and perfect, but also convenient to use.

iv. establishment of embedded Linux

a complete embedded Linux solution should include the embedded Linux operating system kernel, running environment, graphical interface and application software. Due to the special requirements of embedded devices, the kernel, environment and GUI of embedded Linux solutions are quite different from those of standard Linux. The main challenge is how to realize high-quality real-time task scheduling, graphical display, network communication and other functions in narrow FLASH, ROM and memory.

1. Streamlined kernel

The p>Linux kernel has its own architecture, among which process management, memory management and file system are its three most basic subsystems. Figure 1 simply shows its framework. User processes can directly access kernel resources through system calls or function libraries. Because the Linux kernel has such a structure, it is necessary to pay attention to the coordination between subsystems when modifying the kernel.

the embedded Linux kernel is generally cut from the standard Linux kernel. Users can configure the system according to their needs and eliminate unnecessary service functions, file systems and device drivers. After cutting and compressing, the system kernel is generally only about 3k, which is very suitable for embedded devices. Different from standard Linux, embedded Linux must be started from FLASH or ROM. The standard Linux startup code realizes the system initialization and booting the kernel from the floppy disk and hard disk O area. Embedded Linux is generally stored in FLASH or ROM, and standard LILO cannot boot. In systems that support direct boot from FLASH devices, such as uClinux of Huaheng Company, the boot program mainly completes the initialization of the hardware system and the decompression and shifting of the operating system. In a system that does not support booting directly from FLASH, FLASH devices can only be used as non-boot disks. At this point, a small operating system, such as embedded DOS, can be loaded from the hard disk or floppy disk first, and then the "Loadlin" loader can be executed to boot embedded Linux from FLASH.

The modification of standard Linux is mainly the modification of virtual memory and scheduler. Because the purpose of using virtual memory management in standard Linux system is to run multiple processes at the same time, the CPU time allocated by each process to be run is limited, and the utilization efficiency of resources is low. In this way, for embedded systems with high real-time requirements, real-time tasks often require CPU to have high burst processing ability, that is, it needs high processing efficiency in some cases, so it is necessary to shield the virtual memory management mechanism of the kernel. For embedded systems without hard disk devices, virtual memory management is not necessary. Embedded applications with strong real-time requirements can be realized by modifying the task scheduling module, mainly by adding many switching points to the kernel and device drivers. At this point, the system detects whether there is an unprocessed emergency interrupt, and if there is, it deprives the kernel of running and handles the interrupt in time. A better way to realize real-time service is to add a real-time kernel to the standard Linux kernel. The standard Linux kernel runs on the real-time kernel as a task, and the strong real-time task also runs directly on the real-time kernel, such as RT-Linux.

file system is essential for embedded Linux operating system. However, the standard Linux supports a large number of file systems, so all of them can be deleted except one to meet the normal operation needs of the system, and can be removed by using the original setting options. RamDisk technology and network file system technology are mainly used in general embedded device file system. RamDisk can reside in Flash and be loaded into memory at runtime.

2. Streamlined running environment

The usual running environment of p>Linux refers to the infrastructure for users to run any application, mainly including function library and basic command set. The standard Linux system provides users with both static and dynamic function libraries. The static function library is directly linked to the user application when generating the application. Dynamic libraries are linked only when the application is running. Because embedded system applications are generally pre-generated on the development platform, embedded systems only need to provide dynamic function libraries to applications. The function libraries needed for Linux application operation mainly include C library, mathematics library, thread library, encryption library, network communication library and so on. The most basic one is glib, the runtime of C language. This library mainly completes basic input and output, memory access and file processing. A standard glib library needs about 12kB of storage space. Considering that the embedded Linux kernel is often very small and the runtime is too big, we have done some streamlining work. There are two methods: (1) Using static connection method without using dynamic connection of the runtime at all; (2) Simplify the functions of this library.

on a desktop system, using dynamic connection can bring many benefits. Using dynamic link library, the application can be separated from the update and upgrade of function library, which is convenient for maintenance and allows multiple programs running at the same time to enjoy a piece of code. However, in embedded systems, it is rarely possible for multiple programs to be parallel, and the maintenance of programs, especially the maintenance and update of library functions, is not common. At this time, the advantages of using static connection are extremely obvious. Because static connection can only connect the parts used in the library into the program. Static connection can achieve better results when there are few applications (less than 5). In order to meet the needs of future expansion, we also adopt the second method, which streamlines the contents of library functions to keep only some basic functions, and another method is to adopt other C language runtime libraries. But these libraries have a great impact on compatibility.

the basic command set is also the basis for running user applications, mainly including initialization process init, terminal acquisition of getty, Shell and basic commands. The startup process of embedded system may be different from that of standard Linux, such as skipping the login process and starting the GUI directly. This requires modifying init, getty, etc. The standard Linux command set can't be directly applied to embedded environment because of the size problem. At present, there are two main solutions to the small command set: integration method and assembly method. The integration method reduces the overall volume of the command set by integrating the public part, and is implemented by C, which has good platform portability; The assembly method uses assembly programming to reduce the size of each command, which can make the size very small but its platform portability is poor.

3. GUI under embedded Linux

GUI plays an increasingly important role in embedded systems or real-time systems, such as PDA, DVD player, WAP mobile phone, etc., all of which need a complete and beautiful graphical user interface. The basic requirements of these systems for GUI include: (1) Lightweight and less resources; (2) High performance; (3) High reliability; (4) Configurable. These have also become important indicators for evaluating embedded systems. At present, the GUI on embedded Linux mainly includes winCE, Micro Window, compact X Window and MiniGUI (one of the free software that is well done in China). Xfree86, a standard Linux, can't run in an embedded environment because of its huge size and high requirements for running environment. Embedded GUI mainly reduces functions and performance to achieve small size and occupy less resources. At present, the GUI environment on embedded Linux is mainly