Entry: Linux 2.6 kernel embedded system applications

Source: Internet
Author: User
Tags posix

Entry: Linux 2.6 kernel embedded system applications

Original article: http://linux.ccidnet.com/art/302/20060629/592037_1.html

Abstract: Based on the analysis of the new features of the Linux 2.6 kernel, the 264 kernel and the new file system were transplanted on the S3C2410 Development Board and successfully supported the H.264 encoding and decoding multimedia system.

Keywords: Linux kernel embedded system S3C2410

With the rapid development of information technology combined with multimedia and communication technology and the wide application of the Internet, the PC era has also transitioned to the post-PC era. In the post-PC era with the rapid development of digital information technology and network technology, embedded technology is increasingly closely integrated with people's daily lives.

The operating system provides the most basic interface program for users to use computers and their external devices to manage resources on computers. As the application field expands, in order to adapt to different application scenarios, considering the flexibility, scalability, and scalability of the system, an application-centric, computer technology-based, software and hardware cropping, adapted to the application system's functional, reliability, cost, volume, power consumption requirements of a dedicated computer system-Embedded Operating System it is extended.

Linux is a free operating system with excellent performance, open source code, and widely used. Thanks to its small size, scalability, high running speed, and good network performance, can be used as an embedded operating system. With the release of the 2.6 kernel, Linux has posed great challenges to mainstream RTOS providers in the embedded system market, such as VxWorks and wince, which have many new features, it will become a better embedded operating system.

Linux's low cost and openness have created a fertile ground for its application in the field of embedded systems. This article focuses on the new features of Linux 2.6 kernel and its advantages in embedded applications. It is transplanted to the embedded platform and successfully supports H.264 encoding/decoding multimedia systems.

1 Linux 2.6 kernel has notable features for Embedded Development

Real-time reliability is a common requirement for embedded applications. Although Linux 2.6 is not a 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, with three of the most significant improvements: use kernel preemption, more effective scheduling algorithms, and synchronization improvement [4]. Linux 2.6 is a huge improvement in enterprise servers and embedded system applications. In the field of embedded systems, Linux 2.6 not only improves its real-time performance, but also facilitates system migration, at the same time, a new architecture and processor type were added, including support for MMU-less systems without hardware control memory management solutions, and support for large-capacity memory models and microcontroller, at the same time, the I/O subsystem has been improved and more multimedia application functions have been added [4].

1.1 kernel preemption

In earlier kernel versions (including the 2.4 kernel), tasks running in the core State are not allowed to be preemptible (including user tasks that enter the kernel mode through system calls ), you can only wait for them to manually release the CPU. This will inevitably lead to the delay of some important tasks waiting for the end of the System Call.

A kernel task can be preemptible so that important user applications can continue to run. The main advantage of this is to greatly enhance the user interaction of the system.

2.6 The kernel is not a real time operation system (RTOs). It inserts a preemption point in the kernel code, allowing the scheduler to stop the current process and call a process with a higher priority, test the preemption point to avoid unreasonable system call delay. The 2.6 kernel can be preemptible to a certain extent, providing better responsiveness than the 2.4 kernel. However, not all kernel code segments can be preemptible. You can lock the key part of the kernel code to ensure that the data structure and status of the CPU are always protected and not preemptible.

The software must meet the final time limit and schedule Virtual Memory Request pages. Slow page error processing will damage the system's real-time responsiveness, and 2.6 kernel can compile a non-virtual memory system to avoid this problem, which is the key to solving the problem, however, software designers are required to have enough memory to ensure task execution.

1.2 Effective scheduling program

