close

uImage & zImage 差異

kernel 編譯完會產生 zImage。
uImage 是 zImage 在加上一個 64 Bytes 的 header。這是給 uboot 載入 kernel 用的。(利用 bootm )

uImage 如何產生? 利用 mkimage 來產生。

mkimage 參數說明:
[root@localhost tools]# ./mkimage
Usage: ./mkimage -l image
          -l ==> list image header information
       ./mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
          -A ==> set architecture to 'arch'
          -O ==> set operating system to 'os'
          -T ==> set image type to 'type'
          -C ==> set compression type 'comp'
          -a ==> set load address to 'addr' (hex)
          -e ==> set entry point to 'ep' (hex)
          -n ==> set image name to 'name'
          -d ==> use image data from 'datafile'
          -x ==> set XIP (execute in place)

-C 指定映像壓縮模式,可以取以下值︰none 不壓縮,gzip 用gzip的壓縮模式,bzip2 用bzip2的壓縮模式
-a 指定映像在記憶體中的載入位址,映像載入到記憶體當中時,要按照用mkimage製作映像時,這個參數所指定的位址值來載入到記憶體
-e 指定映像執行的入口點(entry point)位址,這個位址就是-a參數指定的值加上0x40(因為前面有個mkimage添加的0x40個位元組的表頭)
-n 指定映像檔案名稱
-d 指定製作映像的來源檔案名稱

下面是 0x40個位元組的表頭header 的格式:
typedef struct image_header {
uint32_tih_magic;   /* Image Header Magic Number*/
uint32_tih_hcrc;   /* Image Header CRC Checksum*/
uint32_tih_time;   /* Image Creation Timestamp  */
uint32_tih_size;   /* Image Data Size    */
uint32_tih_load;   /* Data Load  Address   */
uint32_tih_ep;    /* Entry Point Address   */
uint32_tih_dcrc;   /* Image Data CRC Checksum  */
uint8_t  ih_os;    /* Operating System    */
uint8_t  ih_arch;   /* CPU architecture    */
uint8_t  ih_type;   /* Image Type     */
uint8_t  ih_comp;   /* Compression Type    */
uint8_t  ih_name[IH_NMLEN];/* Image Name     */
} image_header_t;

/* Operating System Codes */
#define IH_OS_INVALID  0/* Invalid OS*/
#define IH_OS_OPENBSD  1/* OpenBSD  */
#define IH_OS_NETBSD  2/* NetBSD  */
#define IH_OS_FREEBSD  3/* FreeBSD  */
#define IH_OS_4_4BSD  4/* 4.4BSD  */
#define IH_OS_LINUX   5/* Linux  */
#define IH_OS_SVR4   6/* SVR4   */
#define IH_OS_ESIX   7/* Esix   */
#define IH_OS_SOLARIS  8/* Solaris  */
#define IH_OS_IRIX   9/* Irix   */
#define IH_OS_SCO   10/* SCO   */
#define IH_OS_DELL   11/* Dell   */
#define IH_OS_NCR   12/* NCR   */
#define IH_OS_LYNXOS  13/* LynxOS  */
#define IH_OS_VXWORKS  14/* VxWorks  */
#define IH_OS_PSOS   15/* pSOS   */
#define IH_OS_QNX   16/* QNX   */
#define IH_OS_U_BOOT  17/* Firmware  */
#define IH_OS_RTEMS   18/* RTEMS  */
#define IH_OS_ARTOS   19/* ARTOS  */
#define IH_OS_UNITY   20/* Unity OS  */
#define IH_OS_INTEGRITY  21/* INTEGRITY*/


/* CPU Architecture Codes (supported by Linux) */
#define IH_ARCH_INVALID  0/* Invalid CPU*/
#define IH_ARCH_ALPHA  1/* Alpha  */
#define IH_ARCH_ARM   2/* ARM   */
#define IH_ARCH_I386  3/* Intel x86*/
#define IH_ARCH_IA64  4/* IA64   */
#define IH_ARCH_MIPS  5/* MIPS   */
#define IH_ARCH_MIPS64  6/* MIPS 64 Bit */
#define IH_ARCH_PPC   7/* PowerPC  */
#define IH_ARCH_S390  8/* IBM S390  */
#define IH_ARCH_SH   9/* SuperH  */
#define IH_ARCH_SPARC  10/* Sparc  */
#define IH_ARCH_SPARC64  11/* Sparc 64 Bit */
#define IH_ARCH_M68K  12/* M68K   */
#define IH_ARCH_NIOS  13/* Nios-32  */
#define IH_ARCH_MICROBLAZE14/* MicroBlaze*/
#define IH_ARCH_NIOS2  15/* Nios-II  */
#define IH_ARCH_BLACKFIN16/* Blackfin  */
#define IH_ARCH_AVR32  17/* AVR32  */
#define IH_ARCH_ST200  18/* STMicroelectronics ST200  */


/* Image Types */
#define IH_TYPE_INVALID  0/* Invalid Image  */
#define IH_TYPE_STANDALONE1/* Standalone Program*/
#define IH_TYPE_KERNEL  2/* OS Kernel Image  */
#define IH_TYPE_RAMDISK  3/* RAMDisk Image  */
#define IH_TYPE_MULTI  4/* Multi-File Image  */
#define IH_TYPE_FIRMWARE5/* Firmware Image  */
#define IH_TYPE_SCRIPT  6/* Script file   */
#define IH_TYPE_FILESYSTEM7/* Filesystem Image (any type)*/
#define IH_TYPE_FLATDT  8/* Binary Flat Device Tree Blob*/


/* Compression Types */
#define IH_COMP_NONE  0/*  No Compression Used*/
#define IH_COMP_GZIP  1/* gzip Compression Used*/
#define IH_COMP_BZIP2  2/* bzip2 Compression Used*/
#define IH_COMP_LZMA  3/* lzma  Compression Used*/


#define IH_MAGIC0x27051956/* Image Magic Number  */
#define IH_NMLEN32   /* Image Name Length  */


下面是 dump 出來 uImage的binary內容,僅供參考。
06000000: 56190527 27f7f8ea 5dcd674b e81f1600    '..V...'Kg.]....
06000010: 00800000 00800000 2a20d41d 00020205    .......... *....
06000020: 756e694c 2e322d78 34312e36 00000000    Linux-2.6.14....
06000030: 00000000 00000000 00000000 00000000    ................
06000040: e1a00000 e1a00000 e1a00000 e1a00000    ................
06000050: e1a00000 e1a00000 e1a00000 e1a00000    ................
06000060: ea000002 016f2818 00000000 00161fe8    .....(o.........
06000070: e1a07001 e3a08000 e10f2000 e3120003    .p....... ......

這是 little endian 格式。

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 ryan0988 的頭像
    ryan0988

    尋找最初的初衷

    ryan0988 發表在 痞客邦 留言(0) 人氣()