MTK AB分区修改

本文详细指导如何在Android P版本的MTK设备上启用AB分区,包括修改preloader、lk、project和Kernel配置,创建并配置partition_ab_dynamic.xml,更新te文件,scatter.json和file_contexts,以及解决常见升级问题。附带OTADemo链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

MTK AB分区修改

打开OTA设置
android p版本开AB 分区需要修改以下配置项:
(1)preloader:
vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/projectname/projectname.mk
MTK_AB_OTA_UPDATER=yes
export MTK_AB_OTA_UPDATER
(2)lk:
vendor/mediatek/proprietary/bootable/bootloader/lk/project/projectname.mk
MTK_AB_OTA_UPDATER=yes
SYSTEM_AS_ROOT=yes
(3)project:
device/mediatekprojects/projectname/ProjectConfig.mk
MTK_AB_OTA_UPDATER=yes
SYSTEM_AS_ROOT=yes
(4)Kernel:
kernel-XXX/arch/arm64/projectname_defconfig
kernel-XXX/arch/arm64/projectname_debug_defconfig
如果有 # CONFIG_SYSTEM_AS_ROOT
is not set, 删去此行
SYSTEM_AS_ROOT定义的Kconfig在kernel-XXX/drivers/misc/mdiatek/Kconfig中,默认为y
确认kernel-XXX的方式为:
查看 /device/mediatekprojects/ projectname /ProjectConfig.mk
LINUX_KERNEL_VERSION = kernel-XXX
(5)增加分区文件device/project/xxxx/partition/partition_ab_dynamic.xml
同时修改编译脚本
device/project/xxxx/partition/Android.mk
(6)增加ota update_engine的SE权限
device/mediatek/mt8xxx/sepolicy/basic/update_engine.te
(7)修改生成的分区刷机文件
device/project/xxxx/partition/scatter.json
(8)AB分区的块设备权限
device/mediatek/mt8xxx/sepolicy/basic/file_contexts
(9)OTA升级遇到的bug解决
(10) OTADemo

前面4步都是添加设置,比较简单,我们从第5步开始说明
5.本来说是在xls里面配置的
device\mediatek\build\build\tools\ptgen\MT8xxx\partition_table_MT8xxx.xls这里是没有动态分区的
但是根据MTK的脚本,发现在device\mediatek\project\xxxx\partition\partition_dynamic.xml里面
新建一个partition_ab_dynamic.xml文件,如下配置,
31457280*512\1024\1024=15360M 也就是15G,下面的也是这么算的
这个不知道怎么写, 就参考其他项目的,或者看这个partition_table_MT8xxx.xls里面的

<?xml version="1.0" encoding="utf-8"?>
<partition lba="31457280">

<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="6144" name="proinfo"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="30720" name="cam_vpu1_a"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="30720" name="cam_vpu2_a"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="30720" name="cam_vpu3_a"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="30720" name="cam_vpu1_b"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="30720" name="cam_vpu2_b"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="30720" name="cam_vpu3_b"/>
	
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="10240" name="nvram"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="20480" name="protect1"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="20480" name="protect2"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="98304" name="persist"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="16384" name="nvcfg"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="512" name="seccfg"/>
	
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="2048" name="lk_a"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="2048" name="lk_b"/>
	
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="65536" name="boot_a"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="65536" name="boot_b"/>
	
	<!-- <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="65536" name="recovery"/> -->
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="1024" name="para"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="16384" name="logo"/>
	
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="16384" name="dtbo_a"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="16384" name="dtbo_b"/>
	
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="20480" name="expdb"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="2048" name="frp"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="10240" name="tee_a"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="10240" name="tee_b"/>
	
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="4096" name="kb"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="4096" name="dkb"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="65536" name="metadata"/>
	
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="11520" name="vbmeta_a"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="11520" name="vbmeta_b"/>
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="8192" name="nvdata" />
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="4096" name="vbmeta_system_a" />
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="4096" name="vbmeta_system_b" />
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="4096" name="vbmeta_vendor_a" />
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="4096" name="vbmeta_vendor_b" />
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="16769024" name="super"/>
	<!-- <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="229376" name="cache"/>  -->
	<entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" size="6291456" name="userdata"/>
</partition>

同目录下的mk脚本 ,这里修改

#PARTITION := $(LOCAL_PATH)/partition_dynamic.xml
PARTITION := $(LOCAL_PATH)/partition_ab_dynamic.xml

还有一些其他地方有需要修改的

diff --git a/alps/device/mediatek/mt8168/BoardConfig.mk b/alps/device/mediatek/mt8xxx/BoardConfig.mk

