uImage生成过程

 

当编译linux的时候,运行make uImage,如果一切正常,最后会生成uImage。

如下具体讲解uImage生成过程:

1. 生成uImag的工具mkimage由arch/arm/boot/Makefile中的MKIMAGE定义

[c-sharp] view plain copy print ?
  1. MKIMAGE         := $(srctree)/scripts/mkuboot.sh 

mkuboot.sh的作用是去找到是否存在"mkimage",此工具是用来生成最后的uImage。

  mkuboot.sh 首先检查toolchain是否拥有mkimage (使用-z来判空),如果没有,再检查系统中是否拥有mkimage;如果没有则报错。

:其中使用type命令来查找。

        type: Display information about command type  (type [-afptP] name [name ...])

       ==> # type mkimage

      ==> mkimage is /usr/bin/mkimage

2. 从makefile.boot中传入生成uImage的相关参数(e.g: arm/arm/mach-at91/Makefile.boot)

[c-sharp] view plain copy print ?
  1. ifneq ($(MACHINE),) 
  2. include $(srctree)/$(MACHINE)/Makefile.boot 
  3. endif 

3.  通过mkimage来生成uImage,其过程是加上0x40 bytes 的kernel头

[c-sharp] view plain copy print ?
  1. quiet_cmd_uimage = UIMAGE  $@ 
  2.       cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A arm -O linux -T kernel / 
  3.            -C none -a $(LOADADDR) -e $(STARTADDR) / 
  4.            -n 'Linux-$(KERNELRELEASE)' -d $< $@ 

mkimage的参数如下:

[c-sharp] view plain copy print ?
  1. Usage: mkimage -l image 
  2.           -l ==> list image header information 
  3.        mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image 
  4.           -A ==> set architecture to 'arch' 
  5.           -O ==> set operating system to 'os' 
  6.           -T ==> set image type to 'type' 
  7.           -C ==> set compression type 'comp' 
  8.           -a ==> set load address to 'addr' (hex) 
  9.           -e ==> set entry point to 'ep' (hex) 
  10.           -n ==> set image name to 'name' 
  11.           -d ==> use image data from 'datafile' 
  12.           -x ==> set XIP (execute in place) 

Load address 由下面代码获得

[c-sharp] view plain copy print ?
  1. ifeq ($(CONFIG_ZBOOT_ROM),y) 
  2. $(obj)/uImage: LOADADDR=$(CONFIG_ZBOOT_ROM_TEXT) 
  3. else 
  4. $(obj)/uImage: LOADADDR=$(ZRELADDR) 
  5. endif 

start address 由下面代码获得

[c-sharp] view plain copy print ?
  1. $(obj)/uImage: STARTADDR=$(LOADADDR) 

由zImage生成uImage:

[c-sharp] view plain copy print ?
  1. $(obj)/uImage:  $(obj)/zImage FORCE 
  2.     $(call if_changed,uimage) 
  3.     @echo '  Image $@ is ready' 

也可以自行用mkimage来生成uImage,

  mkimage -A arm -O linux -T kernel -C none -a <load_addr> -e <entry_addr> -n <name> -d zImage uImage

e.g : mkimage -A arm -O linux -T kernel -C none -a 0x70008000 -e 0x70008000 -n linux-2.6.30 -d zImage uImage

其中:0x8000这32K 空间是Note that the kernel uses 16K of RAM below the image to store page tables.  The recommended placement is 32KiB into RAM. (来自Documentation/arm/booting文件)

 

文章转自:http://blog.csdn.net/voice_shen/article/details/6559752

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值