uImage生成过程

来源:互联网 发布:世界建筑史网络 编辑:程序博客网 时间:2024/06/05 08:03
 uImage生成过程 http://blog.csdn.net/voice_shen/article/details/6559752 
当编译linux的时候,运行make uImage,如果一切正常,最后会生成uImage。

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

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

view plaincopy to clipboardprint?
  1. MKIMAGE         := $(srctree)/scripts/mkuboot.sh  

 

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

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

:其中使用type命令来查找。mkimage 命令源码在uboot/u-boot/tools/mkimage.c

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

view plaincopy to clipboardprint?
  1. ifneq ($(MACHINE),)  
  2. include $(srctree)/$(MACHINE)/Makefile.boot  
  3. endif  

 

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

view plaincopy to clipboardprint?
  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的参数如下:

view plaincopy to clipboardprint?
  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 由下面代码获得

view plaincopy to clipboardprint?
  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 由下面代码获得

view plaincopy to clipboardprint?
  1. $(obj)/uImage: STARTADDR=$(LOADADDR)  

 由zImage生成uImage:

view plaincopy to clipboardprint?
  1. $(obj)/uImage:  $(obj)/zImage FORCE  
  2.     $(call if_changed,uimage)  
  3.     @echo '  Image $@ is ready'  

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

原创粉丝点击