uboot 加载内核镜像分析

2690阅读 0评论2015-04-20 Oliver_L_Oliver
分类:Android平台

uboot加载内核镜像有个头:

typedef struct _LINUX_FILE_TAG
{
unsigned long tagVersion;
    char  signiture_1[SIG_LEN];         // text line for company info
char  signiture_2[SIG_LEN_2];       // additional info (can be version number)
    char  chipId[CHIP_ID_LEN]; // chip id 
    char  boardId[BOARD_ID_LEN];        // board id
    unsigned long productId; // product id
    unsigned long productVer; // product version
    unsigned long reserved1; // reserved for future


    unsigned char imageValidationToken[TOKEN_LEN]; // image validation token - md5 checksum
    unsigned char kernelValidationToken[TOKEN_LEN]; // kernel+tag validation token - md5 checksum


unsigned long kernelTextAddr; // text section address of kernel
unsigned long kernelEntryPoint; // entry point address of kernel

unsigned long totalImageLen; // the sum of kernelLen+rootfsLen+tagLen


unsigned long kernelAddress; // starting address (offset from the beginning of FILE_TAG) of kernel image
unsigned long kernelLen; // length of kernel image


unsigned long rootfsAddress; // starting address (offset) of filesystem image
unsigned long rootfsLen; // length of filesystem image


unsigned long bootloaderAddress; // starting address (offset) of boot loader image
unsigned long bootloaderLen; // length of boot loader image

} LINUX_FILE_TAG;

用UE打开内核镜像的bin 文件:

这里镜像前面的头部数据就正好对应上面的数据结构。

比如,我们把内核的加载地址和入口地址用如下代码打印出来:
printf("fileTag->kernelTextAddr=0x%x fileTag->kernelEntryPoint=%x \n",fileTag->kernelTextAddr,fileTag->kernelEntryPoint);

fileTage 就是上面的LINUX_FILE_TAG数据结构,它指向镜像存储的首地址。

得到入口地址和加载地址都是0x80060000,然后我们算算一算在上面数据结构中的
unsigned long kernelTextAddr; // text section address of kernel
是第几个字节?算出来就是116个字节,然后116对应十六进制的74H,然后我们去图片中的74H 看那里的数据,可以看到,从那里开始正好是两个80060000,又因为mips是大端存储,高位数据存储在低字节上。
所以阅读起来正好跟人类习惯一样。





上一篇:系统性能提升方法探讨
下一篇:贴片回版后遇到的问题汇总