本文主要是介绍MTK AndroidP/Q快速打包ramdisk,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、Android P/Q ramdisk与老版本的差异
Android老版本的ramdisk是out下的root/ramdisk打包而来,里面包含了init /sbin init.rc default.prop等文件。是一个完整的ramdisk
Android新版本ramdisk分为了out 下的ramdisk目录和root目录,init ,init.rc等文件大部分都放到了system下(当然这是基于把system作为跟目录的情况,但是现在默认应该就是这样配置了吧)。
Android新版本的ramdisk.img仅仅包含out 下的ramdisk目录,root目录被放在了system.img(在开机的系统下是看不出差异的,和之前老系统版本看起来一样;看out下system目录也没有变化,只是在打包时将root目录与system目录一起打包为system.img)
二、快速打包ramdisk.img
out/host/linux-x86/bin/mkbootfs -d out/target/product/$(PRODUCT)/system out/target/product/$(PRODUCT)/ramdisk | out/host/linux-x86/bin/minigzip > out/target/product/$(PRODUCT)/ramdisk.img
提取打包命令方法参考之前快速制作boot.img的博客
打包ramdisk.img的相关代码如上图
三、root如何打包到system.img的
root目录定义:
build/core/envsetup.mk TARGET_COPY_OUT_ROOT := root
TARGET_ROOT_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ROOT)
build/core/Makefile 搜索TARGET_ROOT_OUT
# -----------------------------------------------------------------
# the root dir
INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \$(ALL_GENERATED_SOURCES) \$(ALL_DEFAULT_INSTALLED_MODULES))INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST)@echo Installed file list: $@@mkdir -p $(dir $@)@rm -f $@$(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)$(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
继续搜索 INSTALLED_FILES_FILE_ROOT
FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)# -----------------------------------------------------------------
ifdef BUILDING_SYSTEM_IMAGE# installed file list
# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
# We put installed-files.txt ahead of image itself in the dependency graph
# so that we can get the size stat even if the build fails due to too large
# system image.
INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST)@echo Installed file list: $@@mkdir -p $(dir $@)@rm -f $@$(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)$(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@.PHONY: installed-file-list
installed-file-list: $(INSTALLED_FILES_FILE)$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))systemimage_intermediates := \$(call intermediates-dir-for,PACKAGING,systemimage)
BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
由上述代码可以看出打包system.img是依赖root目录的,如果编译是super.img,因为super是依赖system,vendor,product三个img的,所以root也会打包进super
验证推断,解包system.img看有没有root下的文件
这篇关于MTK AndroidP/Q快速打包ramdisk的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!