| As an open soure operating system, Linux is born for embedded system. There are much more advantages in Linux than in any other operating system. It is totally free;anybody can access and modify it for his own reason., thus a low-cost operating system can be easily got;All standard internet protocol are supported, and a sub protocol family can be easily ported to embedded system;It is widely supported by hardware devices, and can run on microprocessores without MMU (Memory Mange Unit).All these make it suitable for embedeed system.But Linux was designed as a time-sharing operating system at the begin time, which focues on getting the best average performance. In most cases, what an embedded system needs is a realtime operating system, so the standard Linux can not meet the requirements .Much work has to be done on improving realtime performance. Up to now, many ways are applied to improve realtime performance of linux kernel, some of them are relatively successful.These ways focused on following fieild: add rescheduling point, improve its preempt ability;add another kernel to take over the standard linux kernel, make the added kernel take care of realtime interrupts;modify the standard linux interrupt, make interrupt handled as a task.A new solution arises to make interrtupts tasked, in this solution an interrupt service thread is designed to handle interrupts. This service thread is at the same level with realtime task, and can be scheduled just by the value of process's scheduling priority. It has a dynamic priority, which is determined by the interrupt in queues with the highest priority value, so the solution can avoid the reverse of priority. Interrupt may happen at any time, even realtime tasks with the highest scheduling prority can not prevent itself from taking time to handle interrupts, so these tasks may not complete in expected time. In our solution interrupt can be handled if only it has a higher priority than realtime task which is running, otherwise necessary information is saved to a special shared memory and interrupt just return. The solution learns a lot form RTLinux about its software interrupt simulation, a module is added to catch and save interrupts during the normalprocess of interrupt handling.Our solution has some sameness with Ingo Molnar, but all interrupts are handled by the serveice thread and the intrinsic fuction in standard linux are finally called to serve them. So it has less influence on system.The preserving interrupt gates are expanded for the sake of testing.Linux source code is also modified, so the preserving interrupt number can be recongnized. A virtual char device is designed, through which a user's program can communicate with kernel. All other interrupts are simulated by usinig the instruction "INT" except for the interrupt of parallel port. A testing service thread also designed to generate soft interrupts, user program can communicate with it through the virtual char decice, which can be used to change the testing strategy.Samsung s3c2410 microprocessor is used in our platform, and it has become a stand platform supported by linux.Ever since version 2.6.10, linux can run on it after few modification ,which just provide necessary information about Nand Flash to kernel. To make linux configure properly, the standard configuration of SMDK2410 can help a lot.Embedded systems are different in their hardware configuration. A bootloader is usually designed to initiaze hardware and boot operating system, and has a tough tie with specal platform. So each embedded system needs a bootloader of its own.A bootloader has been designed for our platform. After hardware initialization, our bootloader move linux kernel to proper memory area and prepare booting params for it, and then let the kernel take control of the left procees. Bootloader is always devided into two stages for the sake of improving portability. In stagel below steps are included: initialize hardware;prepare ram room for stage2, copy bootlaoder to ram;prepare for stack;jump to stage2. In stage2, the main task is to boot kernel: check the memory map, copy kernel and booting filesystem image to ram;parpare booting params for kernel;boot kernel. The source code is written in asm in stagel and C in stage2.The bootloader's compiling process is controlled by Makefile.Makefile is an auto compiling tool, which can help us a lot on compiling program. A source file can be auto compiled by its suffix.To compile bootloader,we need to design rules to explain how the source files are compiled and linked.After compilings ELF file is formed .Extra work is needed to drop some unnecessary section of the bootloader.After that a executablebootloader is got ,which contains only three section:text,data and bss.Embedded file system is usually constructed on Flash memory, which makes the linux traditional file system like ext2 unsuitable. Special file system is needed. According to system's requirement, Cramfs is finally choosed as system's booting file system. Cramfs is designed by Linus Torvalds, the founder of linux, and is a compressable and readonly file system. Cramfs has a compressed rate up to 2:1, so more memory can be left for system. The readonly characteristic prevents files from destroying and is good for improving system's reliability. Cramfs can reach a high speed when read and write. After adding kernel image and usrer application on booting file system, the embedded system is successfully constructed. |