linux uImage/zImage生成过程

linux uImage/zImage生成过程_第1张图片linux uImage/zImage生成过程_第2张图片linux uImage/zImage生成过程_第3张图片linux uImage/zImage生成过程_第4张图片linux uImage/zImage生成过程_第5张图片linux uImage/zImage生成过程_第6张图片uImage是zImage通过mkimage工具(在u-boot代码的tools目录中)在前面加了一个64Byte的头生成的。

/usr/bin/mkimage也可以用来生成uImage.

 

也可以直接在Image(未压缩)的基础上加64Byte的头生成uImage, 如下修改。

linux-3.18.19/arch/arm/boot/Makefile:

-$(obj)/uImage: $(obj)/zImage FORCE
+$(obj)/uImage: $(obj)/Image FORCE
 
 
生成uImage 的Makefile部分
nux-3.18.19/arch/arm/boot/Makefile:
$(obj)/uImage:  $(obj)/Image FORCE
    @$(check_for_multiple_loadaddr)
    $(call if_changed,uimage)
    @$(kecho) '  Image $@ is ready'
    @cp $@ $(KBUILD_OUTPUT)/

$(call if_changed,uimage)命令,参考 scripts/Makefile.lib中的cmd_uimage

341 # U-Boot mkimage
342 # ---------------------------------------------------------------------------
343
344 MKIMAGE := $(srctree)/scripts/mkuboot.sh
345
346 # SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces
347 # the number of overrides in arch makefiles
348 UIMAGE_ARCH ?= $(SRCARCH)
349 UIMAGE_COMPRESSION ?= $(if $(2),$(2),none)
350 UIMAGE_OPTS-y ?=
351 UIMAGE_TYPE ?= kernel
352 UIMAGE_LOADADDR ?= arch_must_set_this
353 UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
354 UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE) - OmniVision ASIC'
355 UIMAGE_IN ?= $<
356 UIMAGE_OUT ?= $@
357
358 quiet_cmd_uimage = UIMAGE  $(UIMAGE_OUT)
359       cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
360             -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
361             -T $(UIMAGE_TYPE) \
362             -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
363             -n $(UIMAGE_NAME) -d $(UIMAGE_IN) $(UIMAGE_OUT)

 

scripts/mkuboot.sh:

  1 #!/bin/bash
  2
  3 #
  4 # Build U-Boot image when `mkimage' tool is available.
  5 #
  6
  7 MKIMAGE=$(type -path "${CROSS_COMPILE}mkimage")
  8 if [ -z "${MKIMAGE}" ]; then
  9     MKIMAGE=$(type -path mkimage)
 10     if [ -z "${MKIMAGE}" ]; then
 11         # Doesn't exist
 12         echo '"mkimage" command not found - U-Boot images will not be built' >&2
 13         exit 1;
 14     fi
 15 fi
 16
 17 # Call "mkimage" to create U-Boot image
 18 ${MKIMAGE} "$@"

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


scripts/mkuboot.sh

 

你可能感兴趣的:(Linux)