The 2.6 Linux kernel uses a new scheduler algorithm developed by Ingo Molnar, known as the O (1) algorithm, as shown in 1. It performs extremely well under high load conditions, and can be well expanded when many processors run concurrently [2]. In the past, the scheduler had to look up the entire ready task queue and calculate their importance to determine the task to be called next. The time required changes with the number of tasks. The O (1) algorithm no longer scans all tasks each time. When the task is ready, it is placed in an active queue. The scheduler schedules the appropriate tasks each time, therefore, each scheduling is a fixed time. A time slice is allocated when the task is running. When the time slice ends, the task will discard the processor and go to the expired Queue according to its priority. After all the tasks in the active queue are scheduled, the two queues are switched and the expired queue becomes the current queue. The scheduler continues to schedule the tasks in the current queue with simple algorithms. This improves SMP efficiency in the case of multi-processor, balances the load of the processor, and avoids the process from jumping between processors.

1.3 synchronization prototype and shared memory

Multi-process applications need to share memory and peripheral resources. To avoid competition, they adopt a mutex method to ensure that resources are accessed by only one task at a time. The Linux kernel uses a system call to determine whether a thread is blocked or continues to execute to achieve mutex. When the thread continues to execute, this time-consuming system call is unnecessary. The Fast User-space mutexes supported by linux2.6 can detect from the user space whether the thread needs to be blocked, and only execute the system call termination thread when needed. It also uses the scheduling priority to determine the process to be executed [4]. In a multi-processor embedded system, each processor needs to share the memory. The Symmetric Multi-processing technology takes the same 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 ). According to the topology of the processor and memory, numa grants different levels of permissions to different processors in case of memory competition to solve the memory preemption bottleneck and improve the throughput.

1.4 POSIX thread and nptl

