About the start of the embedded system (SHARE FOR ALL)

  
 

Embedded Linux boot is divided into two parts, system boot and Linux boot. System booting will complete the CPU and related IO devices and load Linux into memory before Linux is loaded into memory. System booting is mainly implemented by the BootLoader. After the BootLoader loads the Linux kernel into memory, pass the power to LinuxKernel and enter the Linux boot section. The following is a detailed analysis of the startup process and the files used.

First, the system boot and BootLoaderBootLoader are very different from the PC due to the difference of the embedded system. Here, the startup of Hyper250 (Inter Xscale GDPXA250) will be analyzed as an example. Since there is no BIOS driver board, EnbeddedOS must be driven by the bootloader to complete all hardware and complete the hardware initialization. All initialization files are in the hyper250/Bootloader directory. First analyze the components of the boot: hyper250/Bootloader/X-Hyper250R1.1-Boot/src/start_xscale.S file contains two library files: hyper250/Bootloader/X-Hyper250R1.1-Boot/src/include/config. Hhyper250/Bootloader/X-Hyper250R1.1-Boot/src/include/start_xscale.h file config.h mainly completes the macro definition and setting of each hardware of the system, xscale.h mainly completes the setting of system chip and system operation .

The following analysis of the config.h file: (1) macro definition of the storage bus device: define the size of the Flash, word length and other information, define the base address, size and block size of the SRAM. (2) Dynamic memory setting: Define the size and base address of the DRAM. (3) Package information: package name, version number. (4) Set the position of the BOOT LOADER: the maximum value of the DRAM and SRAM, the DRAM load location, and the base address of the stack. (5) Set the location of the kernel: the base address of DRAM and SRAM, the maximum value of KERNEL, and the number of blocks in KERNEL. (6) Set the location of the file system: the base directory of the DRAM and SRAM, the maximum value of the file system, and the number of blocks in the file system. (7) Set the LOADER program: the static memory base address of the LOADER program, the maximum value of the LOADER program, and the number of blocks. (8) Network settings The following analysis starts_xcalse.h file: (1) defines the memory base address (A0000000) (2) defines the offset base address (40D00000) and the offset of the interrupt protection stack (3) defines the clock management base address ( 41300000) and register offset and its initial value (4) define the GPIO interface register base address (40E00000) and the offset of each register (5) define the initial value of each register of the GPIO interface (6) define the memory control register base address (48000000 And the offset of each register (7) defines the initial value of the memory control register (8) defines the parameters of the power management register (9) defines the base address of the FFUART register (40100000) and the offset of each register (10) defines each FFUART The initial value of the register is analyzed by the start_xcalse.S file: (1) setting the interrupt base address (40D00000), completing the initialization of the interrupt protection stack (2) initializing the GPIO interface (3) initializing the memory SDRAM (4) copying the bootloader from the flash to In SDRAM (5) load the Linux kernel image, load the kernel from Flash (000C 0000) into SDRAM (A0008000). (6) Set the protection stack (7) to call main.c's main function c_main() above start_xcalse. S initializes system-related hardware through an assembly file written by the APCS programming standard And completed the loading of BootLoader's load memory and Linux kernel, and finally transferred the power to main.c. The following will analyze the main.c file: hyper250/Bootloader/X-Hyper250R1.1-Boot/src/main.c and two library files hyper250/Bootloader/X-Hyper250R1.1-Boot/src/include/main.hhyper250/Bootloader/X-Hyper250R1.1-Boot/src/include/scc.h #2

Second, Linux boot process analysis

1.Makefile analysis: Analysis of arch/arm/boot/When the files in the compressed directory are used, the analysis of the Makefile is very important, because the kernel will be generated in this directory. The main work here is the compression and decompression of the kernel. This directory will generate vmlinux, head.o, misc.o, head-xscale.o, and piggy.o files after compilation. Among them vmlinux is a kernel that has not been compressed. Head.o is the kernel's header file, responsible for the initial setup. Misc.o will be primarily responsible for the decompression of the kernel, which is after head.o. The head-xscale.o file is primarily for Xscale initialization and will be merged with head.o at link time. Piggy.o is an intermediate file, which is actually a compressed kernel, but there is no link to the initialization file and the extracted file. 2.Decompress analysis: After the BootLoader completes the booting of the system and calls the Linux kernel into memory, call bootLinux(), which will jump to the beginning of the kernel. If the kernel is not compressed, it can be started. If the kernel is compressed, it will be decompressed, and there is a decompression program in the compressed kernel header. The first file source location of the compressed kernel entry is in arch/arm/boot/compressed/head.S. It will call the function decompress_kernel(), which is in the file arch/arm/boot/compressed/misc.c, decompress_kernel() calls proc_decomp_setup(), arch_decomp_setup(), and then prints out the message "Uncompressing Linux" ...” after calling gunzip(). Put the kernel in the specified location. The files that are first run are: arch/arm/boot/compressed/head.Sarch/arm/boot/compressed/head-xscale.Sarch/arm/boot/compressed/misc.c These files are mainly used to extract the kernel and start it. Kernel image. Once the kernel is booted, the memory space occupied by these files will be released. Moreover, once the system is restarted by reset, when the BootLoader puts the compressed kernel into memory, the code must first be executed. The following analysis of the head.S file: (1) For the DEBUG output settings of various Arm CPUs, the macro is used to unify the operation. (2) Set the kernel start and end addresses and save the architecture ID. (3) If the CPU is used in the ARM2 or higher, the normal user mode is used, then it is upgraded to the super user mode, and then the interrupt is turned off. (4) Analyze the LC0 structure delta offset to determine whether it is necessary to reload the kernel address (r0 stores the offset and determines whether r0 is zero). Whether you need to reload the kernel address here, I thought mainly to analyze arch/arm/boot/Makefile, arch/arm/boot/compressed/Makefile and arch/arm/boot/compressed/vmlinux.lds.in three files, mainly to see vmlinux The location of the main section of the .lds.in link file, LOAD_ADDR(_load_addr)=0xA0008000, and the position of TEXT_START(_text,_start) is only set to 0, BSS_START(__bss_start)=ALIGN(4). For such a result, it depends on the way the kernel is decompressed, that is, whether the kernel is decompressed in memory (RAM) or FLASH, because here, our BOOTLOADER moves the compressed kernel (zImage) to RAM 0xA0008000. Location, our compression kernel is arranged in memory (RAM) starting from 0xA0008000 address, so our r0 gets the offset address (0xA0008000). The next step is to translate the relative address of the kernel image into the physical address of the memory, which is the overloaded kernel address.

Copyright © Windows knowledge All Rights Reserved