The operating system provides the most basic interface program for users to use computers and their external devices, and manages the resources on the computer. With the expansion of application fields, in order to adapt to different application occasions, considering the flexibility, scalability and tailorability of the system, a special-purpose computer system centered on applications, based on computer technology, with tailorable software and hardware, and adapting to the strict requirements of application systems on functions, reliability, cost, volume, and power consumption - embedded operating system has been born.
The Linux operating system is a free operating system with excellent performance, open source code and wide application. It can be used as an embedded operating system due to its advantages such as small size, scalability, high running speed and good network performance. With the release of the 2.6 kernel, Linux has posed a huge challenge to the existing mainstream RTOS providers in the embedded system market, such as VxWorks and WinCE, and has many new features, which will become a better embedded operating system.
The low cost and openness of Linux create fertile soil for its application in the field of embedded systems. This paper focuses on the new features of the Linux 2.6 kernel and its advantages in embedded applications, and transplants it to an embedded platform to successfully support H.264 codec multimedia systems.
1 Linux 2.6 kernel for embedded development of significant features
Real-time reliability is a common requirement for embedded applications. Although Linux 2.6 is not a true real-time operating system, its improved features can meet the response requirements. Linux 2.6 has added improvements to the kernel body to improve interrupt performance and scheduling response time. The three most significant improvements are: the use of a preemptible kernel, a more efficient scheduling algorithm, and improved synchronization<4>. In the field of enterprise servers and embedded system applications, Linux 2.6 is a huge step forward. In the embedded field, in addition to improving its real-time performance and making system porting easier, Linux 2.6 also adds new architectures and processor types - including support for MMU-less systems without hardware-controlled memory management solutions, which can support large-capacity memory models and microcontrollers, and also improves the I/O subsystem and adds more multimedia application functions<4>.
1.1 Preemptible kernel
In previous kernel versions (including the 2.4 kernel), it is not allowed to preempt tasks running in kernel mode (including user tasks that enter kernel mode through system calls), and they can only wait for them to actively release the CPU. This will inevitably cause some important tasks to be delayed to wait for the system call to end.
A kernel task can be preempted so that important user applications can continue to run. The main advantage of this is that it greatly enhances the user interactivity of the system.
The 2.6 kernel is not a true RTOS (Real Time Operation System). It inserts preemption points in the kernel code, allowing the scheduler to terminate the current process and call a higher priority process. It avoids unreasonable system call delays by testing the preemption points. The 2.6 kernel is preemptible to a certain extent and has better responsiveness than the 2.4 kernel. However, not all kernel code segments can be preempted. The key parts of the kernel code can be locked to ensure that the CPU data structure and state are always protected and not preempted.
The need for software to meet the final time limit and virtual memory request paging are in conflict. Slow page fault handling will destroy the real-time responsiveness of the system, and the 2.6 kernel can compile a system without virtual memory to avoid this problem, which is the key to solving the problem, but requires software designers to have enough memory to ensure the execution of tasks.
1.2 Effective Scheduler
The Linux kernel version 2.6 uses a new scheduler algorithm developed by Ingo Molnar, called the O(1) algorithm, as shown in Figure 1. It performs extremely well under high load conditions and can also scale well when there are many processors in parallel<2>. In the past, the scheduler needed to search the entire queue of ready tasks and calculate their importance to decide which task to call next. The time required varies with the number of tasks. The O(1) algorithm no longer scans all tasks each time. When a task is ready, it is placed in an active queue. The scheduler schedules the appropriate task from it each time, so each scheduling is a fixed time. When the task runs, it is assigned a time slice. When the time slice ends, the task will give up the processor and move to the expired queue according to its priority. After all the tasks in the active queue are scheduled, the two queue pointers are exchanged, the expired queue becomes the current queue, and the scheduler continues to schedule the tasks in the current queue with a simple algorithm. This can further improve the efficiency of SMP in the case of multiple processors, balance the load of processors, and avoid process jumping between processors.
1.3 Synchronization Prototypes and Shared Memory
Multi-process applications need to share memory and peripheral resources. To avoid competition, mutual exclusion is used to ensure that resources are accessed by only one task at a time. The Linux kernel uses a system call to decide whether a thread should be blocked or continue to execute to achieve mutual exclusion. When the thread continues to execute, this time-consuming system call is no longer necessary. Fast User-Space Mutexes supported by Linux2.6 can detect from user space whether a thread needs to be blocked, and only execute a system call to terminate the thread when necessary. It also uses scheduling priority to determine the process to be executed <4>. Multi-processor embedded systems need to share memory between processors. Symmetric multi-processing technology uses equal priority for memory access, which greatly limits the scalability and processing efficiency of the system. Linux2.6 provides a new management method - NUMA (Non Uniform Memory Access). NUMA gives different levels of permissions to different processors based on the topological layout of processors and memory when memory contention occurs to solve the memory preemption bottleneck and improve throughput.
1.4 POSIX threads and NPTL
The new thread model is based on a 1:1 thread model (one kernel thread corresponds to one user thread), including kernel support for the new NPTL (Native POSIX Threading Library), which is a significant improvement over the previous kernel threading approach. The 2.6 kernel also provides POSIX signals and POSIX high-resolution timers. POSIX signals will not be lost and can carry communication information between threads or processors. Embedded systems require the system to execute tasks according to a schedule, and POSIX timers can provide 1kHz triggers to make this simple, so that progress can be effectively controlled.
1.5 Microcontroller Support
The Linux 2.6 kernel has added support for a variety of microcontrollers. Previously, processors without MMU could only use some improved branch versions, such as uClinux, but the 2.6 kernel has integrated it into the new kernel and started to support a variety of popular microcontrollers without MMU, such as Dragonball, ColdFire, and Hitachi H8/300. Linux still supports multitasking on controllers without MMU, but there is no memory protection function. At the same time, it also adds support for many popular controllers, such as S3C2410. [page]
1.6 Application-oriented
Embedded applications are user-customized, and hardware designs are developed for specific applications, which brings problems to the system in supporting non-standard designs (such as IRQ management). In order to better achieve this, a componentized operating system can be used. The subsystem architecture adopted by Linux2.6 modularizes functions and can be customized with minimal impact on other parts. At the same time, Linux2.6 provides support for a variety of new technologies to realize various application development, such as Advanced Linux Sound Architecture (ALSA) and Video4Linux, which make multimedia information processing more convenient; support for USB2.0, providing higher-speed transmission, adding Bluetooth wireless interface, audio data link and link-oriented data transmission L2CAP to meet the needs of short-distance wireless connection; and in the 2.6 kernel, it can also be configured as a pure user-free interface system without input and display.
2 Applied research
The embedded Linux 2.6.11.7 kernel system was ported to the S3C2410 development board and applied to building the H.264 multimedia system.
2.1 Establishing a cross-compilation environment
To develop kernel porting on a RedHat9 host, you first need to establish a cross-compilation environment. Since the 2.6 kernel uses some new features and instructions, you need to use a newer tool set, binutils-2.15, gcc-3.4.2, glibc-2.2.5, linux-2.6.8, and glibc-linuxthreads-2.2.5 to establish a cross-compilation tool chain. After establishment, add the tool chain path to the system path $PATH.
2.2 Kernel modification
The Linux 2.6.11.7 kernel has added support for the S3C2410 chip, and no patch files are needed. Modify the cross-compilation options ARCH=arm, CROSS_COMPILE=arm-linux- in the Makefile in the kernel source code. For hardware configuration, add the FLASH partition information s3c_nand_info in arch/arm/mach-s3c2410/devs.c or smdk2410.c, as shown in Table 1.
|
Then add .dev={.platform_data= &s3c_nand_info} in s3c_device_nand, and add &s3c_device_nand in the __initdata section of arch/arm/mach-s3c2410/mach-smdk2410.c to enable the kernel to initialize the NAND FLASH information at startup.
2.3 Kernel compilation and loading
Properly configuring the kernel is a tailor-made process. Since the 2.6 kernel will be initially set up according to the local system configuration, you can import the default s3c2410 configuration file of the kernel source code to facilitate loading the basic kernel configuration, and then select the required options. For the MTD configuration, select to support the MTD device driver and NAND FLASH driver; select to support various file systems (DEVFS, TMPFS, CRAMFS, YAFFS, EXT2, NFS) and network devices and protocols to be used. This system loads the network chip CS8900 and USB support; in the H.264 multimedia system, it is also necessary to load the Frame buffer to support the LCD display function. After compiling the kernel source code using the cross-compilation tool, a kernel image named zImage will be generated under arch/arm/boot/. Use the download command in the command prompt mode of the Boot loader to complete the kernel loading into the storage device FLASH of the development board. Compilation process (compared to the compilation process of previous versions, the 2.6 kernel compilation is simplified):
make mrproper
make menuconfig (character interface, or use make xconfig graphical interface, but it requires the support of Qt library, and make gconfig requires the support of GTK library)
make
make bzImage
2.4 File System
Linux uses the file system to organize files and devices in the system and provide a unified interface for devices and user programs. Linux supports multiple file systems. This system uses the read-only root file system in CRAMFS format, and uses the YAFFS file system format that supports read and write in the USER area of FLASH, which is convenient for adding your own applications.
In the root file system, the CRAMFS format is used to protect the basic settings of the system from being changed. DEVFS is used to implement the establishment and mounting of basic devices. At the same time, using BusyBox is also a way to reduce the root file system, providing basic instructions for the system; it is also necessary to create some necessary directories and add the required configuration files, such as fstab, inittab, etc.; another important task is to add the dynamic function library necessary for system applications. Use the generation tool mkcramfs to make the contents of the entire root file directory into an image file.
mkcramfs rootfs rootfs.ramfs
To support the YAFFS file system format, you need to add the driver to the kernel code tree under fs/yaffs/, modify the kernel configuration file, and then load the support for the file system during kernel compilation. Use the mkyaffs tool to format the NAND FLASH partition as a YAFFS partition, burn the application image generated by mkyaffsimage into the YAFFS partition, and automatically load the YAFFS partition by writing fstab at startup.
2.5 Network Device Drivers
The system uses the 10M network chip of CS8900A, which uses nGCS3 and IRQ_EINT9 of S3C2410. Modify linux/arch/arm/mach-s3c2410/irq.c accordingly, and add {SMDK2410_ETH_IO,S3C2410_CS2, SZ_1M, MT_DEVICE} in smdk2410_iodesc<> of mach-smdk2410.c. Add the chip drivers drivers/net/arm/cs8900.h and cs8900.c to the kernel source code, configure the Makefile and Kconfig files of the network device driver, and add the configuration options of CS8900A, so that the network device driver can be loaded when the kernel is compiled.
When using Linux 2.6, we should also see some problems compared with previous versions of the kernel. Compared with Linux 2.4, there are some shortcomings in kernel compilation time, kernel image size, kernel RAM space occupied, and system startup time, but they are acceptable in today's increasingly advanced hardware conditions, and part of it is also due to the inevitable result of enhanced functions. Although Linux is not a true real-time operating system, the improvements of the 2.6 kernel can meet most application requirements, so the Linux 2.6 kernel will be very useful in the field of embedded systems.
Previous article:CAN bus embedded driver programming based on uclinux
Next article:Design of mobile TV software and hardware based on S3C2440A T-DMB
Recommended ReadingLatest update time:2024-11-16 20:46
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- UF2 bootloader for ESP32-S2
- How to assign initial values to a continuous RAM range in C2000 chip
- The Raspberry Pi with built-in keyboard is here. Is $70 a good deal?
- [Basic Operation Tutorial] How to use the ATG-2021H power signal source?
- Accelerating 5G network deployment in the n258 frequency band using compact 5G antenna technology
- MSP430 MCU interrupt
- When processing this signal, how do we calculate Z if we know the coordinates of Z-1, Z0, and Z1?
- Zigbee (CC2530) connected to esp8266 can only send but not receive
- Mini RP2040 development board minik
- Analysis of the Design Method of DSP and Slow Peripheral Device Interface