Introduction to boatloader

Source: Internet
Author: User

I wrote an article about firmware a few days ago. bootloader is an important part of BSP. We all know that the BIOS function is to guide the OS. bootloader is called a boot loader, in the embedded system, bootloader also acts as a boot OS. In the embedded system, the OS startup process is (enable bootloader, hardware initialization, software initialization, and boot OS ), through the bootloader code, you can initialize the software and hardware and map the resume memory space, so that you can configure the system's hardware and software environment to the appropriate State to load the OS and start the OS, bootloader also provides support for interfaces such as serial port, network, and USB to facilitate debugging of embedded software development functions. The position of bootloader in the software hierarchy of the entire embedded system is as follows.

Figure (1)

In an ARM-based embedded system, the system usually starts from 0x00000000 when powered on or reset, and the address is usually the bootloader of the system. Currently, bootloader supports more and more architectures, including Vivi, Redboot, and U-boot. Vivi developed by South Korea's mizi company is suitable for the arm9-processor. Redboot is an independent open source code boot/loader widely used in embedded systems.

Most bootloaders have two different loading modes: "Start loading mode" and "Download mode ". In this mode, bootloader loads the operating system to ram from a solid-state storage device of the target machine, no user intervention is involved throughout the process. The boot loading mode is the normal working mode of bootloader. When an embedded product is released, bootloader must work in this mode. : The download Mode means that the bootloader on the target machine will download files from the host machine through serial port or network connection (TFTP) or other communication means, for example, the impact of the operating system kernel image and the root file system. Serial Communication is the easiest way to achieve this. Even when the bootloader program is executing, it can use serial communication for I/O operations to exchange data and information. You can use the TFTP software on the host to download files over Ethernet.

Most bootloaders are divided into stage1 and stage2, and U-boot is no exception. Code dependent on the CPU architecture (such as device initialization Code) is usually stored in stage1 and can be implemented in assembly language, while stage2 is implemented in C language, in this way, complicated functions can be implemented, and better readability and movement can be achieved.

Seeding.

1. stage1 start. s code structure

The stage1 code of U-boot is usually stored in the start. s file, which is written in assembly language. The main code section is as follows:

Below:

(1) define the entry. An executable image must have one entry point and only one global entry. Generally, this entry is placed at 0x0 address of the RoM (flash). Therefore, the compiler must be notified to know the entry, which can be done by modifying the connector script.

(2) set an exception vector ).

(3) set the CPU speed, clock frequency, and terminal control register.

(4) initialize the memory controller.

(5) copy the program in the Rom to ram.

(6) initialize the stack.

(7) Go to ram for execution. This task can be completed using the ldr pc command.

2. lib_arm/board in the Code section of stage2 C. in C, start arm boot is the function starting from C language and the main function of C language in the whole startup code. It is also the main function of the whole U-boot (armboot, you only need to complete the following operations for this function:

(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 the device.

(6) initialize related network devices, and fill in IP addresses and MAC addresses.

(7) enter the command loop (that is, the operating cycle of the entire boot), accept the commands input by the user from the serial port, and then perform the corresponding work.

Figure (2)

U-boot source code top-level directory description
Topic features explanation
The Board platform depends on storing directory files related to the circuit board,
For example: rpxlite (mpc8xx), smdk2410 (ARM920T), sc520_cdp (x86) and other directories

CPU platform depends on storing CPU-related directory files

For example, the following directories are available: mpc8xx, ppc4xx, arm720t, ARM920T, XScale, and i386.

The lib_ppc platform depends on files that are common to the PowerPC architecture,
It is mainly used to implement functions common to the PowerPC platform.
The lib_arm platform depends on files that are common to the ARM architecture,
It is mainly used to implement general functions of the ARM platform.
The lib_i386 platform depends on files that are common to the X86 architecture,
It is mainly used to implement common functions on the X86 platform.
Include general header files and development board configuration files,
The configuration files of all development boards are under the configs directory.
Common universal multi-function implementation
Implementation of lib_generic universal library functions
Net General Network Storage Program
FS general program for storing file systems
Post general storage power-on self-check program
Drivers is a general-purpose device driver with Ethernet interfaces.
General disk interface program
RTC universal RTC driver
DTT universal digital temperature measuring device or sensor drive
Examples of some independent applications, such as helloworld
Tools stores images in S-record or U-boot format, such as mkimage
Doc documentation development user documentation

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.