Porting U-boot (1)

Source: Internet
Author: User

1. Functions of Bootloader:

When the system is powered on, initialize the hardware device, prepare the software environment, call the operating system kernel, and copy the system kernel to the memory for running.

2. Start address of Bootloader:

The CPU of the ARM architecture obtains the first instruction starting from the address 0x0000000, which is also the starting address of the bootloader.

3. bootloader startup method:

  • Start loading mode: After power-on, bootloader loads the operating system to ram from a solid-state storage device on the board. The entire process requires no user intervention and is used for product release.
  • Download mode: developers can download files (such as kernel images and file system images) from hosts through serial port connections or network connections ), store them directly in memory or burn them into flash-type solid-state storage devices.

4. The functions of bootloader in the two startup stages:

(1) In the first stage, the Assembly is used to complete initialization dependent on the CPU architecture and call the code in the second stage:

  • Hardware Device initialization;
  • Prepare the ram space for loading the second-stage code of bootloader;
  • Copy the second-stage code of bootloader to the ram space;
  • Set the stack;
  • Jump to the C entry of the second-stage code.

Hardware initialization includes disabling WD, disconnection, setting the CPU speed and clock frequency, and ram initialization. But none of them are required.

(2) The second stage of bootloader is implemented using C to implement more complex functions:

  • Initialize the hardware used in this phase;
  • Checks system memory ing;
  • Read the kernel image and root file system image from the flash to the ram space;
  • Set startup parameters for the kernel;
  • Call the kernel.

After the kernel is stored in a proper location, you can directly jump to its entry point to call the kernel. Before calling the kernel, the following conditions must be met:

(1) CPU register settings:

  • R0 = 0;
  • R1 = Machine Type ID;
  • R2 = start parameter flag list start base address in Ram.

(2) CPU operating mode:

  • Interruption must be prohibited (irqs and fiqs );
  • The CPU must be in SVC mode.

(3) cache and MMU settings:

  • MMU must be disabled;
  • Command cache can be enabled or disabled;
  • The data cache must be disabled.

5. Interaction between Bootloader and kernel:

One-way interaction between Bootloader and the kernel. Various parameters are stored in a fixed position according to the Conventions, and then the kernel is started. After the kernel is started, the parameters are obtained from this position.

The parameter has a fixed structure and is passed as a tagged list. Mark the list to start marking atag_core and end marking atag_none.

The data structure of the tag is tag, which contains a tag_header structure and a union.

  • Tag_header indicates the tag type and length, such as memory or command line parameters;
  • Union indicates that different types of tags are used, indicating that the memory uses tag_mem32, indicating that the command line uses tag_cmdline.

6. Analysis and Transplantation of U-BOOT

U-boot(Universal Boot Loader) is an open-source project that complies with the GPL terms. It has the following features:

  • Open source code;
  • Supports multiple embedded operating system kernels, such as Linux, VxWorks, NetBSD, QNX, RTEMS, Artos, and lynxos;
  • Rich device driver source code: serial port, Ethernet, SDRAM, Flash, LCD, EEPROM, TRC, keyboard, etc;
  • Supports NFS mounting and ramdisk root file systems;
  • Supports NFS mounting to boot the compressed or non-compressed system kernel from FLASH;
  • Supports multiple storage methods for target board environment variables, such as flash, NVRAM, and EEPROM;
  • Power-on self-check function: automatic detection of SDRAM, flash size, SDRAM fault detection, CPU model;
  • Special features: xip internal boot.

 

Directory

Features

Description

Board

Development Board Problems

Corresponding to different configurations of the circuit board (even if the CPU is the same), such as smdk2410, sbc410x

CPU

Platform Problems

Stores CPU-related directory files, such as ARM920T, arm925t, and i386.

Lib_arm

 

Stores common files of the ARM architecture, which are mainly used to implement common functions of the ARM platform.

Include

General

The header file and the development board configuration file. All the development board configuration files are under the include/configs directory. You need to manually modify the macro definition in the configuration file.

Common

 

Universal multi-function implementation, mostly encapsulation of the driver at the next layer

Lib_generic

 

Implementation of Common Library functions

Net

General Device Driver

Store network-related programs

FS

 

Program for storing file systems

Post

 

Store power-on self-check program

Drivers

 

Drivers of various devices can be used

Disk

 

Hard Disk interface program

RTC

 

RTC driver

DTT

 

Driving of a digital temperature measuring device or sensor

Example

Sample program

Examples of independent applications, such as helloworld

Tools

Tools

Stores images in the S-record or U-boot format, such as mkimage.

Doc

Document

Development and usage documents

 

Porting U-boot (1)

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.