UCLinux operating system transplantation

xiaoxiao2021-03-05  25

(Fudan University Electronics Engineering Department Shensha, welcome to reprint, please keep this travel author information) L UCLinux Introduction L Hardware Architecture Introduction L Compilation Environment and Compilation Tools. l UClinux startup process L system source modification 1. UCLinux Introduction UClinux This English word Udem, MICRO, small meaning, c represents Control, control, the meaning of control, is Micro-Control-Linux, the literal understanding is " Linux system designed in the field of microcontrollations. " Uclinux is a source-opening operating system that does not have a hardware platform without Memory Management Unit. It is a variant of Linux, the main difference is that the memory management mechanism and process scheduling management mechanism, and in order to adapt to the demand for embedded applications, it uses the ROMFS file system, and doing the C language library on Linux. Simplified. 2. Hardware Architecture Introduction The hardware platform running UClinux mainly includes the following sections: CPU (ARMV4 instruction set compatible), UART, Memory Controller, Timer, Flash memory, SDRAM memory, interrupt controller, and DMA. 3. Compile the environment and compile tools. Most of the UClinux operating system source code is developed with C language, and some code directly related to hardware is implemented with a compilation of a certain CPU architecture. These source code can only compile, link with GNU GCC compilation tools. The GNU GCC can run on the Linux / UNIX operating system. If you want to run GCC on a Windows platform, you must install Cygwin. Cygwin can install a Linux running environment in Windows, which can run the program that can only run in Linux under Windows. In order to compile the operating system kernel running on the target CPU on the PC, you must also install a suitable cross-compiler. GCC provides ready-made cross-compilers for MIPS, ARM, M68K, Sharc, PowerPC. If there is no ready-made cross-compiler, you need to design it yourself. The GNU website provides some articles that develop new cross-compilers. Develop a new compiler, generally need the following steps: 1, write machine description scripts. The number of machine instructions and addressing methods for a certain CPU architecture, the number of data types, the number of data types, the number of data types, the number of data, the CPU floating point processing, the number of data types, the number of data types, and the number of data types, and use of each of the data types, the number of data, the CPU floating point processing, ENDIANESS, C language are described in terms of GCC Details of the architecture such as rules, stacks, and function call rules. 2, design code generator. GCC will generate an intermediate format file (Intermediate Reperesentation) after leming and grammar analysis of C language source files. In order to convert this intermediate format file to machine code for the specific CPU architecture, you need to design a code generator. 3, design assembler 4, design linker 4. UCLinux startup process UCLinux system startup can be divided into two steps: 1. Run Bootloader Initializer SRAM, SDRAM and other storage devices belong to volatile memory, and after powering It will be lost, so the kernel mirror of the operating system must be stored on a non-volatile storage medium such as Flash. However, the operating system is running, requiring some of the data such as data segments, stacks, pages (for operating systems using virtual addresses), and other content, etc., you need to run the operating system in RAM. Therefore, there is a need for a boot program to copy the kernel mirror of the operating system from the Flash memory to the RAM, and then perform the kernel of the operating system from the RAM. BootLoader is a program that can complete such a function. In essence, bootloader is not within the operating system kernel.

It is written in assembly language, so this part of the code does not have portability for different CPU architectures. This part of the code must be rewritten when porting the operating system. Specifically, BootLoader mainly completes the following works at the system startup: (1) Copy the operating system kernel to SDRAM, if it is the core of the compression format, it is necessary to decompress it. (2) Rewriting the system's MEMORY MAP, the original Flash start address is mapped to 0 address, and the start address of the RAM needs to be mapped to 0. (3) Set the stack pointer and clear the BSS section. It is used in the future when the C language program is executed and the subunion is called. (4) Change the PC value so that the CPU began to perform a real operating system kernel. 2. Run the operating system kernel bootloader program After performing the above work, through a jump instruction, turn the function start_kernel () in the INI directory in type C language source file main.c. Because BootLoader has created a initialization environment before this, the C function can start executing. The initialization of the entire operating system kernel is really started here.

The length of this function is relatively short, as follows: / asmlinkage void __init start_kernel (void) {char * command_line; unsigned long mempages; extern char saved_command_line []; / * * Interrupts are still disabled Do necessary setups, then * enable them *. / lock_kernel (); printk (linux_banner); setup_arch (& command_line); printk ( "Kernel command line:% s / n", saved_command_line); parse_options (command_line); trap_init (); init_IRQ (); sched_init (); softirq_init ( Time_init (); / * * Hack Alert! This is early. We're Enabling The console before * We've Done PCI setups etc, and console_init () Must be aware of * this. But we do want output early, . in case something goes wrong * / console_init (); #ifdef CONFIG_MODULES init_modules (); #endif if (prof_shift) {unsigned int size; / * only text is profiled * / prof_len = (unsigned long) & _etext - (unsigned long) & _Stext; PROF_LEN >> = PROF_SHIFT; SIZE = PROF_LEN * SIZEOF (unsigned int) Page_Size-1; Prof_Buffer = (unsigned int *) Alloc_bootmem (size) ;} Kmem_cache_init (); sti (); calibrate_delay (); #ifdef CONFIG_BLK_DEV_INITRD if (! Initrd_start && initrd_below_start_ok && initrd_start

转载请注明原文地址:https://www.9cbs.com/read-36066.html

New Post(0)