今天,我们来看一下boot.img的生成,作用,和修改方法。
1.首先是build/core/main.mk
.PHONY: bootimage
bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
如果我们把out/target/product/crespo/boot.img去掉,再运行make bootimage, 那么会重新生成boot.img。然后我们看build/core/Makefile里
INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
$(call pretty,"Target boot image: $@")
$(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
else # TARGET_BOOTIMAGE_USE_EXT2 != true
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
$(call pretty,"Target boot image: $@")
$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
$(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
endif # TARGET_BOOTIMAGE_USE_EXT2
可知INSTALLED_BOOTIMAGE_TARGET的对象就是out/target/product/crespo/boot.img, 有可能用2种方式生成,一种是ext2格式,另外一种则不是。根据添加调试打印,crespo采用的不是ext2文件格式,因此我们来看一下$(MKBOOTIMG)。
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
$(call pretty,"Target boot image: $@")
$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
$(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
展开来就是
out/target/product/crespo/boot.img:out/host/linux-x86/bin/mkbootimg out/target/product/crespo/kernel out/target/product/crespo/ramdisk.img
$(call pretty, "Target boot image: $@")
$(hide) --kernel out/target/product/crespo/kernel --ramdisk out/target/product/crespo/ramdisk.img --cmdline "console=ttyFIQ0 no_console_suspend" --base 0x30000000 --pagesize 4096 --output $@
其中各变量的含义分别为:
INSTALLED_BOOTIMAGE_TARGET:out/target/product/crespo/boot.img
MKBOOTIMG:out/host/linux-x86/bin/mkbootimg
INTERNAL_BOOTIMAGE_FILES:out/target/product/crespo/kernel out/target/product/crespo/ramdisk.img
INTERNAL_BOOTIMAGE_ARGS: --kernel out/target/product/

本文探讨了boot.img的生成过程,包括build/core/main.mk中的定义、mkbootimg工具及其源码分析,以及bootimg.h的相关信息。详细解释了kernel_addr, ramdisk_addr, tags_addr的含义,并介绍了ramdisk.img的解压方法。boot.img在android系统启动流程中扮演重要角色,存储kernel和ramdisk,用于加载内核和初始化系统。文章还概述了android的启动流程和各个分区的功能。"
113259447,10295094,Jenkins Pipeline连接MySQL实战指南,"['Jenkins', '数据库', 'Pipeline', 'MySQL连接']

7392

被折叠的 条评论
为什么被折叠?