--- a/alps/device/mediatek/mt8168/BoardConfig.mk
+++ b/alps/device/mediatek/mt8168/BoardConfig.mk
@@ -163,7 +163,8 @@ endif

 #get partition
 ifeq ($(strip $(MTK_DYNAMIC_PARTITION_SUPPORT)), yes)
-PARTITION_XML := $(MTK_TARGET_PROJECT_FOLDER)/partition/partition_dynamic.xml
+#PARTITION_XML := $(MTK_TARGET_PROJECT_FOLDER)/partition/partition_dynamic.xml
+PARTITION_XML := $(MTK_TARGET_PROJECT_FOLDER)/partition/partition_ab_dynamic.xml

6增加te文件

diff --git a/alps/device/mediatek/mt8xxx/sepolicy/basic/update_engine.te b/alps/device/mediatek/mt8xxx/sepolicy/basic/update_engine.te
--- /dev/null
+++ b/alps/device/mediatek/mt8168/sepolicy/basic/update_engine.te
@@ -0,0 +1,2 @@
+allow update_engine metadata_file:dir { search };^M
+allow update_engine sysfs_boot_type:file { read open getattr write unlink};

(7)修改生成的分区刷机文件
device/project/xxxx/partition/scatter.json

{
    "preloader": {
        "boundary_check": true,
        "is_download": true,
        "is_upgradable": true,
        "file_name": "preloader_xxxx.bin",
        "is_reserved": false,
        "partition_name": "preloader",
        "partition_size": 262144,
        "physical_start_addr": 0,
        "linear_start_addr": 0,
        "region": "EMMC_BOOT_1",
        "storage": "HW_STORAGE_EMMC",
        "operation_type": "BOOTLOADERS",
        "type": "SV5_BL_BIN",
        "reserve": 0
    },
    "pgpt": {
        "boundary_check": true,
        "is_download": true,
        "file_name": "GPT.img",
        "is_reserved": false,
        "partition_name": "pgpt",
        "partition_size": 524288,
        "physical_start_addr": 0,
        "linear_start_addr": 0,
        "region": "EMMC_USER",
        "storage": "HW_STORAGE_EMMC",
        "operation_type": "UPDATE",
        "type": "NORMAL_ROM",
        "reserve": 0
    },
    "PRO_INFO": {
        "operation_type": "PROTECTED",
        "type": "NORMAL_ROM"
    },
    "proinfo": {
        "operation_type": "PROTECTED",
        "type": "NORMAL_ROM"
    },
    "NVRAM": {
        "operation_type": "BINREGION",
        "type": "NORMAL_ROM"
    },
    "nvram": {
        "operation_type": "BINREGION",
        "type": "NORMAL_ROM"
    },
    "cam_vpu1": {
        "file_name": "cam_vpu1.img",
        "operation_type": "UPDATE",
        "is_upgradable": true,
        "type": "NORMAL_ROM"
    },
	"cam_vpu1_a": {
        "file_name": "cam_vpu1.img",
        "operation_type": "UPDATE",
        "is_upgradable": true,
        "type": "NORMAL_ROM"
    },
	"cam_vpu1_b": {
        "is_upgradable": true,
        "type": "NORMAL_ROM"
    },
    "cam_vpu2": {
        "file_name": "cam_vpu2.img",
        "operation_type": "UPDATE",
        "is_upgradable": true,
        "type": "NORMAL_ROM"
    },
	"cam_vpu2_a": {
        "file_name": "cam_vpu2.img",
        "operation_type": "UPDATE",
        "is_upgradable": true,
        "type": "NORMAL_ROM"
    },
	"cam_vpu2_b": {
        "is_upgradable": true,
        "type": "NORMAL_ROM"
    },
    "cam_vpu3": {
        "file_name": "cam_vpu3.img",
        "operation_type": "UPDATE",
        "is_upgradable": true,
        "type": "NORMAL_ROM"
    },
	"cam_vpu3_a": {
        "file_name": "cam_vpu3.img",
        "operation_type": "UPDATE",
        "is_upgradable": true,
        "type": "NORMAL_ROM"
    },
	"cam_vpu3_b": {
        "is_upgradable": true,
        "type": "NORMAL_ROM"
    },
    "nvcfg": {
        "operation_type": "INVISIBLE",
        "type": "EXT4_IMG"
    },
    "boot_para": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "protect1": {
        "operation_type": "PROTECTED",
        "type": "EXT4_IMG"
    },
    "protect2": {
        "operation_type": "PROTECTED",
        "type": "EXT4_IMG"
    },
    "para": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "SECCFG": {
        "operation_type": "INVISIBLE",
        "type": "NONE"
    },
    "seccfg": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "PROTECT_F": {
        "operation_type": "PROTECTED",
        "type": "NORMAL_ROM"
    },
    "PROTECT_S": {
        "operation_type": "PROTECTED",
        "type": "NORMAL_ROM"
    },
    "UBOOT": {
        "file_name": "lk.img",
        "type": "NORMAL_ROM"
    },
    "lk": {
        "file_name": "lk.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "lk2": {
        "file_name": "lk.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "lk_a": {
        "file_name": "lk.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "lk_b": {
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "BOOTIMG": {
        "file_name": "boot.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "boot": {
        "file_name": "boot.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "boot_a": {
        "file_name": "boot.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "boot_b": {
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "recovery": {
        "file_name": "recovery.img",
        "is_upgradable": true
    },
    "RECOVERY": {
        "file_name": "recovery.img",
        "is_upgradable": true
    },
    "SEC_RO": {
        "file_name": "secro.img",
        "type": "NORMAL_ROM"
    },
    "secro": {
        "file_name": "secro.img",
        "type": "NORMAL_ROM"
    },
    "MISC": {
        "operation_type": "INVISIBLE",
        "type": "NONE"
    },
    "misc": {
        "operation_type": "INVISIBLE",
        "type": "NONE"
    },
    "LOGO": {
        "file_name": "logo.bin",
        "type": "NORMAL_ROM"
    },
    "logo": {
        "file_name": "logo.bin",
        "type": "NORMAL_ROM"
    },
    "DTBO": {
        "file_name": "dtbo.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "dtbo": {
        "file_name": "dtbo.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
	"dtbo_a": {
        "file_name": "dtbo.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
	"dtbo_b": {
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "ODMDTBO": {
        "file_name": "odmdtbo.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "odmdtbo": {
        "file_name": "odmdtbo.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "odmdtbo_a": {
        "file_name": "odmdtbo.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "odmdtbo_b": {
        "file_name": "odmdtbo.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "EXPDB": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "expdb": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "TEE1": {
        "file_name": "tee.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "TEE2": {
        "file_name": "tee.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "tee1": {
        "file_name": "tee.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "tee2": {
        "file_name": "tee.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "tee_a": {
        "file_name": "tee.img",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "tee_b": {
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "oemkeystore": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "keystore": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "FRP": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "frp": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "nvdata": {
        "operation_type": "INVISIBLE",
        "type": "EXT4_IMG"
    },
    "metadata": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "vbmeta": {
        "file_name": "vbmeta.img",
        "operation_type": "UPDATE",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
	"vbmeta_a": {
        "file_name": "vbmeta.img",
        "operation_type": "UPDATE",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
	"vbmeta_b": {
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "KB": {
        "operation_type": "INVISIBLE",
        "type": "NORMAL_ROM"
    },
    "kb": {
        "operation_type": "PROTECTED",
        "type": "NORMAL_ROM"
    },
    "dkb": {
        "operation_type": "PROTECTED",
        "type": "NORMAL_ROM"
    },
    "vbmeta_vendor": {
        "file_name": "vbmeta_vendor.img",
        "operation_type": "UPDATE",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
	"vbmeta_vendor_a": {
        "file_name": "vbmeta_vendor.img",
        "operation_type": "UPDATE",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
	"vbmeta_vendor_b": {
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "vbmeta_system": {
        "file_name": "vbmeta_system.img",
        "operation_type": "UPDATE",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
	"vbmeta_system_a": {
        "file_name": "vbmeta_system.img",
        "operation_type": "UPDATE",
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
	"vbmeta_system_b": {
        "type": "NORMAL_ROM",
        "is_upgradable": true
    },
    "system": {
        "file_name": "system.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "super": {
        "file_name": "super.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "system_a": {
        "file_name": "system.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "system_b": {
        "file_name": "system_other.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "ANDROID": {
        "file_name": "system.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "vendor": {
        "file_name": "vendor.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "VENDOR": {
        "file_name": "vendor.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "vendor_a": {
        "file_name": "vendor.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "vendor_b": {
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "odm": {
        "file_name": "odm.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "ODM": {
        "file_name": "odm.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "odm_a": {
        "file_name": "odm.img",
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "odm_b": {
        "type": "EXT4_IMG",
        "is_upgradable": true
    },
    "cache": {
        "file_name": "cache.img",
        "type": "EXT4_IMG"
    },
    "CACHE": {
        "file_name": "cache.img",
        "type": "EXT4_IMG"
    },
    "persist": {
        "operation_type": "PROTECTED",
        "type": "EXT4_IMG"
    },
    "userdata": {
        "file_name": "userdata.img",
        "type": "EXT4_IMG"
    },
    "USRDATA": {
        "file_name": "userdata.img",
        "type": "EXT4_IMG"
    },
    "FAT": {
        "type": "EXT4_IMG",
        "operation_type": "INVISIBLE"
    },
    "OTP": {
        "boundary_check": false,
        "is_download": false,
        "file_name": "NONE",
        "is_reserved": true,
        "partition_name": "OTP",
        "partition_size": 45088768,
        "physical_start_addr": 4294902104,
        "linear_start_addr": 4294902104,
        "region": "EMMC_USER",
        "storage": "HW_STORAGE_EMMC",
        "operation_type": "RESERVED",
        "type": "NONE",
        "reserve": 0
    },
    "sgpt": {
        "boundary_check": false,
        "is_download": false,
        "file_name": "NONE",
        "is_reserved": true,
        "partition_name": "sgpt",
        "partition_size": 16896,
        "physical_start_addr": 4294901760,
        "linear_start_addr": 4294901760,
        "region": "EMMC_USER",
        "storage": "HW_STORAGE_EMMC",
        "operation_type": "RESERVED",
        "type": "NORMAL_ROM",
        "reserve": 0
    }

}

(8)AB分区的块设备权限
device/mediatek/mt8xxx/sepolicy/basic/file_contexts

diff --git a/alps/device/mediatek/mt8168/sepolicy/basic/file_contexts b/alps/device/mediatek/mt8168/sepolicy/basic/file_contexts
index d8999c3cad..79452f378e 100644
--- a/alps/device/mediatek/mt8168/sepolicy/basic/file_contexts
+++ b/alps/device/mediatek/mt8168/sepolicy/basic/file_contexts
@@ -3,6 +3,8 @@
 #
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/proinfo u:object_r:nvram_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/nvram u:object_r:nvram_device:s0
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/preloader(_[ab])? u:object_r:preloader_block_device:s0
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/lk(_[ab])? u:object_r:lk_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/protect1  u:object_r:protect1_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/protect2 u:object_r:protect2_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/seccfg u:object_r:seccfg_block_device:s0
@@ -14,16 +16,25 @@
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/frp u:object_r:frp_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/tee1 u:object_r:tee_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/tee2 u:object_r:tee_block_device:s0
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/tee(_[ab])? u:object_r:tee_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/nvdata u:object_r:nvdata_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/metadata u:object_r:metadata_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/super u:object_r:super_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/system u:object_r:system_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/vendor(_[ab])? u:object_r:vendor_block_device:s0
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/vbmeta(_system|_vendor)?(_[ab])? u:object_r:vbmeta_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/cache u:object_r:cache_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/userdata u:object_r:userdata_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/odmdtbo(_[ab])? u:object_r:dtbo_block_device:s0
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/dtbo(_[ab])? u:object_r:dtbo_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/odm(_[ab])? u:object_r:odm_block_device:s0
 /dev/block/platform/soc/[0-9]+\.mmc/by-name/nvcfg u:object_r:nvcfg_block_device:s0
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/boot(_[ab])? u:object_r:boot_block_device:s0
+
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/vbmeta(_[ab])? u:object_r:lk_block_device:s0
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/cam_vpu1(_[ab])? u:object_r:lk_block_device:s0
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/cam_vpu2(_[ab])? u:object_r:lk_block_device:s0
+/dev/block/platform/soc/[0-9]+\.mmc/by-name/cam_vpu3(_[ab])? u:object_r:lk_block_device:s0

升级的时候可能会有bug

BUG1
校验preloader.img出错,增加下面的patch,patch_package/0001-ALPS07157008-8168-preloader-header.patch复制到下面的目录
vendor/mediatek/proprietary/bootable/bootloader/preloader/platform/mt8168/headerblock_for_ota_fastboot_emmc
这个,自己找MTK要

BUG2
Vbmeta.img校验错误 是因为在runtime是关闭了avb,加快开机速度,但这样 导致hash检验失败

1.build/make/core/Makefile
-ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
+#ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
 # We only need the flag in top-level vbmeta.img.
 BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
-endif
+#endif

2.external/avb/avbtool
@@ -46,6 +46,7 @@ AVB_FOOTER_VERSION_MAJOR = 1
 AVB_FOOTER_VERSION_MINOR = 0
 AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED = 1
+AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED = 2 
 class AvbError(Exception):
@@ -3867,7 +3868,7 @@ class AvbTool(object):
       The modified arguments.
     """
     if args.set_hashtree_disabled_flag:
-      args.flags |= AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED
+      args.flags |= AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED
     return args

另附OTADemo

OTAdemo链接
https://download.youkuaiyun.com/download/xuyewen288/85801495

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xuyewen288

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值