手机boot.img:
通常由2k头部、n pages的kernel、m pages 的ramdisk、x pages的second stage组成的
$ file boot.img boot.img: Android bootimg, kernel (0x40080000), ramdisk (0x44000000), page size: 2048, cmdline (bootopt=64S3,32N2,64N2)
关键参数:
- magic: Android
- base = kernel address - 0x8000
- page size
- cmdline
电视的boot.img :
通常由64字节头部、自解压程序、kernel、ramdisk等组成
$ file ../boot.img ../boot.img: u-boot legacy uImage, MStar-linux, Linux/ARM, Multi-File Image (Not compressed), 3683426 bytes, Sun Dec 16 08:35:49 2012, Load Address: 0x40208000, Entry Point: 0x40208000, Header CRC: 0x31D11693, Data CRC: 0x2940EEB0
关键参数:
- magic : u-boot
- 类型:legecy uImage
- Load Address:kernel加载到ram的地址
- Entry Point :执行的入口地址,通常是Load Address + 64
用mkimage查看电视的boot.img信息:
命令:mkimage -l image
$ mkimage -l /home/biren/downloads/boot.img Image Name: MStar-linux Created: Sun Dec 16 16:35:49 2012 Image Type: ARM Linux Multi-File Image (uncompressed) Data Size: 3683426 Bytes = 3597.10 KiB = 3.51 MiB Load Address: 40208000 Entry Point: 40208000 Contents: 主要由以下2个镜像组合 Image 0: 3516928 Bytes = 3434.50 KiB = 3.35 MiB Image 1: 166486 Bytes = 162.58 KiB = 0.16 MiB头部说明 :
手机boot头部 : 共2K
4字节*2 ,magic , 固定是android 4*1, kernel长度,小端(以下都是) 4*1,kernel地址,=base地址+0x00008000 (offset) 4*1, ramdisk长度 4*1,ramdisk地址 4*1 ,second stage长度 4*1,second stage地址 4*1,tags地址 4*1,page大小 4*2,未使用,固定为0x00 4*4,板子名字,通常为空 4*128,内核命令参数 4*8,ID ...
例 子:
先解压:
C:tmpGionee_F103_BAKddd>bootimg.exe --unpack-bootimg arguments: [bootimg file] bootimg file: boot.img output: kernel[.gz] ramdisk[.gz] second[.gz] found nonstandard ramdisk_addr found nonstandard second_addr found nonstandard tags_addr base: 0x40078000 ramdisk_addr: 0x44000000 second_addr: 0x40f00000 tags_addr: 0x4e000000 page_size: 2048 name: "1440706504" cmdline: "bootopt=64S3,32N2,64N2" padding_size=2048 arguments: [ramdisk file] [directory] ramdisk file: ramdisk.gz directory: initrd output: cpiolist.txt compress: True
boot的头部信息:
kernel长度:0x006059B9 即6314425字节,地址:0x40080000
电视uboot头部 : 共64字节
ih_magic:magic,固定为0x27051956,占4字节,uimage格式标志。 ih_hcrc:整个头部的crc32校验,占4字节。 ih_time:时间戳,占4字节,为16进制,生成的时间。 ih_size: 镜像数据大小,即除去头部信息外的数据大小,占4字节。(大端) ih_load:uboot启动过程中,加载到RAM的地址。占4字节。 ih_ep: 启动镜像的入口地址,占4字节。 ih_dcrc:除去头部信息外数据的crc32校验数值,占4字节。 ih_os: 适用的系统。 占1字节。 ih_arch:cpu架构 ih_type:镜像类型,占1字节。 ih_comp:压缩类型,如gzip、lzma等,占1字节。 ih_name[IHNMLEN]: 镜像的名称,占32字节。
例 子:
- magic : 0x27051956 (固定的)
- 镜像大小:0x00383462 即3683426字节(比boot.img少64B)
- 加载到RAM地址:0x40208000
针对boot的有:
有bootimg.exe, bootimg.py , unpackbootimg , unmkbootimg , mkbootimg等
针对uboot的有:
mkimage , dumpimage
mkimage/dumpimage的安装:
biren@ubuntu:~$ sudo apt-get install uboot-mkimage 或者 biren@ubuntu:~$ sudo apt-get install u-boot-tools



