In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to carry on the embedded system application of Linux 2.6 kernel, the content is very detailed, interested friends can refer to, hope to be helpful to you.
With the rapid development of information technology with the combination of multimedia technology 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 more and more closely integrated with people's lives.
The operating system provides the most basic interface programs for users to use the computer and its external devices to manage the resources on the computer. With the expansion of the application field, in order to adapt to different applications, taking into account the flexibility, scalability and clippability of the system, a special computer system-embedded operating system, which is application-centered, based on computer technology, software and hardware can be tailored, and adapts to the application system, has strict requirements on function, reliability, cost, volume and power consumption.
Linux operating system is a free operating system with excellent performance, open source code and widely used. Because of its small size, cutback, high running speed and good network performance, it can be used as an embedded operating system. With the release of kernel 2.6, Linux has posed a great challenge to the existing mainstream RTOS providers in the embedded system market, such as VxWorks and WinCE, which have many new features and will become better embedded operating systems.
The low cost and openness of Linux create a fertile soil for its application in the field of embedded systems. This paper focuses on the new features of Linux 2.6 kernel and its advantages in embedded applications, and transplants it to the embedded platform to successfully support H.264 codec multimedia system.
1. Linux 2.6 kernel aims at the remarkable characteristics of embedded development.
Real-time reliability is a common requirement for embedded applications. Although Linux 2.6 is not a real 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, of which there are three most significant improvements: the use of preemptive kernel, more efficient scheduling algorithm and improved synchronization [4]. Linux 2.6 is a huge step forward in enterprise servers and embedded system applications. In the embedded field, Linux 2.6 not only improves the real-time performance, but also adds new architecture and processor types-- including support for MMU-less systems without hardware-controlled memory management solutions, which can support large-capacity memory models and microcontrollers. At the same time, it also improves the Icano subsystem and adds more multimedia application functions [4].
1. Preemptive kernel
Previous kernel versions (including 2.4 kernels) were not allowed to preempt tasks running in kernel mode (including user tasks that entered kernel mode through system calls) and had to wait for them to actively release CPU. This will inevitably lead to delays in some important tasks to wait for the system call to finish.
A kernel task can be preempted so that important user applications can continue to run. The main advantage of doing so is to greatly enhance the user interaction of the system.
The kernel is not a real RTOS (Real Time Operation System). It inserts preemption points into the kernel code, allowing the scheduler to abort the current process and call higher priority processes, and to avoid unreasonable system call delays by testing preemption points. The 2.6 kernel is preemptive to some extent and is more responsive than the 2.4 kernel. But not all kernel code snippets can be preempted, and key parts of kernel code can be locked to ensure that the data structure and state of CPU are always protected from preemption.
There is a contradiction between the software's need to meet the final time limit and the virtual memory request page scheduling. Slow page error handling will destroy the real-time responsiveness of the system, and the 2.6 kernel can compile non-virtual memory systems to avoid this problem, which is the key to solve the problem, but requires software designers to have enough memory to ensure the execution of tasks.
2. Effective scheduler
Version 2.6 of the Linux kernel uses a new scheduler algorithm, called the O (1) algorithm, developed by Ingo Molnar, as shown in figure 1. It performs extremely well under high load and can scale well when there are many processors in parallel. In the past, schedulers needed to find entire ready task queues and calculate their importance to determine which task to call next, and the time required varied with the number of task. The O (1) algorithm no longer scans all the tasks every time, but is put into an active queue when the task is ready, and the scheduler schedules the appropriate task every time, so each scheduling is a fixed time. When the task runs, it allocates a time slice, and when the time slice ends, the task discards the processor and transfers it to the expiration queue according to its priority. After all the tasks in the active queue are scheduled, the two queue pointers are exchanged, and the expired queue becomes the current queue, and the scheduler continues to schedule the tasks in the current queue with a simple algorithm. In the case of multiprocessors, this can improve the efficiency of SMP, balance the load of processors, and avoid the jump of processes between processors.
3. Synchronization prototype and shared memory
Multi-process applications need to share memory and peripheral resources. In order to avoid competition, mutexes are used 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 blocks or continues to execute to achieve mutual exclusion, and this time-consuming system call is not necessary when the thread continues to execute. The Fast User-Space Mutexes supported by Linux2.6 can detect whether a thread needs to be blocked from user space and only execute a system call to terminate the thread when needed. It also uses scheduling priority to determine the process to be executed [4]. The processors of the multiprocessor embedded system need to share memory, and the symmetrical multiprocessing technology uses the same priority for memory access, which limits the scalability and processing efficiency of the system to a great extent. Linux2.6 provides a new management method-NUMA (Non Uniform Memory Access). According to the topological layout of processors and memory, NUMA gives different processors different levels of permissions to solve memory preemption bottlenecks and improve throughput when memory competition occurs.
4. POSIX threads and NPTL
The new threading model is based on a 1:1 threading model (one kernel thread for one user thread), including kernel support for the new NPTL (Native POSIX Threading Library), which is a significant improvement over the previous kernel threading method. The kernel also provides POSIX signals and POSIX high-resolution timers.POSIX signals that will not be 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 1kHz triggers to make all this simple, so that the progress can be effectively controlled.
5. Support of microcontroller
The Linux2.6 kernel adds support for a variety of microcontrollers. Previously, processors without MMU can only take advantage of some improved branch versions, such as uClinux, but the 2.6 kernel has integrated it into the new kernel and began to support a variety of popular MMU-free microcontrollers, such as Dragonball, ColdFire, Hitachi H8/300.Linux, which still supports multitasking on MMU-free controllers, but does not have memory protection. At the same time, many popular controllers are supported, such as S3C2410 and so on.
6. Application-oriented
Embedded applications have the characteristics of user customization, and the hardware designs are developed for specific applications, which brings problems to the system to support non-standardized design (such as IRQ management). In order to better implement it, a component-based operating system can be used. The subsystem architecture adopted by Linux2.6 is modular 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 achieve a variety of application development, such as Advanced Linux Sound Architecture (ALSA) and Video4Linux, which makes it more convenient for multimedia information processing; support for USB2.0, provides higher speed transmission, and adds Bluetooth wireless interface, audio data link and link-oriented data transmission L2CAP to meet the needs of short-distance wireless connections. It can also be configured as a purely user interface-free system without input and display in the 2.6 kernel.
II. Applied research
Transplant the embedded Linux 2.6.11.7 kernel system on the S3C2410 development board and apply it to the construction of H.264 multimedia system.
1. Establish a cross-compilation environment
To carry out kernel migration development on the host of RedHat9, it is necessary to establish a cross-compilation environment. Due to the adoption of some new features and instructions in the 2.6kernel, it is necessary to adopt a newer tool set, using binutils-2.15, gcc-3.4.2, glibc-2.2.5, linux-2.6.8 and glibc-linuxthreads-2.2.5 to build the cross-compilation tool chain. After the establishment, the tool chain path is added to the system path $PATH.
2. Kernel modification
The Linux 2.6.11.7 kernel adds support for S3C2410 chips and no longer requires any patch files. Modify the cross-compilation option ARCH=arm,CROSS_COMPILE=arm-linux-. for Makefile in kernel source code For hardware configuration, you need to add the partition information s3c_nand_info of FLASH to arch/arm/mach-s3c2410/devs.c or smdk2410.c, as shown in Table 1.
Table 1 NAND FLASH partition table
Partition name starting address size
Vivi 0x00000000 0x00020000
Param 0x00020000 0x00010000
Kernel 0x00030000 0x001c0000
Root 0x00200000 0x00200000
Usr 0x00400000 0x03c00000
Then add it to s3c_device_nand. Dev= {.platform_data= & s3c_nand_info}, add & s3c_device_nand to the _ _ initdata part of arch/arm/mach-s3c2410/mach-smdk2410.c to make the kernel initialize NAND FLASH information at startup.
3. Kernel compilation and loading
Proper configuration of the kernel is a tailored process. Since the kernel is initially set up according to the local system configuration, you can import the kernel source default s3c2410 configuration file to make it easy to load the kernel basic configuration and then select the desired options. Choose to support MTD device driver and NAND FLASH driver for MTD configuration; select all kinds of file systems (DEVFS, TMPFS, CRAMFS, YAFFS, EXT2, NFS) and network devices and protocols to be used; this system loads network chip CS8900 and USB support; in H.264 multimedia system, you also need to load Frame buffer to support LCD display function. After compiling the kernel source code using the cross-compilation tool, a kernel image named zImage is generated under arch/arm/boot/, and the kernel is loaded into the storage device FLASH of the development board using the download command in the command prompt mode of Boot loader. The compilation process (2.6 kernel compilation is simplified compared to previous versions):
Make mrproper
Make menuconfig (character interface, or make xconfig graphical interface, but requires support from the Qt library, while make gconfig requires support from the GTK library)
Make
Make bzImage
4. File system
Linux uses a file system to organize files and devices in the system, providing a unified interface for devices and user programs. Linux supports multiple file systems. This system uses a read-only root file system in CRAMFS format, while the USER area in FLASH uses a YA FFS file system format that supports reading and writing, so it is convenient to add your own applications.
In the root file system, the CRAMFS format is used to protect the basic settings of the system from being changed. Using DEVFS to establish and mount basic equipment, while using BusyBox is also a way to reduce the root file system, providing the basic instructions of the system; also need to establish some necessary directories, add the necessary configuration files, such as fstab, inittab, etc.; there is also an important work is to add the necessary dynamic function library for system applications. Use the generation tool mkcramfs to make the contents of the entire root file into an image file.
Mkcramfs rootfs rootfs.ramfs
The support for the YAFFS file system format requires adding the driver to the kernel code tree and fs/yaffs/, to modify the kernel configuration file so that the support for the file system can be loaded in the kernel compilation. Use the mkyaffs tool to format the NAND FLASH partition into the YAFFS partition, burn and write the application image generated by mkyaffsimage into the YAFFS partition, and automatically load the YAFFS partition by writing fstab at startup.
5. Network device driver
CS8900A's 10m network chip is used in the system, which uses S3C2410's nGCS3 and IRQ_EINT9, modifies linux/arch/arm/mach-s3c2410/irq.c accordingly, adds {SMDK2410_ETH_IO,S3C2410_CS2, SZ_1M, MT_DEVICE} to mach-smdk2410.c 's smdk2410_iodesc [], adds chip drivers drivers/net/arm/cs8900.h and cs8900.c to kernel source code, configures Makefile and Kconfig files for network device drivers, and adds CS8900A configuration options. This allows the driver of the network device to be loaded at kernel compilation time.
In the application of Linux2.6, we should also see some problems compared with previous versions of the kernel. There are varying degrees of deficiency in kernel compilation time, kernel image size, kernel space occupied by RAM, and system startup time relative to Linux2.4, but it is acceptable today when the hardware conditions are improving day by day, and some of them are inevitably brought about by the enhancement of functions. Although Linux is not a real real-time operating system, the improvement of kernel 2.6 can meet the needs of most applications, so the Linux2.6 kernel will play an important role in the field of embedded systems.
This is the end of the embedded system application of Linux 2.6 kernel. I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 233
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.