Bootloader startup process:
The Bootloader startup process is generally divided into two phases: stage1 and stage2. The following describes the two phases respectively.
Booloader in stage1 mainly completes the following tasks:
* Basic hardware initialization includes shielding all interrupts and setting the CPU speed and clock frequency. RAM initialization, LED initialization, and CPU Internal commands and data cache are disabled.
* Prepare a RAM space for loading stage2. Generally, Stage2 is loaded to the RAM space for execution at a faster execution speed. Therefore, an available RAM space range must be prepared for the stage2 loaded with Bootloader.
* Copy Stage2 to RAM. Here, we need to determine two points: the starting address and ending address of the executable image of 1 stage2 stored on the solid state storage device, and the starting address of 2 RAM space.
* Set the stack pointer SP to prepare the C language code for stage2 execution.
Stage2 mainly completes the following tasks:
* Use the assembly language to jump to the main entry function:
* Initialize the hardware devices to be used in this phase, including the initialization serial port and initialization timer. You can output some print information before initializing these devices.
* Checks the system's memory ing. The so-called memory address ing refers to specifying the address ranges allocated in the 4 GB address space for addressing the system's RAM unit.
* Load the kernel image and the root file system image, including the layout of the planned memory usage and copying data from Flash.
* Set the memory startup parameters.