定制我的Nexus系统之boot.img的前世今生

本文探讨了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连接']

        今天,我们来看一下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/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值