Android Boot.img

Source: Internet
Author: User

Android at startup Uboot determine if there is a combination of health press or cache partition upgrade file to determine which system to enter (there may be other ways to determine)
If there is a combination of health press or the cache partition has an upgrade file, then load Recovery.img into the upgrade system. Otherwise load boot.img into the normal system
The 3 key points of this record:

Structure of the 1:BOOT.IMG

2: How to make a boot.img

3:uboot How to find boot.img

A: the structure of the boot.img is as follows:

+-----------------+

| Boot Header | 1 page

+-----------------+

| Kernel | N Pages

+-----------------+

| RAMDisk | M pages

+-----------------+

| Second Stage | o Pages

+-----------------+


which

The boot header records some information about the boot.img,

Kernel is the kernel compressed file zimage,

RAMDisk is the root file system,

Second Stage spare



Boot Header a total of one page, the default 2K .
The data in front is the struct BOOT_IMG_HDR, the back takes 0 to complement , gather 2K.
The structure is as follows:
struct BOOT_IMG_HDR
{

unsigned char magic[boot_magic_size];

unsigned kernel_size;/* Kernel size */

unsigned kernel_addr;/* Kernel location */

unsigned ramdisk_size;/* Root root file System size */

unsigned ramdisk_addr;/* root file system location */

unsigned second_size;/* Extended, Alternate */

unsigned second_addr;/* Extended, Alternate */

unsigned tags_addr;/* The physical memory address used to pass the parameter, which is the function of bootloader passed to the parameter in the kernel*/

unsigned page_size;/* page size, default 2k*/

unsigned unused[2]; * / Extended, Alternate */

unsigned char name[boot_name_size]; * / Product Name */

unsigned char cmdline[boot_args_size]/* Startup Parameters */;

unsigned id[8]; * / can be reused, such as timestamps, check bits */

};


Two: Boot.img the production

m kbootimg command to make boot.img, command path: ~/out/host/linux-x86/bin/mkbootimg, code path: ~/system/core/mkbooting


The Mkbootimg command parameters are as follows:

Path of the Kernel:zimage

Path of the ramdisk:ramdisk.img

Second: alternate file path

CmdLine: kernel parameters

Board: Product Name

Base:base Address

PageSize: page Size

Output: export Path


where kernel,ramdisk,and output are parameters that must be passed in, others are optional


Example:

Mkbootimg--kernel zimage--ramdisk ramdisk.img--base 0x10800000--output boot.img

Three: Uboot loading boot.img

Uboot Use the Booti command when loading boot.img, for example: Booti MMC2, which means that if a device has several SD cards, or EMMC, go to the second resource to find,boot.img

Uboot will go to the first partition on the second resource device read boot.img

First read the boot header in the boot.img to get the required information

This determines the location of the kernel and the root file system in the boot.img , and the rest is loaded into memory.


where the kernel is loaded into memory is determined by the base parameter, the default is 0x10800000







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.