RK Android10/11/12平台上新建分区并挂载到root根目录下的方法
在根目录下创建test_dir目录
system/core$ git diff
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index 24b3999..71297fb 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -139,6 +139,7 @@ LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/overlay $(TARGET_ROOT_OUT)/odm/ov
LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/priv-app $(TARGET_ROOT_OUT)/odm/priv-app
LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/usr $(TARGET_ROOT_OUT)/odm/usr
+ LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/test_dir
ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/cache
给test_dir添加权限
device/rockchip/common$ git diff
diff --git a/sepolicy/private/file_contexts b/sepolicy/private/file_contexts
index d0b1d91..af22da1 100644
--- a/sepolicy/private/file_contexts
+++ b/sepolicy/private/file_contexts
@@ -1,2 +1,3 @@
# file in /system
/system/bin/move_widevine_data\.sh u:object_r:move-widevine-data-sh_exec:s0
+/test_dir(/.*)? u:object_r:cache_file:s0
在fstab下添加新分区,挂在为ext4文件系统
首先找到(或指定)fstab的模板文件:
get_build_var PRODUCT_FSTAB_TEMPLATE
例如:
PRODUCT_FSTAB_TEMPLATE := device/rockchip/common/scripts/fstab_tools/fstab.in
device/rockchip/common$ git diff
diff --git a/scripts/fstab_tools/fstab.in b/scripts/fstab_tools/fstab.in
index 2ec6c265..d823c46d 100755
--- a/scripts/fstab_tools/fstab.in
+++ b/scripts/fstab_tools/fstab.in
@@ -10,6 +10,7 @@ ${_block_prefix}odm /odm ext4 ro,barrier=1 ${_flags},first_stage_mount
/dev/block/by-name/cache /cache ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
/dev/block/by-name/metadata /metadata ext4 nodev,noatime,nosuid,discard,sync wait,formattable,first_stage_mount,check
/dev/block/by-name/misc /misc emmc defaults defaults
+/dev/block/by-name/test /test_dir ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
/devices/platform/*usb* auto vfat defaults voldmanaged=usb:auto
在parameter里面添加test分区
- 在产品的BoardConfig.mk中定义:(以rk3566_r产品为例),分区大小为16M
device/rockchip/rk356x
diff --git a/rk3566_r/BoardConfig.mk b/rk3566_r/BoardConfig.mk
index 24b415f..3fcbb2b 100644
--- a/rk3566_r/BoardConfig.mk
+++ b/rk3566_r/BoardConfig.mk
@@ -37,3 +37,5 @@ ifeq ($(strip $(BOARD_USES_AB_IMAGE)), true)
include device/rockchip/common/BoardConfig_AB.mk
TARGET_RECOVERY_FSTAB := device/rockchip/rk356x/rk3566_r/recovery.fstab_AB
endif
+
+BOARD_WITH_SPECIAL_PARTITIONS := test:16M
如果要添加2个分区则是:BOARD_WITH_SPECIAL_PARTITIONS := test:16M,test1:16M
- 在RebuildParameter.mk中添加BOARD_WITH_SPECIAL_PARTITIONS
device/rockchip/common/build/rockchip/RebuildParameter.mk
+ifneq ($(strip $(BOARD_WITH_SPECIAL_PARTITIONS)), )
+partition_list := $(partition_list),$(BOARD_WITH_SPECIAL_PARTITIONS)
+endif