1.增加块设备
2.修改根目录节点权限
3.开机启动自动挂载
增加块设备
1.修改parameter.txt文件,新增块设备大小及命名
device/rockchip/rk356x/rk3566_r/parameter.txt
FIRMWARE_VER: 11.0
MACHINE_MODEL: rk3566_r
MACHINE_ID: 007
MANUFACTURER: rockchip
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: rk3566_r
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
CMDLINE:mtdparts=rk29xxnand:0x00002000@0x00002000(security),0x00002000@0x00004000(uboot),0x00002000@0x00006000(trust),0x00002000@0x00008000(misc),0x00002000@0x0000a000(dtbo),0x00000800@0x0000c000(vbmeta),0x00014000@0x0000c800(boot),0x00030000@0x00020800(recovery),0x000c0000@0x00050800(backup),0x000c0000@0x00110800(cache),0x00008000@0x001d0800(metadata),0x00000800@0x001d8800(baseparameter),0x00614000@0x001d9000(super),0x00614000@0x007ed000(device),-@0x00e12000(userdata:grow)
//红色部分代表新增的块设备
@符号前是分区的大小
@符号后是分区的起始地址
括号中是分区的名字
单位都是 sector(512Bytes)
比如 uboot 起始地址为 0x2000 sectors (4MB)的位置,大小为 0x2000 sectors(4M)
另外 flash 最大的 block 是 4M(0x2000 sectors),所以每个分区需要 4MB 对齐,即每个分区必须为 4MB 的整数倍。
,0x00038000@0x00038000(backup)
backup 分区前的分区为固件区 uboot、trust、misc、resource、kernel、boot、recovery 。
后续升级时不能修改分区大小
backup 分区后的分区 cache、system、metadata、baseparamer、userdata
是可以读写的,可以调整分区大小。但是修改分区大小后需要进入 recovery 系统格式化 cache
2.修改recovery
修改recovery.fstab,使得recovery阶段处理新增分区
device/rockchip/rk356x/recovery.fstab
diff --git a/rk3566_r/recovery.fstab b/rk3566_r/recovery.fstab
old mode 100644
new mode 100755
index 0856791..28c47f7
--- a/rk3566_r/recovery.fstab
+++ b/rk3566_r/recovery.fstab
[url=home.php?mod=space&uid=1999721]@@[/url] -8,6 +8,7 @@
/dev/block/by-name/product /product ext4 defaults defaults
/dev/block/by-name/system_ext /system_ext ext4 defaults defaults
/dev/block/by-name/cache /cache ext4 defaults defaults
+/dev/block/by-name/device /device ext4 defaults defaults
/dev/block/by-name/metadata /metadata ext4 defaults defaults
/dev/block/by-name/userdata /data f2fs defaults defaults
/dev/block/by-name/cust /cust ext4 defaults defaults
修改recovery.cpp,使得recovery阶段格式化新增分区
bootable/recovery/recovery.cpp
diff --git a/install/include/install/wipe_data.h b/install/include/install/wipe_data.h
old mode 100644
new mode 100755
index c177f59..15cd951
--- a/install/include/install/wipe_data.h
+++ b/install/include/install/wipe_data.h
@@ -30,5 +30,6 @@ bool WipeCache(RecoveryUI* ui, const std::function<bool()>& confirm);
bool WipeData(Device* device, bool convert_fbe);
void SureMetadataMount();
+void SureDeviceMount();
void WipeFrp();
int ResizeData(Device* device);
diff --git a/install/wipe_data.cpp b/install/wipe_data.cpp
old mode 100644
new mode 100755
index a16e62c..bbc62dc
--- a/install/wipe_data.cpp
+++ b/install/wipe_data.cpp
@@ -36,6 +36,7 @@
constexpr const char* CACHE_ROOT = "/cache";
constexpr const char* DATA_ROOT = "/data";
constexpr const char* METADATA_ROOT = "/metadata";
+constexpr const char* DEVICE_ROOT = "/device";
/**
reset hdmi after restore factory.
@@ -164,6 +165,15 @@ bool WipeData(Device* device, bool convert_fbe) {
return success;
}
+void SureDeviceMount() {
if (ensure_path_mounted(DEVICE_ROOT)) {
printf("mount device fail,so formate...\n");
reset_tmplog_offset();
format_volume(DEVICE_ROOT);
ensure_path_mounted(DEVICE_ROOT);
}
+}
void SureMetadataMount() {
if (ensure_path_mounted(METADATA_ROOT)) {
printf("mount metadata fail,so formate...\n");
diff --git a/recovery.cpp b/recovery.cpp
old mode 100644
new mode 100755
index eda573b..4f309a1
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -1170,6 +1170,8 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector std::stri
device-StartRecovery();
SureMetadataMount();
+
SureDeviceMount();
printf("Command:");
for (const auto& arg : args) {
.....
修改根目录节点权限
1.修改BoardConfig.mk,新增TARGET_FS_CONFIG_GEN += device/rockchip/common/config.fs
device/rockchip/common/BoardConfig.mk
diff --git a/BoardConfig.mk b/BoardConfig.mk
index d642ffd..beb78c9 100755
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -132,6 +132,9 @@ BOARD_ODMIMAGE_FILE_SYSTEM_TYPE ?= ext4
TARGET_COPY_OUT_VENDOR := vendor
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE ?= ext4
+#test for fs_config
+TARGET_FS_CONFIG_GEN += device/rockchip/common/config.fs
+
default.prop & build.prop split
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED ?= true
2.新增config.fs,指明根目录/device的权限状态
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file is used to define the properties of the filesystem
images generated by build tools (mkbootfs and mkyaffs2image) and
by the device side of adb.
[AID_VENDOR_NEW_SERVICE]
value: 2900
[AID_VENDOR_NEW_SERVICE_TWO]
value:2902
[vendor/bin/service1]
mode: 0755
user: AID_SYSTEM
group: AID_VENDOR_NEW_SERVICE
caps: CHOWN DAC_OVERRIDE
[device/]
mode: 0777
user: AID_SYSTEM
group: AID_SYSTEM
caps: 0
[device/f7s/]
mode: 0777
user: AID_SYSTEM
group: AID_SYSTEM
caps: 0
开机启动自动挂载
修改init.rc和fstab.in,在init阶段创建/device目录并模拟/cache目录的挂载参数
device/rockchip/common/scripts/fstab_tools/fstab.in
device/rockchip/common/recovery/etc/init.rc
diff --git a/recovery/etc/init.rc b/recovery/etc/init.rc
old mode 100644
new mode 100755
index 2ed0ea6..7fb4d09
--- a/recovery/etc/init.rc
+++ b/recovery/etc/init.rc
@@ -32,6 +32,7 @@ on init
mkdir /data
mkdir /cache
mkdir /sideload
mkdir /device
mount tmpfs tmpfs /tmp
chown root shell /tmp
diff --git a/scripts/fstab_tools/fstab.in b/scripts/fstab_tools/fstab.in
index 10c3d2e..9a1d1e0 100755
--- a/scripts/fstab_tools/fstab.in
+++ b/scripts/fstab_tools/fstab.in
@@ -10,6 +10,7 @@ {_block_prefix}system_ext /system_ext ext4 ro,barrier=1 {flags},first_stage
/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/cache /cache ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
+/dev/block/by-name/device /device ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
/devices/platform/usb auto vfat defaults voldmanaged=usb:auto
原作者:山人牛牛