The new thread model is based on a thread model (a kernel thread corresponds to a user thread), including Kernel support for the new nptl (native POSIX threading library, this is a significant improvement to the previous kernel thread method. The 2.6 kernel also provides POSIX signals and POSIX high-resolution timers. POSIX signals is not lost and can carry communication information between threads or processors. The embedded system requires the system to execute tasks according to the schedule. POSIX timer can provide 1 kHz triggers to simplify all the tasks and effectively control the progress.

1.5 microcontroller support

The linux2.6 kernel is supported by multiple microcontroller types. MMU-free processors can only use improved branch versions, such as uClinux, And the 2.6 kernel has integrated them into the new kernel, and began to support a variety of popular MMU-free microcontroller, such as Dragonball, ColdFire, and Hitachi H8/300. Linux still supports multi-task processing without the MMU controller, but does not have the memory protection function. It also supports many popular controllers, such as S3C2410.

1.6 application-oriented

Embedded applications are customized by users, and hardware design is developed for specific applications. This poses problems for the system to support non-standardized design (such as IRQ management ). A component-based operating system can be used for better implementation. The subsystem architecture used in linux2.6 modularize the functions and can be customized to minimize the impact on other components. At the same time, linux2.6 provides support for a variety of new technologies to achieve various application development, such as advanced Linux sound architecture (ALSA) and video4linux, to facilitate multimedia information processing. USB2.0 USB2.0 support, provides higher-speed transmission, and adds bluetooth wireless interfaces, audio data links, and link-oriented data transmission L2CAP to meet short-distance wireless connection needs; in addition, in the 2.6 kernel, it can be configured as a pure non-user interface system without input or display.

2 Application Research

Transplant the embedded Linux 2.6.11.7 kernel system on the S3C2410 Development Board to build the H.264 multimedia system.

2.1 create a cross-compilation environment

To port the kernel on the redhat9 host, you must first establish a cross-compilation environment. Because some new features and commands are adopted in the 2.6 kernel, a newer toolset needs to be adopted to build a cross-compilation toolchain using binutils-2.15, gcc-3.4.2, glibc-2.2.5, linux-2.6.8 and glibc-linuxthreads-2.2.5, after the tool chain is created, add the tool chain path to the system path $ path.

2.2 kernel Modification

Linux 2.6.11.7 kernel supports the S3C2410 chip and no patch files are required. Modify the cross-compilation options arch = arm and cross_compile = arm-Linux-for makefile in the kernel source code -. For hardware configuration, you need to add the flash partition information in arch/ARM/mach-s3c2410/Devs. C or smdk2410.c, such as table 1.

Table 1 NAND Flash Partition Table

The start address of the partition name is large or small.

Vivi 0x00000000 0x00020000

Param 0x00020000 0x00010000

Kernel 0x00030000 0x001c0000

Root 0x00200000 0x00200000

USR 0x00400000 0x03c00000

Then, add the parameter value in the value of "initi_device_nand. dev = {. the _ initdata section in the arch/ARM/mach-s3c2410/mach-smdk2410.c is added to enable the kernel to initialize the NAND Flash information at startup.

2.3 kernel compilation and Loading

Configuring the kernel properly is a tailored process. Because the 2.6 kernel will perform initial settings based on the local system configuration, You can import the default kernel source code S3C2410 configuration file to facilitate loading the basic Kernel configuration and then select the required options. For MTD configuration, select support for MTD device drivers and NAND Flash drivers. select various file systems (devfs, tmpfs, cramfs, yaffs, ext2, and NFS) and network devices and protocols to be used, the system is loaded with a network chip CS8900 and USB support. 264 frame buffer needs to be loaded in multimedia systems to support LCD display. After the cross-compilation tool is used to compile the kernel source code, a kernel image named zimage will be generated under ARCH/ARM/boot, in the command prompt mode of boot loader, run the download command to load the kernel to the flash storage device of the Development Board. Compilation process (compared with the compilation process of previous versions, 2.6 kernel compilation is simplified ):

Make mrproper

Make menuconfig (character interface, or use the make xconfig graphical interface, but the QT library is required, while make gconfig requires the support of the GTK Library)

Make

Make bzimage

2.4 File System

Linux uses a file system to organize files and devices in the system, providing unified interfaces for devices and user programs. Linux supports multiple file systems. The system uses the cramfs-format read-only root file system, while the user area in Flash uses the ya FFS file system format that supports read and write, easy to add your own applications.

In the root file system, cramfs format is used to protect the basic settings of the system from being changed. Using devfs to create and mount basic devices, and using busybox is also a way to reduce the root file system, providing the basic commands of the system. You also need to create some necessary directories, add the required configuration files, such as fstab and inittab. An important task is to add the necessary dynamic function libraries for system applications. Use the generation tool mkcramfs to make the content in the entire root file directory into an image file.

Mkcramfs rootfs. ramfs

To support the format of the yaffs file system, you need to add the driver to the FS/yaffs/kernel under the kernel code tree and modify the Kernel configuration file so that you can load the support for the file system during kernel compilation. Use the mkyaffs tool to format the NAND Flash partition into the yaffs partition, burn the application image generated by the mkyaffsimage into the yaffs partition, and write the fstab to automatically load the yaffs partition at startup.

2.5 network device driver

The 10 m network chip of cs8900a is used in the system. It uses ngcs3 and irq_eint9 of S3C2410 and modifies Linux/ARCH/ARM/mach-s3c2410/IRQ accordingly. c, and add {smdk2410_eth_io, s3c2410_cs2, sz_1m, mt_device} to the mach-smdk2410.c drivers/NET/ARM/cs8900.h and cs8900.c, configure the makefile and kconfig files of the network device driver and add the cs8900a configuration option to load the driver of the network device during kernel compilation.

At the same time as the linux2.6 application, we should also see some problems with the previous version of the kernel. The kernel Compilation Time, kernel image size, memory occupied by the kernel, and system startup time are insufficient to varying degrees compared with linux2.4. However, it is acceptable that the hardware conditions are increasingly improved, in addition, some of the features are bound to be enhanced. Although Linux is not a real-time operating system, the improvement of the 2.6 kernel can meet most application requirements. Therefore, the linux2.6 kernel will be used in the embedded system field.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.