1. 程式人生 > >boot.img解包和打包過程

boot.img解包和打包過程

MTK平臺:
boot.img打包過程:

boot.img=header+kernel+ramdisk.img
LK會使用header裡面的引數。
mkbootimg header引數在BoardConfig.mk檔案裡定義:
BOARD_KERNEL_BASE = 0x40000000--base
BOARD_KERNEL_OFFSET = 0x00080000--kernel_offset
BOARD_RAMDISK_OFFSET = 0x04000000--ramdisk_offse
BOARD_TAGS_OFFSET = 0xE000000--tags_offset
BOARD_KERNEL_CMDLINE = bootopt=64S3,32N2,64N2--cmdline
mkbootimg命令對kernel和ramdisk.img打包,使用的選項如下:
--kernel
--ramdisk
--base
--kernel_offset
--ramdisk_offse
--tags_offset
--cmdline
--pagesize(可選)
--board(可選)
--output
舉例如下:
# make boot.img
INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
INSTALLED_KERNEL_TARGET=$PRODUCT_OUT/kernel
INSTALLED_RAMDISK_TARGET=./ramdisk.img
MKBOOTIMG=./mkbootimg

BUILD_NUMBER=`date +%s`
CUSTOM_BUILD_VERNO_HDR=$BUILD_NUMBER
BOARD_KERNEL_BASE=0x40000000
BOARD_KERNEL_OFFSET=0x00080000
BOARD_RAMDISK_OFFSET=0x04000000
BOARD_TAGS_OFFSET=0xE000000
BOARD_KERNEL_CMDLINE="bootopt=64S3,32N2,64N2"


INTERNAL_BOOTIMAGE_ARGS=" --kernel $INSTALLED_KERNEL_TARGET --ramdisk $INSTALLED_RAMDISK_TARGET --cmdline $BOARD_KERNEL_CMDLINE --base $BOARD_KERNEL_BASE --ramdisk_offset $BOARD_RAMDISK_OFFSET --kernel_offset $BOARD_KERNEL_OFFSET --tags_offset $BOARD_TAGS_OFFSET --board $CUSTOM_BUILD_VERNO_HDR"
BOARD_MKBOOTIMG_ARGS="--kernel_offset $BOARD_KERNEL_OFFSET --ramdisk_offset $BOARD_RAMDISK_OFFSET --tags_offset $BOARD_TAGS_OFFSET"

echo MKBOOTIMG=$MKBOOTIMG
echo INTERNAL_BOOTIMAGE_ARGS=$INTERNAL_BOOTIMAGE_ARGS
echo BOARD_MKBOOTIMG_ARGS=$BOARD_MKBOOTIMG_ARGS
echo INSTALLED_BOOTIMAGE_TARGET=$INSTALLED_BOOTIMAGE_TARGET

./$MKBOOTIMG $INTERNAL_BOOTIMAGE_ARGS $BOARD_MKBOOTIMG_ARGS --output $INSTALLED_BOOTIMAGE_TARGET

ramdisk.img打包過程:

指令碼位置:build\core\Makefile
需要的應用程式:
/out/host/linux-x86/bin/mkbootfs
/out/host/linux-x86/bin/minigzip


ifeq ($(MTK_HEADER_SUPPORT),yes)
$(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > [email protected]_raw
$(hide) $(HOST_OUT_EXECUTABLES)/mkimage [email protected]_raw ROOTFS 0xffffffff > [email protected]

else
$(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > [email protected]
endif
MTK打包ramdisk.img有兩種方式:加header和不加header。
MTK預設情況下:ProjectConfig.mk:MTK_HEADER_SUPPORT = no

boot.img解包
->kernel
->ramdisk.img解包
->root fs(修改)
->ramdisk.img打包
boot.img打包