The embedded system generally does not have the universal Bootloader,u-boot is the powerful bootloader development software, but relatively is also more complex.
1 bootloader and U-boot Introduction
The bootloader code is a piece of code that executes before the chip is reset and enters the operating system, primarily to complete the transition from hardware boot to operating system boot, thus providing the operating system with a basic operational environment, such as initializing CPUs, stacks, memory systems, and so on. The bootloader code is related to the CPU chip's kernel structure, the specific model, the configuration of the application system and the operating system used, and its function is similar to the BIOS program of the PC. due to the bootloader and the configuration of the CPU and the board, it is impossible to have a generic bootloader, which requires the user to migrate according to the specific situation. embedded Linux systems commonly used in bootloader have Armboot, Redboot, Blob, U-boot,bios-lt,Bootldr , which U-boot is currently more popular, Powerful bootloader that can support multiple architectures, but are relatively complex. the implementation of Bootloader relies on the CPU architecture, and most bootloader are divided into Stage1 and Stage2 .
2.1 stage1 (START.S code structure)---- Basic hardware initialization
U-boot's stage1 code is usually placed in the Start.s file, which is written in assembly language, and its main code section is as follows:
(1) define the entrance. Because an executable image must have an entry point and can have only one global entry, usually this entry is placed in the 0x0 address of the ROM (Flash), so the compiler must be notified to know the portal, which can be done by modifying the connector script.
(2) Set the anomaly vector (exception vector).
(3) Set the CPU speed, clock frequency and interrupt control register.
all interrupts are blocked. servicing interrupts is usually the responsibility of the OS device driver, so there is no need to respond to any interrupts during the execution of the Boot Loader. Interrupt masking can be done by writing interrupt screen registers or status registers (such as ARM's CPSR registers) of the CPU.
(4) Initialize (RAM) memory controller.
(5) Copy the program in ROM to RAM.
(6) Initialize the stack.
(7) Go to RAM to execute, the work can be done using the instructions LDR pc.
2.2 Stage2 C Language Code section
The start Armboot in LIBARM/BOARD.C is a function of the C language, the main function of the C language in the entire startup code, and the main function of the entire u-boot (Armboot), which mainly completes the following operations:
(1) Call a series of initialization functions.
(2) initialize the flash device.
(3) Initialize the system memory allocation function.
(4) If the target system has a NAND device, initialize the NAND device.
(5) If the target system has a display device, initialize that class of device.
(6) Initialize the relevant network equipment, fill in the IP, MAC address and so on.
(7) Enter the command loop (that is, the entire boot cycle), accept the user input from the serial port command, and then do the corresponding work.
REF:
Http://www.360doc.com/content/11/1022/08/1317564_158121482.shtml
Http://blog.chinaunix.net/uid-24951403-id-2212589.html
https://www.ibm.com/developerworks/cn/linux/l-btloader/