The implementation of the boot Loader in an embedded system relies entirely on the CPU's architecture, so most boot
Loader are divided into the first and second phases, which depend on the CPU architecture of the code, such as the device initial
Code, etc., are usually placed in phase 1, and are usually implemented in assembly language to achieve a short and concise purpose.
Phase 2 is usually implemented in C, which enables complex functions, and the code has a better
Readability and portability.
The first phase includes:
(1) Initialization of hardware devices
① initialization of Gpio functions
② setting the speed and clock frequency of the CPU
③ Storage Control Unit initialization
(2) Copy the bootloader program into RAM space
(3) Set up the stack.
(4) Jump to the C population address of stage 2
The second phase includes:
(1) Initialize the hardware device to be used at this stage;
① initialization of at least one serial port
② initialization Timer (timer)
③ initialization of network transmission, etc.
(2) system memory map;
(3) Read the kernel image and the root file system image from Flash to ram space;
Loading kernel image and root file system image
(4) Set the boot parameters for the kernel;
(5) Call the kernel.
See my 360 network Disk file, "Experimental three bootloader experiment" pdf