如下具体讲解uImage生成过程:
1. 生成uImag的工具mkimage由arch/arm/boot/Makefile中的MKIMAGE定义
[c-sharp] view plain copy print ?
- MKIMAGE := $(srctree)/scripts/mkuboot.sh
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 ?
- ifneq ($(MACHINE),)
- include $(srctree)/$(MACHINE)/Makefile.boot
- endif
ifneq ($(MACHINE),) include $(srctree)/$(MACHINE)/Makefile.boot endif
3. 通过mkimage来生成uImage,其过程是加上0x40 bytes 的kernel头
[c-sharp] view plain copy print ?
- quiet_cmd_uimage = UIMAGE $@
- cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A arm -O linux -T kernel /
- -C none -a $(LOADADDR) -e $(STARTADDR) /
- -n 'Linux-$(KERNELRELEASE)' -d $< $@
quiet_cmd_uimage = UIMAGE $@ cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A arm -O linux -T kernel / -C none -a $(LOADADDR) -e $(STARTADDR) / -n 'Linux-$(KERNELRELEASE)' -d $< $@
mkimage的参数如下:
[c-sharp] view plain copy print ?
- 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)
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)
Load address 由下面代码获得
[c-sharp] view plain copy print ?
- ifeq ($(CONFIG_ZBOOT_ROM),y)
- $(obj)/uImage: LOADADDR=$(CONFIG_ZBOOT_ROM_TEXT)
- else
- $(obj)/uImage: LOADADDR=$(ZRELADDR)
- endif
ifeq ($(CONFIG_ZBOOT_ROM),y) $(obj)/uImage: LOADADDR=$(CONFIG_ZBOOT_ROM_TEXT) else $(obj)/uImage: LOADADDR=$(ZRELADDR) endif
start address 由下面代码获得
[c-sharp] view plain copy print ?
- $(obj)/uImage: STARTADDR=$(LOADADDR)
$(obj)/uImage: STARTADDR=$(LOADADDR)
由zImage生成uImage:
[c-sharp] view plain copy print ?
- $(obj)/uImage: $(obj)/zImage FORCE
- $(call if_changed,uimage)
- @echo ' Image $@ is ready'
$(obj)/uImage: $(obj)/zImage FORCE $(call if_changed,uimage) @echo ' Image $@ is ready'
也可以自行用mkimage来生成uImage,
mkimage -A arm -O linux -T kernel -C none -a -e -n -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