Bootloader Startup Process Analysis

Source: Internet
Author: User

The START process of bootloader is generally divided into two phases: stage1 and stage2. The following describes the two phases respectively:

1. stage1

(1) complete basic hardware initialization. Initialization mainly includes shielding all interrupts, setting the CPU speed and clock frequency, Ram initialization, initializing LEDs, disabling CPU Internal commands, and data cache.

(2) Prepare Ram space for loading stage2. To accelerate the execution, stage2 is usually loaded into the ram space for execution. Therefore, an available Ram space range must be prepared for the stage2 loaded with bootloader.

(3) Copy stage2 to ram. Determine the start address and end address of the stage2 executable image on the solid state storage device and the start address of the ram space.

(4) set the stack pointer sp. This is to prepare the C language code for executing stage2.

 

2. stage2

(1) Jump to the main entry function in assembly language

(2) to implement more complex functions and achieve better code readability and portability, stage2 code is usually implemented in C language. When compiling and linking bootloader, you cannot use any supported functions in the glibc library.

(3) initialize hardware devices such as serial port and timer. You can output some print information before initializing these devices.

(4) memory ing of the detection system. The so-called memory ing refers to specifying the address ranges allocated in the entire 4 GB physical address space for addressing the system's Ram unit.

(5) load the kernel image and the root file system image, including planning the layout of memory usage and copying data from flash.

(6) set the kernel startup parameters.

 

U-boot directory and Storage Principles

Board

And some existing Development Board related files, such as makefile and U-Boot.lds are related to the specific development board hardware and address allocation.

 

Common

C files that are not related to the architecture and implement various commands

 

CPU

CPU-related files. The subdirectories are named after the CPU supported by U-boot, such as arm926ejs, MIPS, mpc8260, and NIOS. Each specific subdirectory contains the CPU. C and interrupt. c, start. s. CPU. c. initialize the CPU, set the command cache and data cache, and interrupt. c. set various system interruptions and exceptions, such as switch interruptions, clock interruptions, software interruptions, prefetch suspensions, and undefined commands. S is the first file executed when u-boot is started. It mainly sets the system stack and working mode to lay the foundation for I to enter the C program.

 

Disk

Partition processing code driven by disk

 

Doc

Document

 

Drivers

General device drivers, such as various NICs, flash supporting CFI, serial port, USB bus, etc.

 

FS

Supports file systems. U-boot now supports cramfs, fat, fdos, jffs2, and registerfs.

 

Include

Header files, assembly files supported by various hardware platforms, system configuration files, and files supported by file systems

 

Net

Network-related code, such as BOOTP, TFTP, RARP, and NFS file system implementation

 

Lib_arm

Code related to the ARM architecture

 

Tools

Tools for creating S-record files and U-boot images

 

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.