boot.img的生成
(1)命令執行追溯
Sourcebuild/envsetup.sh
Make bootimage -j10
(2)bootimage 目標執行如下
core/main.mk:859:.PHONY:bootimage
core/main.mk:860:bootimage:$(INSTALLED_BOOTIMAGE_TARGET)
(3)執行envsetup.sh指令碼,把(TARGET_DEVICE)/BoardConfig.mk包含了進來
build/envsetup.sh:628: localTOPFILE=build/core/envsetup.mk
-->build/core/envsetup.mk:161: $(shell test -d device && find device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk
下面為裡面的內容
BOARD_KERNEL_CMDLINE :=console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcommsm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhcilpm_levels.sleep_disabled=1 loglevel=8 earlyprintk=msm_hsl_uart,0x78b0000
CPXXXBoardConfig.mk:80:BOARD_KERNEL_PAGESIZE := 2048
CPXXX/BoardConfig.mk:79:BOARD_KERNEL_BASE := 0x80000000
CPXXX/AndroidBoard.mk:34:includekernel/AndroidKernel.mk
(4)具體如下:
Build/core/Makefile
INSTALLED_RAMDISK_TARGET :=$(BUILT_RAMDISK_TARGET)
BUILT_RAMDISK_TARGET:= $(PRODUCT_OUT)/ramdisk.img
》》》》》-----------------------kernel
INSTALLED_KERNEL_TARGET :=$(PRODUCT_OUT)/kernel
INTERNAL_BOOTIMAGE_ARGS:= \
477 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
478 --kernel $(INSTALLED_KERNEL_TARGET)
CPXXX/AndroidBoard.mk:36:$(INSTALLED_KERNEL_TARGET):$(TARGET_PREBUILT_KERNEL) | $(ACP)
Kernel/AndroidKernel.mk:77 TARGET_PREBUILT_KERNEL := $(TARGET_PREBUILT_INT_KERNEL)
build/core/Makefile: TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/Image.gz-dtb
《《《《---------------------------kernel
INTERNAL_BOOTIMAGE_ARGS +=--ramdisk $(INSTALLED_RAMDISK_TARGET)
INTERNAL_BOOTIMAGE_ARGS+= --cmdline "$(BOARD_KERNEL_CMDLINE)"
INTERNAL_BOOTIMAGE_ARGS+= --base $(BOARD_KERNEL_BASE)
INTERNAL_BOOTIMAGE_ARGS+= --pagesize $(BOARD_KERNEL_PAGESIZE)
INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
$(INSTALLED_BOOTIMAGE_TARGET):$(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)$(BOOT_SIGNER)
509 $(call pretty,"Target boot image: [email protected]")
510 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS)$(BOARD_MKBOOTIMG_ARGS) --output [email protected]
511 $(BOOT_SIGNER) /boot [email protected]$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem [email protected]
512 $(hide) $(callassert-max-image-size,[email protected],$(BOARD_BOOTIMAGE_PARTITION_SIZE))
上面標紅的一行解析如下,也就是編譯生成boot.img的命令
build/core/Makefile:513:out/host/linux-x86/bin/mkbootimg --kernel out/target/product/CPXXX/kernel--ramdisk out/target/product/CPXXX/ramdisk.img --cmdline"console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 loglevel=8earlyprintk=msm_hsl_uart,0x78b0000" --base 0x80000000 --pagesize 2048
[email protected]代表目標的值,如果有多個值會一個一個替換
執行mkbootimg的help如下:
[email protected]:~/code/L_6.0_8976/LA.BR.1.3.4-01810-8976.0$out/host/linux-x86/bin/mkbootimg --help
usage: mkbootimg
--kernel <filename>
[ --ramdisk <filename> ]
[ --second<2ndbootloader-filename> ]
[ --cmdline <kernel-commandline> ]
[ --board <boardname> ]
[ --base <address> ]
[ --pagesize <pagesize> ]
[ --id ]
-o|--output<filename> //--------------------------輸出到目標檔案