Linux 编译可以生成 uImage、 Image 以及 zImage 内核,其中 uImage 是 uboot 专用内核映像文件
内核编译
Linux 内核编译默认生成 Image 和 zImage,其中 Image 为内核映像文件,而 zImage 为内核的一种映像压缩文件
uImage 为 uboot 专用的映像文件,是在 zImage 之前加上一个长度为 64 字节的头,说明这个内核的版本、加载位置、生成时间、大小等信息;其 0x40 之后与 zImage 没区别,64 字节头部结构如下
typedef struct image_header {
uint32_tih_magic;
uint32_tih_hcrc;
uint32_tih_time;
uint32_tih_size;
uint32_tih_load;
uint32_tih_ep;
uint32_tih_dcrc;
uint8_tih_os;
uint8_tih_arch;
uint8_tih_type;
uint8_tih_comp;
uint8_tih_name[IH_NMLEN];
} image_header_t;
zImage 由 vmlinux objcopy 出来的纯二进制文件以及解压缩程序组成, zImage 自带了解压缩程序
uImage 和 zImage 都是压缩后的内核映像。而 uImage 是用 mkimage 工具 根据 zImage 制作而来的
编译 uImage 需要指定 make ARCH=arm CROSS_COMPILE=arm-linux- uImage LOADADDR=0x8000
LOADADDR
当编译 uImage 时需要指定一个参数 LOADADDR,指定内核映像所在的地址,对于 arm 来将这个是惯例
Despite the ability to place zImage anywhere within memory, convention has it that it is loaded at the base of physical RAM plus an offset of 0x8000 (32K). This leaves space for the parameter block usually placed at offset 0x100, zero page exception vectors and page tables. This convention is very common.