Android新增自定义分区

  • Post author:
  • Post category:其他




前言

最近测试又看我太闲了给我找了点事情做,工厂测试模式的数据需要保存,且恢复出场设置不会被恢复,这让我下意识想到新增一个分区,之前做MTK平台的时候有类似的FAQ,就很简单的新增了个,所以自信慢慢,拍着胸脯就答应了。可是这一次是全志A50平台,之前完全没有做过,也没有类似的文档支持,所以经过将近一周的磕磕绊绊,终于解决了此问题。在此记录一下!不想听废话的直接看如下 patch进行修改就可以了。想知道个大概就可以看看我的思路,这李说的是全志A50的,看看能不能找到一点灵感,表达能力不够,还多包涵!



下面还有RK3326 Q的新增分区方法 有需要的可以参考一下,我觉得下面的正宗点



参考思路 A50新增自定义分区

我们知道。Android是基于linux内核开发的一个系统,所以很多东西就是继承自linux的,记得刚拿到新电脑装服务器的时候,系统装在固态硬盘中。但是我们的代码比较大,上百个G,你固态硬盘的容量肯定不够,此刻就需要一个机械硬盘。在linux上我们在硬件接好固态硬盘的时候,需要去给他挂载到某个目录下,每次开机后都需要挂载,除非你在开机的时候就给他写入了(

Ubunutu开机挂载硬盘

)。 这时候我会想到Android 中的init.rc;init进程解析的init.rc会去花式创建各种目录结构并挂载。



Steps1

那么我们第一步,应该去在根目录(/)下创建一个可供system_app读写的目录。给他分配相应的空间,存放测试数据,在第一步中我有提到init.rc中mkdir,并且去挂载。我们可以去找找init.rc里面有没有类似的例子。你想…蓝牙wifi mac地址保存在哪才会恢复出场设置不会被恢复

init.rc 我这里使用的是init.sun8iw15p1.rc 目录是device/common/softwinner/venus-common/中

on init //在init阶段
    ....
    #add by tuliyuan for add a new dir
    mkdir /vtechfs system system  //这一段话的意思就是创建一个用户组为system的文件夹vtechfs
    ....
on fs         //在挂载阶段 这些init.rc中的各种状态可以参考 https://www.jianshu.com/p/cb73a88b0eed 这个地址的大佬对这些命令的解析
    mount_all /vendor/etc/fstab.sun8iw15p1      //这里我们看到是用的这个表去挂载 注意看步骤2
    swapon_all /vendor/etc/fstab.sun8iw15p1

    restorecon_recursive /persist

    #restorecon_recursive /vtech  //注意这一行,我先给他注释掉 
on late-fs
    # gpu
    insmod /vendor/modules/mali.ko

on post-fs-data
    # Set indication (checked by vold) that we have finished this action
    setprop vold.post_fs_data_done 1
on boot  //在启动阶段
    chown system system /sys/kernel/debug/sync/sw_sync
    chmod 0660 /sys/kernel/debug/sync/sw_sync
    
#add by tuliyuan
    #chown system system /vtech       //注意这一行,我先给他注释掉 



Steps2

在步骤一这样操作之后这样我们会在/目录下生成一个vtech文件夹,但是光有这个文件夹是不行的,这个文件夹没有空间,没有大小我们没办法去读写数据。这样我们需要分配一块空间给到vtech这个文件夹,并给他挂载到vtech目录下,即新增块设备,并挂载到vtech目录下

# Android fstab file.
#<src>                                         <mnt_point>  <type>  <mnt_flags and options>  <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK

#/dev/block/by-name/system               /system      ext4    ro,barrier=1      wait
#/dev/block/by-name/vendor               /vendor      ext4    ro,barrier=1      wait
/dev/block/by-name/cache                /cache       ext4    noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check,formattable
/dev/block/by-name/UDISK                /data        f2fs    noatime,nosuid,nodev,discard                                                               wait,check,formattable,encryptable=/dev/block/by-name/metadata,quota
/dev/block/by-name/boot                 /boot        emmc    defaults                                                                                  defaults
/dev/block/by-name/recovery             /recovery    emmc    defaults                                                                                  defaults
/dev/block/by-name/misc                 /misc        emmc    defaults                                                                                  defaults
/dev/block/by-name/frp                  /persistent  emmc    defaults                                                                                  defaults
/dev/block/zram0                        none         swap    defaults                                                                                  zramsize=75%
/devices/platform/soc/sdc0/mmc_host/mmc*            auto           auto    defaults                                                                voldmanaged=extsd:auto
/devices/platform/soc/usbc0/usb*                       auto    auto    defaults    voldmanaged=usb:auto
/devices/platform/soc/5101000.ehci0-controller/usb*    auto    auto    defaults    voldmanaged=usb:auto
/devices/platform/soc/5200000.ehci1-controller/usb*    auto    auto    defaults    voldmanaged=usb:auto
/devices/platform/soc/5101000.ohci0-controller/usb*    auto    auto    defaults    voldmanaged=usb:auto
/devices/platform/soc/5200000.ohci1-controller/usb*    auto    auto    defaults    voldmanaged=usb:auto
#add by tuliyuan for vtech factory
#将块设备vtechfs以ext4的格式挂载到/vtech目录下
/dev/block/by-name/vtechfs        /vtech    ext4    noatime,nosuid,nodev,	   defaults



Steps3

到这里是不是有点奇怪,那我的dev/block/by-name/vtechfs这个块设备哪里来的。是怎么创建的。这里这个东西目录结构是不是有点熟悉。是没有新建分区的文档,但是有修改分区大小的文档,这些资料肯定都是查阅的,我用的是这个。你可以看到在fstab.sun8iw15p1中的很多类似frp,boot,vendor等这些块设备,在这里都有定义,我们尝试一下新增一个自己的。

lichee/tools/pack/chips/sun8iw15p1/configs/a1/sys_partition.fex

;---------------------------------------------------------------------------------------------------
; 说明: 脚本中的字符串区分大小写,用户可以修改"="后面的数值,但是不要修改前面的字符串
;---------------------------------------------------------------------------------------------------


;---------------------------------------------------------------------------------------------------
;                                   固件下载参数配置
;---------------------------------------------------------------------------------------------------
;***************************************************************************************************
;    mbr的大小, 以Kbyte为单位
;***************************************************************************************************
[mbr]
size = 16384

;***************************************************************************************************
;                                              分区配置
;
;
;  partition 定义范例:
;    [partition]                ;  //表示是一个分区
;    name        = USERFS2      ; //分区名称
;    size        = 16384        ; //分区大小 单位: 扇区.分区表示个数最多2^31 * 512 = 2T
;    downloadfile = "123.fex"   ; //下载文件的路径和名称,可以使用相对路径,相对是指相对于image.cfg文件所在分区。也可以使用绝对路径
;    keydata     = 1            ; //私有数据分区,重新量产数据将不丢失
;    encrypt     = 1            ; //采用加密方式烧录,将提供数据加密,但损失烧录速度
;    user_type   = ?            ; //私有用法
;    verify      = 1            ; //要求量产完成后校验是否正确
;
; 注:1、name唯一, 不允许同名
;     2、name最大12个字符
;     3、size = 0, 将创建一个无大小的空分区
;     4、为了安全和效率考虑,分区大小最好保证为16M字节的整数倍
;***************************************************************************************************
[partition_start]
;------------------------------>mmcblk0p2/nand0p2
[partition]
    name         = bootloader
    size         = 65536
    downloadfile = "boot-resource.fex"
    user_type    = 0x8000

;------------------------------>mmcblk0p3/nand0p3
[partition]
    name         = env
    size         = 32768
    downloadfile = "env.fex"
    user_type    = 0x8000

;------------------------------>mmcblk0p4/nand0p4
[partition]
    name         = boot
    size         = 65536
    downloadfile = "boot.fex"
    user_type    = 0x8000

;------------------------------>mmcblk0p5/nand0p5
[partition]
    name         = system
    size         = 2868192
    downloadfile = "system.fex"
    user_type    = 0x8000

;------------------------------>mmcblk0p6/nand0p6
[partition]
    name         = vendor
    size         = 491520
    downloadfile = "vendor.fex"
    user_type    = 0x8000

;------------------------------>mmcblk0p7/nand0p7
[partition]
    name         = misc
    size         = 32768
    user_type    = 0x8000

;------------------------------>mmcblk0p8/nand0p8
[partition]
    name         = recovery
    size         = 65536
    downloadfile = "recovery.fex"
    user_type    = 0x8000

;------------------------------>mmcblk0p9/nand0p9
[partition]
    name         = cache
    size         = 1048576
    user_type    = 0x8000

;------------------------------>store encryptable
;------------------------------>mmcblk0p10/nand0p10
[partition]
    name         = metadata
    size         = 32768
    user_type    = 0x8000

;------------------------------>data image private
;------------------------------>mmcblk0p11/nand0p11
[partition]
    name         = private
    size         = 32768
    ro           = 0
    user_type    = 0x8000

;------------------------------>frp
;------------------------------>mmcblk0p12/nand0p12
[partition]
    name         = frp
    size         = 1024
    ro           = 0
    user_type    = 0x8000
    keydata      = 0x8000

;------------------------------>empty
;------------------------------>mmcblk0p13/nand0p13
[partition]
    name         = empty
    size         = 31744
    ro           = 0
    user_type    = 0x8000

;------------------------------>device tree overlay
;------------------------------>mmcblk0p14/nand0p14
[partition]
    name         = dto
    size         = 32768
    user_type    = 0x8000

;------------------------------>media_data
;------------------------------>mmcblk0p15/nand0p15
[partition]
    name         = media_data
    size         = 32768
    user_type    = 0x8000
;add by tuliyuan for new block device
;------------------------------>mmcblk0p16/nand0p16
[partition]
    name         = vtechfs              -->块设备名称
    downloadfile = "vtechfs.fex"  -->块设备对应的img
    size         = 65536          -->块设备大小
    user_type    = 0x8000   -->块设备类型

;------------------------------>UDISK
;------------------------------>mmcblk0p1/nand0p1
[partition]
    name         = UDISK
    user_type    = 0x8100

然后重新pack一下,你会发现无法pack成功~报错信息为

ERROR:  unable to open file vtechfs.fex
ERROR: update mbr file fail
ERROR: update_mbr failed
/home/sn0553/software/project/vtech_aw/sp01/android



Steps4

当然。我们没有vtechfs.fex文件。那这个文件怎么来的,我们知道,全志用的刷机工具是PhoenixSuit;我们通常在make -j8 完了之后,还要pack一下生成很多fex文件供我们烧录使用。那这个pack命令怎么来的?device/softwinner/common/vendorsetup.sh有个function pack();我们是用的这个进行pack的 这个也是我无意间发现的,既然是全志的 那就去device/softwinner看看有没有什么特别的就好了。果然给我找到了! 通过跟踪,我们发现他最终使用的是lichee/tools/pack/pack这个脚本进行的打包fex文件! 我们搜索一下sys_partition.fex中的system.fex吧。果然在这里面搜索到了lichee/tools/pack/pack

function do_pack_android()
{
	local link_real=$(get_realpath ${ANDROID_IMAGE_OUT} ./)

	printf "packing for android\n"

	if [ -z "${ANDROID_IMAGE_OUT}" ] ; then
		pack_error "please specify ANDROID_IMAGE_OUT env"
		exit 1
	fi

	ln -sf ${link_real}/boot.img boot.fex
	ln -sf ${link_real}/system.img system.fex
	ln -sf ${link_real}/recovery.img recovery.fex
	#add by tuliyuan for add a new partition
	ln -s ${LICHEE_OUT}/vtechfs.ext4  vtechfs.fex
	#add end 

	if [ -f ${ANDROID_IMAGE_OUT}/verity_block.img ] ; then
		cp -f ${ANDROID_IMAGE_OUT}/verity_block.img verity_block.fex
	fi

	if [ -f ${ANDROID_IMAGE_OUT}/userdata.img ] ; then
		ln -sf ${link_real}/userdata.img userdata.fex
	fi

        if [ -f ${ANDROID_IMAGE_OUT}/vendor.img ] ; then
                ln -sf ${link_real}/vendor.img vendor.fex
        fi

	if [ "x${PACK_SIG}" = "xsig" ] ; then
		echo "signature sunxi mbr"
		signature sunxi_mbr.fex dlinfo.fex
		echo "signature over"
	elif [ "x${PACK_SECURE}" = "xsecure" ] ; then
		echo "secure"
		do_android_signature
	elif [ "x${PACK_SIG}" = "xprev_refurbish" ] ; then
		echo "prev_refurbish"
		do_android_signature
	else
		echo "normal"
	fi
}

我们看到他把out目录下的system.img 映射成system.fex文件,这就是fex文件的由来,我们需要那我们该怎么编译一个fex文件呢?我们求助,在朋友的点拨下,找到了这个

全志V40 分区


这里有详细描述。于是我进行了一番参考之后。有了如下内容



Steps5

/lichee/tools/build/mkcmd.sh

function mkrootfs()
{
	mk_info "build rootfs ..."

	if [ ${LICHEE_PLATFORM} = "linux" ] ; then

		if [ "x$PACK_TINY_ANDROID" = "xtrue" ]; then
			mk_tinyandroid $1
		elif [ ${SKIP_BR} -ne 0 ]; then
			mk_defroot $1
		else
			if [ "x$PACK_BSPTEST" = "xtrue" ];then
				if [ -d ${LICHEE_BR_OUT}/target ];then
 					rm -rf ${ROOTFS}/target/*
				fi
				if [ -d ${LICHEE_SATA_DIR}/linux/target ];then
					mk_info "copy SATA rootfs"
					cp -a ${LICHEE_SATA_DIR}/linux/target ${LICHEE_BR_OUT}/target/
				fi
			fi

			# buildroot-201611 just not using this
			if [ -z `echo $LICHEE_BR_DIR | grep "201611"` ]; then
				make O=${LICHEE_BR_OUT} -C ${LICHEE_BR_DIR} \
					BR2_TOOLCHAIN_EXTERNAL_PATH=${LICHEE_TOOLCHAIN_PATH} \
					BR2_TOOLCHAIN_EXTERNAL_PREFIX=${LICHEE_CROSS_COMPILER} \
					BR2_JLEVEL=${LICHEE_JLEVEL} target-post-image
			fi

			[ $? -ne 0 ] && mk_error "build rootfs Failed" && return 1

			cp ${LICHEE_BR_OUT}/images/rootfs.ext4 ${LICHEE_PLAT_OUT}

			if [ -f "${LICHEE_BR_OUT}/images/rootfs.squashfs" ]; then
				cp ${LICHEE_BR_OUT}/images/rootfs.squashfs ${LICHEE_PLAT_OUT}
			fi
		fi
	elif [ ${LICHEE_PLATFORM} = "dragonboard" ] ; then
		# buildroot-201611 not supporting dragonboard, i am just say sorry,
		# pls add it, but i just done nothing else
		if [ -d ${LICHEE_TOP_DIR}/buildroot/target ]; then
			echo "Regenerating dragonboard Rootfs..."
			(
			cd ${LICHEE_TOP_DIR}/buildroot/target/${LICHEE_PLATFORM}; \
				if [ ! -d "./rootfs" ]; then \
					echo "extract dragonboard rootfs.tar.gz"; \
					tar zxf ../common/rootfs/rootfs.tar.gz; \
				fi
			)
			prepare_dragonboard_toolchain
			mkdir -p ${LICHEE_TOP_DIR}/buildroot/target/${LICHEE_PLATFORM}/rootfs/lib/modules
			rm -rf ${LICHEE_TOP_DIR}/buildroot/target/${LICHEE_PLATFORM}/rootfs/lib/modules/*
			cp -rf ${LICHEE_KERN_DIR}/output/lib/modules/* \
				${LICHEE_TOP_DIR}/buildroot/target/${LICHEE_PLATFORM}/rootfs/lib/modules/
			(cd ${LICHEE_TOP_DIR}/buildroot/target/common/scripts; ./build.sh)
					[  $? -ne 0 ] && mk_error "build rootfs Failed" && return 1
			cp ${LICHEE_TOP_DIR}/buildroot/target/${LICHEE_PLATFORM}/rootfs.ext4 ${LICHEE_PLAT_OUT}
		fi
	else
#add by tuliyuan for custom partition
#add start
        mk_info "tuliyuan mk_tinyandroid LICHEE_PLAT_OUT $LICHEE_PLAT_OUT "
    #//这里是要压缩的成分区的地方
	VTECH_FS_PATH=${LICHEE_TOOLS_DIR}/product/configs/a1/vtech/
	NR_SIZE=`du -sm ${VTECH_FS_PATH} | awk '{print $1}'`
	# 配置的分区大小 至少32M
	NEW_NR_SIZE=$(((($NR_SIZE+32)/16)*16)) 

	echo "blocks: $NR_SIZE"M" -> $NEW_NR_SIZE"M""
	${LICHEE_TOOLS_DIR}/build/bin/make_ext4fs -l \
		$NEW_NR_SIZE"M" ${LICHEE_PLAT_OUT}/vtechfs.ext4 ${VTECH_FS_PATH}
	fsck.ext4 -y ${LICHEE_PLAT_OUT}/vtechfs.ext4 > /dev/null
       

#add end
		mk_info "skip make rootfs for ${LICHEE_PLATFORM}"
	fi

	mk_info "build rootfs OK."
}

这里配置了以后我们先让mkcmd.sh脚本走一下编译一下lichee

root@abc:~/software/project/vtech_aw/sp01$ ls -l
drwxr-xr-x 31 sn0553 sn0553   4096 9月  22 12:17 android
lrwxrwxrwx  1 sn0553 sn0553     32 5月   7 18:27 compile.sh -> customize/tools/build/compile.sh
drwxr-xr-x  5 sn0553 sn0553   4096 5月   7 19:27 customize
drwxr-xr-x  8 sn0553 sn0553   4096 9月  22 09:44 lichee
drwxr-xr-x  4 sn0553 sn0553   4096 5月   7 18:28 modem
root@abc:~/software/project/vtech_aw/sp01$ cd lichee
root@abc:~/software/project/vtech_aw/sp01/lichee$ rm -rf linux-4.9/.config
root@abc:~/software/project/vtech_aw/sp01/lichee$ ./build.sh

生成对应的vtechfs.fex文件.



Steps6

如此这般加上上面的pack,我们就添加分区成功并且挂载了。剩下的selinux 权限,无非就是file.te 里面自定义type,file_context里面把vtech目录指向自定义的type,然后system_app.te里面加入读写权限就可以了。然后我们开机。adb shell ;在看看ls -lZ 查看目录对应的用户组和安全权限,我用户组之前一直为root 。后面在init.rc中的on boot的时候 再chown system system /vtech就可以了。 但是我们发现security context仍旧不是我们定义的,vtechfs 这原因就是selinux加载在分区挂载之前,所以我们需要重新分配这个目录的security context

init.rc

on fs
    restorecon_recursive /vtech
 on boot 
    chown system system /vtech

一切大功告成,如下为patch补丁包!



A50新增分区Patch

 From 1faa986a7af21dbf94e0ad780f43f41dc390bb68 Mon Sep 17 00:00:00 2001
From: "liyuan.tu" <975150240@qq.com>
Date: Tue, 22 Sep 2020 14:25:48 +0800
Subject: [PATCH] =?UTF-8?q?[VTECH]=20[Partition]=201.=E6=96=B0=E5=A2=9Evte?=
 =?UTF-8?q?chfs=E5=88=86=E5=8C=BA=20=E6=8C=82=E8=BD=BD=E7=82=B9=E4=B8=BA/v?=
 =?UTF-8?q?tech?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit


diff --git a/android/device/softwinner/common/sepolicy/vendor/attributes b/android/device/softwinner/common/sepolicy/vendor/attributes
new file mode 100644
index 0000000000..bfb26350bc
--- /dev/null
+++ b/android/device/softwinner/common/sepolicy/vendor/attributes
@@ -0,0 +1 @@
+attribute vtech_file_type;
diff --git a/android/device/softwinner/common/sepolicy/vendor/file.te b/android/device/softwinner/common/sepolicy/vendor/file.te
new file mode 100644
index 0000000000..42d00028e2
--- /dev/null
+++ b/android/device/softwinner/common/sepolicy/vendor/file.te
@@ -0,0 +1 @@
+type vtechfs, vtech_file_type, file_type;
diff --git a/android/device/softwinner/common/sepolicy/vendor/file_contexts b/android/device/softwinner/common/sepolicy/vendor/file_contexts
index acf4365ad2..b97ac891c9 100755
--- a/android/device/softwinner/common/sepolicy/vendor/file_contexts
+++ b/android/device/softwinner/common/sepolicy/vendor/file_contexts
@@ -88,3 +88,6 @@
 
 # awbms
 /system/bin/awbms           u:object_r:shell_exec:s0
+
+#add by tuliyuan for vtechfs 
+/vtech(/.*)?                u:object_r:vtechfs:s0
diff --git a/android/device/softwinner/common/sepolicy/vendor/init.te b/android/device/softwinner/common/sepolicy/vendor/init.te
index 5656277162..6562a31016 100755
--- a/android/device/softwinner/common/sepolicy/vendor/init.te
+++ b/android/device/softwinner/common/sepolicy/vendor/init.te
@@ -22,5 +22,7 @@ allow init sysfs:file create;
 allow init sysfs_zram:dir { write add_name };
 allow init sysfs_zram:file create;
 allow init debugfs:dir mounton;
+#============= init ==============
+allow init vtechfs:dir create;
 #allow init rootfs:file create;
 
diff --git a/android/device/softwinner/common/sepolicy/vendor/shell.te b/android/device/softwinner/common/sepolicy/vendor/shell.te
index c5999f8c1b..51663aa8a7 100755
--- a/android/device/softwinner/common/sepolicy/vendor/shell.te
+++ b/android/device/softwinner/common/sepolicy/vendor/shell.te
@@ -6,4 +6,6 @@ allow shell sysfs_zram:file { read getattr open };
 allow shell hal_memtrack_default:binder call;
 allow shell untrusted_app_25:process { getsched setsched };
 allow shell untrusted_app:process { getsched setsched };
+allow shell vtechfs:file { open read write rw_file_perms create };
+allow shell vtechfs:dir { add_name search create read write rw_file_perms };
 set_prop(shell, system_prop)
diff --git a/android/device/softwinner/common/sepolicy/vendor/system_app.te b/android/device/softwinner/common/sepolicy/vendor/system_app.te
index 2759ddf680..8fa6ec7111 100644
--- a/android/device/softwinner/common/sepolicy/vendor/system_app.te
+++ b/android/device/softwinner/common/sepolicy/vendor/system_app.te
@@ -7,5 +7,8 @@ allow system_app device:chr_file { ioctl open read write };
 allow system_app installd_service:service_manager find;
 allow system_app netd_service:service_manager find;
 allow system_app wificond:binder call;
+#============= system_app ==============
+allow system_app vtechfs:dir { add_name create_dir_perms create_dir_perms create_file_perms write read getattr };
+allow system_app vtechfs:file { open create read write getattr};
 
 
diff --git a/android/device/softwinner/common/sepolicy/vendor/vtechfs.te b/android/device/softwinner/common/sepolicy/vendor/vtechfs.te
new file mode 100644
index 0000000000..1f4f89ad81
--- /dev/null
+++ b/android/device/softwinner/common/sepolicy/vendor/vtechfs.te
@@ -0,0 +1,2 @@
+#============= vtechfs ==============
+allow vtechfs rootfs:filesystem associate;
diff --git a/android/device/softwinner/venus-a1/fstab.sun8iw15p1 b/android/device/softwinner/venus-a1/fstab.sun8iw15p1
index 4a430009bd..1e9642c506 100644
--- a/android/device/softwinner/venus-a1/fstab.sun8iw15p1
+++ b/android/device/softwinner/venus-a1/fstab.sun8iw15p1
@@ -18,3 +18,5 @@
 /devices/platform/soc/5200000.ehci1-controller/usb*    auto    auto    defaults    voldmanaged=usb:auto
 /devices/platform/soc/5101000.ohci0-controller/usb*    auto    auto    defaults    voldmanaged=usb:auto
 /devices/platform/soc/5200000.ohci1-controller/usb*    auto    auto    defaults    voldmanaged=usb:auto
+#add by tuliyuan for vtech factory
+/dev/block/by-name/vtechfs        /vtech    ext4    noatime,nosuid,nodev,	   defaults
diff --git a/android/device/softwinner/venus-common/init.sun8iw15p1.rc b/android/device/softwinner/venus-common/init.sun8iw15p1.rc
index a75c41e1af..89c7671131 100755
--- a/android/device/softwinner/venus-common/init.sun8iw15p1.rc
+++ b/android/device/softwinner/venus-common/init.sun8iw15p1.rc
@@ -16,6 +16,13 @@ on init
     mkdir /oem 0550 system system
     export PATH /vendor/xbin:/sbin:/system/sbin:/system/bin:/system/xbin:/vendor/bin
 
+    #add by tuliyuan 
+    mkdir /vtech 777 system system
+
+    #wait /dev/block/by-name/vtechfs
+    #mount ext4 /dev/block/by-name/vtechfs /vtech rw nosuid nodev utf8,context=u:object_r:vtechfs:s0
+    
+
 on early-fs
     wait /dev/block/by-name/media_data
     mount vfat /dev/block/by-name/media_data /oem ro nosuid nodev utf8,context=u:object_r:oemfs:s0
@@ -23,8 +30,10 @@ on early-fs
 on fs
     mount_all /vendor/etc/fstab.sun8iw15p1
     swapon_all /vendor/etc/fstab.sun8iw15p1
+
     restorecon_recursive /persist
 
+    restorecon_recursive /vtech
 on late-fs
     # gpu
     insmod /vendor/modules/mali.ko
@@ -35,14 +44,15 @@ on post-fs-data
 on boot
     chown system system /sys/kernel/debug/sync/sw_sync
     chmod 0660 /sys/kernel/debug/sync/sw_sync
-
+    
+#add by tuliyuan
+    chown system system /vtech
 on post-fs-data
     # mkdir for optee
     mkdir /data/tee 0770 system system
     # create file for audio dump data
     mkdir /data/audio_d 0777 audio audio
     restorecon_recursive /data/tee
-
 on charger
     chown system system /dev/alarm
     chmod 0660 /dev/alarm
diff --git a/lichee/buildroot/scripts/mkcmd.sh b/lichee/buildroot/scripts/mkcmd.sh
index 6df50921cc..99ee6b315a 100755
--- a/lichee/buildroot/scripts/mkcmd.sh
+++ b/lichee/buildroot/scripts/mkcmd.sh
@@ -456,7 +456,6 @@ function mk_tinyandroid()
 	mkdir -p ${ROOTFS}/lib/modules
 	cp -rf ${LICHEE_KERN_DIR}/output/lib/modules/* \
 		${ROOTFS}/lib/modules/
-
 	if [ "x$PACK_BSPTEST" = "xtrue" ];then
 		if [ -d ${ROOTFS}/target ];then
 			rm -rf ${ROOTFS}/target/*
@@ -479,7 +478,6 @@ function mk_tinyandroid()
 function mkrootfs()
 {
     mk_info "build rootfs ..."
-
     if [ ${LICHEE_PLATFORM} = "linux" ] ; then
         if [ "x$PACK_TINY_ANDROID" = "xtrue" ]; then
             mk_tinyandroid $1
@@ -523,7 +521,7 @@ function mkrootfs()
         (cd ${LICHEE_BR_DIR}/target/dragonboard; ./build.sh)
         cp ${LICHEE_BR_DIR}/target/dragonboard/rootfs.ext4 ${LICHEE_PLAT_OUT}
     else
-        mk_info "skip make rootfs for ${LICHEE_PLATFORM}"
+	mk_info "skip make rootfs for ${LICHEE_PLATFORM}"
     fi
 
     mk_info "build rootfs OK."
diff --git a/lichee/tools/build/mkcmd.sh b/lichee/tools/build/mkcmd.sh
index 02fd3dc01d..f1d2d0ef98 100755
--- a/lichee/tools/build/mkcmd.sh
+++ b/lichee/tools/build/mkcmd.sh
@@ -748,6 +748,21 @@ function mkrootfs()
 			cp ${LICHEE_TOP_DIR}/buildroot/target/${LICHEE_PLATFORM}/rootfs.ext4 ${LICHEE_PLAT_OUT}
 		fi
 	else
+#add by tuliyuan for custom partition
+#add start
+        mk_info "tuliyuan mk_tinyandroid LICHEE_PLAT_OUT $LICHEE_PLAT_OUT "
+
+	VTECH_FS_PATH=${LICHEE_TOOLS_DIR}/product/configs/a1/vtech/
+	NR_SIZE=`du -sm ${VTECH_FS_PATH} | awk '{print $1}'`
+	NEW_NR_SIZE=$(((($NR_SIZE+32)/16)*16))
+
+	echo "blocks: $NR_SIZE"M" -> $NEW_NR_SIZE"M""
+	${LICHEE_TOOLS_DIR}/build/bin/make_ext4fs -l \
+		$NEW_NR_SIZE"M" ${LICHEE_PLAT_OUT}/vtechfs.ext4 ${VTECH_FS_PATH}
+	fsck.ext4 -y ${LICHEE_PLAT_OUT}/vtechfs.ext4 > /dev/null
+       
+
+#add end
 		mk_info "skip make rootfs for ${LICHEE_PLATFORM}"
 	fi
 
diff --git a/lichee/tools/pack/chips/sun8iw15p1/configs/a1/sys_partition.fex b/lichee/tools/pack/chips/sun8iw15p1/configs/a1/sys_partition.fex
index 53bb6b4450..670cd61bc0 100755
--- a/lichee/tools/pack/chips/sun8iw15p1/configs/a1/sys_partition.fex
+++ b/lichee/tools/pack/chips/sun8iw15p1/configs/a1/sys_partition.fex
@@ -132,6 +132,13 @@ size = 16384
     size         = 32768
     user_type    = 0x8000
 
+;------------------------------>mmcblk0p16/nand0p16
+[partition]
+    name         = vtechfs
+    downloadfile = "vtechfs.fex"
+    size         = 65536
+    user_type    = 0x8000
+
 ;------------------------------>UDISK
 ;------------------------------>mmcblk0p1/nand0p1
 [partition]
diff --git a/lichee/tools/pack/chips/sun8iw15p1/configs/a1/vtech/madsd b/lichee/tools/pack/chips/sun8iw15p1/configs/a1/vtech/madsd
new file mode 100644
index 0000000000..1f40f85ba8
--- /dev/null
+++ b/lichee/tools/pack/chips/sun8iw15p1/configs/a1/vtech/madsd
@@ -0,0 +1,6 @@
+asd ad,l;
+
+sf mdmafm 
+fldsmfioaasfi jdois
+fmsadlf ajksdf
+
diff --git a/lichee/tools/pack/pack b/lichee/tools/pack/pack
index 8d20a7d9e4..bb8c7d9859 100755
--- a/lichee/tools/pack/pack
+++ b/lichee/tools/pack/pack
@@ -935,6 +935,9 @@ function do_pack_android()
 	ln -sf ${link_real}/boot.img boot.fex
 	ln -sf ${link_real}/system.img system.fex
 	ln -sf ${link_real}/recovery.img recovery.fex
+	#add by tuliyuan for add a new partition
+	ln -s ${LICHEE_OUT}/vtechfs.ext4  vtechfs.fex
+	#add end 
 
 	if [ -f ${ANDROID_IMAGE_OUT}/verity_block.img ] ; then
 		cp -f ${ANDROID_IMAGE_OUT}/verity_block.img verity_block.fex
-- 
2.17.1



附录

顺便来个app读写的代码工具类,没有优化过。ResultUtils.java

package abcdefg.

import android.util.Log;

import abcdefg.TestList;//包名码住,这个类是测试项的一个汇总 做个参考就好了


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;


public class ResultUtils {
    private static ResultUtils INSTANCE = null;
    private final String TAG = "ResultUtils";
    //文件保存路径
    public static final String FILE_PATH = "/vtech/factory_result";
    public static final int RESULT_DEFAULT = -1;
    public static final int RESULT_SUCCESS = 1;
    public static final int RESULT_FAILED = 0;

    private LinkedHashMap<String, Integer> mResult = new LinkedHashMap<>();


    /**
     * 获取本地缓存的测试结果表
     *
     * @return 一个有序的hashmap表
     */

    public LinkedHashMap<String, Integer> getResult() {
        File file = new File(FILE_PATH);
        //初始化,文件不存在,则为第一次刷机测试,创建文件,并写入默认值.
        if (!file.exists()) {
            Log.d(TAG, "getResult 文件不存在!开始创建,并设置默认值!");
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
            for (int i = 0; i < TestList.getCount(); i++) {
                // Log.d("ResultUtils"," put string "+TestList.get(i).getClass().getSimpleName());
                mResult.put(TestList.get(i).getClass().getSimpleName(), ResultUtils.RESULT_DEFAULT);
            }
            writeFileData(map2string(mResult));
        }
        return mResult;
    }


    public static ResultUtils getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new ResultUtils();
        }
        return INSTANCE;
    }

    /**
     * 初始化,我放在application类中
     * 文件不存在 则创建文件。并添加默认值。
     * 文件存在 则给本地的测试结果hasmap表赋值
     */
    public void init() {
        Log.d(TAG, "init ... ");
        File file = new File(FILE_PATH);
        //初始化,文件不存在,则为第一次刷机测试,创建文件,并写入默认值.
        if (!file.exists()) {
            Log.d(TAG, "init 文件不存在!开始创建,并设置默认值!");
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
            for (int i = 0; i < TestList.getCount(); i++) {
                // Log.d("ResultUtils"," put string "+TestList.get(i).getClass().getSimpleName());
                mResult.put(TestList.get(i).getClass().getSimpleName(), ResultUtils.RESULT_DEFAULT);
            }
            writeFileData(map2string(mResult));
        } else {//文件存在。已进行过测试,读取配置
            Log.d(TAG, "init 文件存在! 开始读取测试结果");
            mResult = getStringToMap(readStringFromFile());
        }
    }

    /**
     * 向文本中写入数据
     *
     * @param content 是String 类型的 由hashmap转换而来
     */

    public void writeFileData(String content) {
        Log.d(TAG, " 将在 " + FILE_PATH + "此文件中写入内容: " + content);
        try {
            File file = new File(FILE_PATH);
            FileOutputStream fos = new FileOutputStream(file);
            //将要写入的字符串转换为byte数组
            byte[] bytes = content.getBytes();
            fos.write(bytes);//将byte数组写入文件
            fos.close();//关闭文件输出流

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 读取文本中的数据
     *
     * @return 返回的是String类型的数据流
     */

    public String readStringFromFile() {
        String content = "";
        File file = new File(FILE_PATH);
        if (!file.exists()) {
            Log.d(TAG, "readStringFromFile 文件不存在!");
            content = "";
            return content;
        }

        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            int length = fileInputStream.available();
            byte[] bytes = new byte[length];
            fileInputStream.read(bytes);

            content = new String(bytes, "UTF-8");

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Log.d(TAG, "readStringFromFile  content is " + content);
        return content;
    }

    /**
     * string转为map
     *
     * @param str 传入参数String
     * @return 返回参数LinkedHashMap
     */

    public LinkedHashMap<String, Integer> getStringToMap(String str) {
        //根据逗号截取字符串数组
        String[] str1 = str.split(",");
        //创建Map对象
        mResult.clear();
        // LinkedHashMap<String, Integer> map = new LinkedHashMap<>();
        //循环加入map集合

        for (int i = 0; i < str1.length; i++) {
            //根据":"截取字符串数组

            String[] str2 = str1[i].split(":");
            //str2[0]为KEY,str2[1]为值
            Log.d(TAG, " str2[0] " + str2[0] + " value is " + Integer.valueOf(str2[1]));
            mResult.put(str2[0], Integer.valueOf(str2[1]));
        }
        Log.d(TAG, "getStringToMap  content is " + mResult.toString());
        return mResult;
    }

    /**
     * map转换为string
     *
     * @param map 传入参数HashMap
     * @return 返回参数 String
     */
    private String map2string(HashMap<String, Integer> map) {


        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < TestList.getCount(); i++) {
            // 参数值为空,则不参与签名 这个方法trim()是去空格
            if ((String.valueOf(map.get(TestList.get(i).getClass().getSimpleName()))).trim().length() > 0) {
                sb.append(TestList.get(i).getClass().getSimpleName()).append(":").append(String.valueOf(map.get(TestList.get(i).getClass().getSimpleName())).trim());
            }
            if (i != TestList.getCount() - 1) {
                sb.append(",");
            }
        }
        return sb.toString();
    }

    /**
     * 更新数据,并全部重新写入文本
     *
     * @param key   测试项
     * @param value 测试项对应的结果
     */
    public void updateItem(String key, int value) {
        mResult.replace(key, value);
        Log.d(TAG, " updateItem 在更新数据之后, 维护的测试结果为: " + mResult.toString());
        writeFileData(map2string(mResult));
    }
}



参考 RK3326 Q 新增自定义分区

From ad112446914b3b8437bb0641cd1f5f01e2372f1d Mon Sep 17 00:00:00 2001
From: "liyuan.tu" <975150240@qq.com>
Date: Fri, 22 Jan 2021 17:55:54 +0800
Subject: [PATCH] =?UTF-8?q?[VTECH=5FVCS800]=20[Parition]=201.=E6=96=B0?=
 =?UTF-8?q?=E5=A2=9E=E8=87=AA=E5=AE=9A=E4=B9=89vtech=E5=88=86=E5=8C=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit


diff --git a/build/make/core/Makefile b/build/make/core/Makefile
index bac49d186e..026a82116d 100755
--- a/build/make/core/Makefile
+++ b/build/make/core/Makefile
@@ -1386,6 +1386,11 @@ $(if $(filter $(2),cache),\
     $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
     $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
 )
+$(if $(filter $(2),vtech),\
+    $(if $(BOARD_VTECHIMAGE_PARTITION_SIZE),$(hide) echo "vtech_size=$(BOARD_VTECHIMAGE_PARTITION_SIZE)" >> $(1))
+    $(if $(BOARD_VTECHIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vtech_fs_type=$(BOARD_VTECHIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
+)
+
 $(if $(filter $(2),vendor),\
     $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
     $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
@@ -1443,6 +1448,8 @@ $(if $(filter $(2),oem),\
     $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
     $(if $(BOARD_OEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "oem_extfs_rsv_pct=$(BOARD_OEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
 )
+
+
 $(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
 
 $(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
@@ -2641,6 +2648,42 @@ else # BUILDING_CACHE_IMAGE
 IGNORE_CACHE_LINK := --exclude=cache
 endif # BUILDING_CACHE_IMAGE
 
+#add for  vtech fs
+BOARD_VTECHIMAGE_FILE_SYSTEM_TYPE := ext4
+ifdef BOARD_VTECHIMAGE_FILE_SYSTEM_TYPE
+INTERNAL_VTECHIMAGE_FILES := \
+    $(filter $(TARGET_OUT_VTECH)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
+
+vtechimage_intermediates := \
+    $(call intermediates-dir-for,PACKAGING,vtech)
+BUILT_VTECHIMAGE_TARGET := $(PRODUCT_OUT)/vtech.img
+
+define build-vtechimage-target
+  $(call pretty,"Target vtech fs image: $(INSTALLED_VTECHIMAGE_TARGET)")
+  @mkdir -p $(TARGET_OUT_VTECH)
+  @mkdir -p $(vtechimage_intermediates) && rm -rf $(vtechimage_intermediates)/vtech_image_info.txt
+  $(call generate-image-prop-dictionary, $(vtechimage_intermediates)/vtech_image_info.txt,vtech,skip_fsck=true)
+  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
+      build/make/tools/releasetools/build_image.py \
+      $(TARGET_OUT_VTECH) $(vtechimage_intermediates)/vtech_image_info.txt $(INSTALLED_VTECHIMAGE_TARGET) $(TARGET_OUT)
+  $(hide) $(call assert-max-image-size,$(INSTALLED_VTECHIMAGE_TARGET),$(BOARD_VTECHIMAGE_PARTITION_SIZE))
+endef
+
+# We just build this directly to the install location.
+INSTALLED_VTECHIMAGE_TARGET := $(BUILT_VTECHIMAGE_TARGET)
+$(INSTALLED_VTECHIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VTECHIMAGE_FILES) $(BUILD_IMAGE_SRCS)
+	$(build-vtechimage-target)
+
+.PHONY: vtechimage-nodeps
+vtechimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
+	$(build-vtechimage-target)
+
+else # BOARD_VTECHIMAGE_FILE_SYSTEM_TYPE
+# we need to ignore the broken vtech link when doing the rsync
+IGNORE_VTECH_LINK := --exclude=vtech
+
+endif
+
 # -----------------------------------------------------------------
 # system_other partition image
 ifdef BUILDING_SYSTEM_OTHER_IMAGE
@@ -3838,6 +3881,7 @@ $(BUILT_TARGET_FILES_PACKAGE): \
 	    $(INSTALLED_USERDATAIMAGE_TARGET) \
 	    $(INSTALLED_CACHEIMAGE_TARGET) \
 	    $(INSTALLED_VENDORIMAGE_TARGET) \
+	    $(INSTALLED_VTECHIMAGE_TARGET) \
 	    $(INSTALLED_PRODUCTIMAGE_TARGET) \
 	    $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) \
 	    $(INSTALLED_VBMETAIMAGE_TARGET) \
diff --git a/build/make/core/config.mk b/build/make/core/config.mk
index b59862ee2a..44ff422d3a 100644
--- a/build/make/core/config.mk
+++ b/build/make/core/config.mk
@@ -1156,6 +1156,7 @@ dont_bother_goals := out \
     psnod productservicesimage-nodeps \
     onod odmimage-nodeps \
     systemotherimage-nodeps \
+    vtechimage-nodeps \
     ramdisk-nodeps \
     ramdisk_debug-nodeps \
     bootimage-nodeps \
diff --git a/build/make/core/envsetup.mk b/build/make/core/envsetup.mk
index 5131598a94..30a82665e0 100644
--- a/build/make/core/envsetup.mk
+++ b/build/make/core/envsetup.mk
@@ -599,6 +599,8 @@ endif
 TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
 .KATI_READONLY := TARGET_OUT_CACHE
 
+TARGET_OUT_VTECH := $(PRODUCT_OUT)/vtech
+
 TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
 .KATI_READONLY := TARGET_OUT_VENDOR
 ifneq ($(filter address,$(SANITIZE_TARGET)),)
diff --git a/build/make/core/main.mk b/build/make/core/main.mk
index 7465743d88..6a53fd7097 100644
--- a/build/make/core/main.mk
+++ b/build/make/core/main.mk
@@ -1587,6 +1587,9 @@ bptimage: $(INSTALLED_BPTIMAGE_TARGET)
 .PHONY: vendorimage
 vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
 
+.PHONY: vtechimage
+vtechimage: $(INSTALLED_VTECHIMAGE_TARGET)
+
 .PHONY: productimage
 productimage: $(INSTALLED_PRODUCTIMAGE_TARGET)
 
@@ -1628,6 +1631,7 @@ droidcore: $(filter $(HOST_OUT_ROOT)/%,$(modules_to_install)) \
     $(INSTALLED_CACHEIMAGE_TARGET) \
     $(INSTALLED_BPTIMAGE_TARGET) \
     $(INSTALLED_VENDORIMAGE_TARGET) \
+    $(INSTALLED_VTECHIMAGE_TARGET) \
     $(INSTALLED_ODMIMAGE_TARGET) \
     $(INSTALLED_SUPERIMAGE_EMPTY_TARGET) \
     $(INSTALLED_PRODUCTIMAGE_TARGET) \
diff --git a/build/make/tools/releasetools/build_image.py b/build/make/tools/releasetools/build_image.py
index 4136ed432e..428769ba44 100755
--- a/build/make/tools/releasetools/build_image.py
+++ b/build/make/tools/releasetools/build_image.py
@@ -597,6 +597,9 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
   elif mount_point == "cache":
     copy_prop("cache_fs_type", "fs_type")
     copy_prop("cache_size", "partition_size")
+  elif mount_point == "vtech":
+    copy_prop("vtech_fs_type", "fs_type")
+    copy_prop("vtech_size", "partition_size")
   elif mount_point == "vendor":
     copy_prop("avb_vendor_hashtree_enable", "avb_hashtree_enable")
     copy_prop("avb_vendor_add_hashtree_footer_args",
@@ -769,6 +772,8 @@ def main(argv):
       mount_point = "oem"
     elif image_filename == "product.img":
       mount_point = "product"
+    elif image_filename == "vtech.img":
+      mount_point = "vtech"
     elif image_filename == "product_services.img":
       mount_point = "product_services"
     else:
diff --git a/device/rockchip/common/BoardConfig.mk b/device/rockchip/common/BoardConfig.mk
index 7006707622..c760df33a8 100755
--- a/device/rockchip/common/BoardConfig.mk
+++ b/device/rockchip/common/BoardConfig.mk
@@ -119,7 +119,7 @@ ifeq ($(strip $(USE_DEFAULT_PARAMETER)), true)
   BOARD_BOOTIMAGE_PARTITION_SIZE := $(shell python device/rockchip/common/get_partition_size.py $(TARGET_DEVICE_DIR)/parameter.txt boot)
   BOARD_DTBOIMG_PARTITION_SIZE := $(shell python device/rockchip/common/get_partition_size.py $(TARGET_DEVICE_DIR)/parameter.txt dtbo)
   BOARD_RECOVERYIMAGE_PARTITION_SIZE := $(shell python device/rockchip/common/get_partition_size.py $(TARGET_DEVICE_DIR)/parameter.txt recovery)
-
+  BOARD_VTECHIMAGE_PARTITION_SIZE := $(shell python device/rockchip/common/get_partition_size.py $(TARGET_DEVICE_DIR)/parameter.txt vtech)
   #$(info Calculated BOARD_SYSTEMIMAGE_PARTITION_SIZE=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE) use $(TARGET_DEVICE_DIR)/parameter.txt)
 else
   ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS), true)
@@ -138,6 +138,7 @@ else
   endif
 endif
 
+
 # GPU configration
 TARGET_BOARD_PLATFORM_GPU ?= mali-t760
 BOARD_USE_LCDC_COMPOSER ?= false
@@ -248,7 +249,7 @@ TARGET_ROCHCHIP_RECOVERY ?= true
 BOARD_HAS_FLIPPED_SCREEN ?= false
 
 # Auto update package from USB
-RECOVERY_AUTO_USB_UPDATE ?= false
+RECOVERY_AUTO_USB_UPDATE ?= true
 
 # To use bmp as kernel logo, uncomment the line below to use bgra 8888 in recovery
 TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
diff --git a/device/rockchip/common/init.rk30board.rc b/device/rockchip/common/init.rk30board.rc
index 2d1b7ac1e1..3772d2035f 100755
--- a/device/rockchip/common/init.rk30board.rc
+++ b/device/rockchip/common/init.rk30board.rc
@@ -6,9 +6,11 @@ import /vendor/etc/init/hw/init.${ro.target.product}.rc
 import /vendor/etc/init/hw/init.car.rc
 import /vendor/etc/init/hw/init.optee.rc
 
+
 on post-fs
     restorecon_recursive /mnt/vendor/metadata
 
+
 on post-fs-data
     # AP6476 GPS permission
     chmod 755 /system/bin/glgps
@@ -25,7 +27,10 @@ on post-fs-data
 
     mkdir /data/vendor/logs 0755 root shell
     mkdir /data/vendor/audio 0755 system system
-
+   # mount ext4 /dev/block/by-name/vtech /vtech wait noatime nodiratime nosuid nodev noauto_da_alloc
+    chown system system /vtech
+    chmod 0771 /vtech
+    
 on early-init
     setprop ro.hardware.egl mali
     write /sys/devices/system/cpu/cpufreq/policy0/scaling_governor performance
@@ -39,9 +44,12 @@ on init
     chmod 0666 /dev/teepriv0
     chown system system /sys/system_monitor/system_status
     chmod 0666 /sys/system_monitor/system_status
-
+    
+    	
+    
 on boot
 
+   
     chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate
     chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate
     chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_slack
diff --git a/device/rockchip/common/scripts/fstab_tools/fstab.in b/device/rockchip/common/scripts/fstab_tools/fstab.in
index 266531ac72..82d4fe11fa 100755
--- a/device/rockchip/common/scripts/fstab_tools/fstab.in
+++ b/device/rockchip/common/scripts/fstab_tools/fstab.in
@@ -19,3 +19,5 @@ ${_block_prefix}product /product  ext4 ro,barrier=1 ${_flags},first_stage_mount
 /dev/block/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065,fsync_mode=nobarrier latemount,wait,check,fileencryption=software,quota,formattable,reservedsize=128M,checkpoint=fs
 # for ext4
 #/dev/block/by-name/userdata    /data      ext4    discard,noatime,nosuid,nodev,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait,formattable,check,fileencryption=software,quota,reservedsize=128M
+#add by tuliyuan
+/dev/block/by-name/vtech        /vtech    ext4    noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard	    wait,check
diff --git a/device/rockchip/common/sepolicy/vendor/device.te b/device/rockchip/common/sepolicy/vendor/device.te
index bfc7713c55..231e24daa8 100755
--- a/device/rockchip/common/sepolicy/vendor/device.te
+++ b/device/rockchip/common/sepolicy/vendor/device.te
@@ -32,3 +32,5 @@ type cec_device, dev_type;
 
 #for hid audio
 type hidraw_device, dev_type;
+#for vtech fs
+type vtech_block_device, dev_type;
diff --git a/device/rockchip/common/sepolicy/vendor/file.te b/device/rockchip/common/sepolicy/vendor/file.te
index b3b5b5b14f..78dbc3f30c 100755
--- a/device/rockchip/common/sepolicy/vendor/file.te
+++ b/device/rockchip/common/sepolicy/vendor/file.te
@@ -50,3 +50,4 @@ type sysfs_mmc, fs_type, sysfs_type;
 # input files
 type idc_file, file_type, vendor_file_type;
 type keylayout_file, file_type, vendor_file_type;
+type vtechfs, file_type, data_file_type;
diff --git a/device/rockchip/common/sepolicy/vendor/file_contexts b/device/rockchip/common/sepolicy/vendor/file_contexts
index 4a35a7638d..0f029833ae 100644
--- a/device/rockchip/common/sepolicy/vendor/file_contexts
+++ b/device/rockchip/common/sepolicy/vendor/file_contexts
@@ -71,7 +71,7 @@
 /dev/block/by-name/security                     u:object_r:security_block_device:s0
 /dev/block/by-name/baseparameter                u:object_r:baseparameter_block_device:s0
 /dev/block/by-name/super                        u:object_r:super_block_device:s0
-
+/dev/block/by-name/vtech  			u:object_r:vtech_block_device:s0
 /sys/devices/platform/fb/graphics/fb[0-9]/cabc                u:object_r:sysfs_fb:s0
 /sys/kernel/debug/mali/gpu_memory                u:object_r:sys_mali:s0
 
@@ -176,3 +176,4 @@
 
 #flash_img
 /system/bin/flash_img.sh u:object_r:install_recovery_exec:s0
+/vtech(/.*)? u:object_r:vtechfs:s0
diff --git a/device/rockchip/common/sepolicy/vendor/fsck.te b/device/rockchip/common/sepolicy/vendor/fsck.te
index 9322f9e2c0..4d461d31f5 100644
--- a/device/rockchip/common/sepolicy/vendor/fsck.te
+++ b/device/rockchip/common/sepolicy/vendor/fsck.te
@@ -1,3 +1,4 @@
 allow fsck e2fsck_oem_block_device:blk_file rw_file_perms;
 allow fsck e2fsck_cache_block_device:blk_file rw_file_perms;
 allow fsck e2fsck_frp_block_device:blk_file rw_file_perms;
+allow fsck vtech_block_device:blk_file rw_file_perms;
diff --git a/device/rockchip/common/sepolicy/vendor/init.te b/device/rockchip/common/sepolicy/vendor/init.te
index fadab5af8c..235c32f9bc 100755
--- a/device/rockchip/common/sepolicy/vendor/init.te
+++ b/device/rockchip/common/sepolicy/vendor/init.te
@@ -55,4 +55,7 @@ allow init baseparameter_block_device:lnk_file { relabelto setattr };
 allow init vendor_file:file { execute open};
 allow init oemfs:dir { mounton };
 allow init mnt_vendor_file:dir { mounton };
+allow init vtech_block_device:lnk_file { relabelto };
+allow init vtech_block_device:blk_file { write };
+allow init vtechfs:dir { create setattr getattr mounton };
 dontaudit init proc:file { write setattr };
diff --git a/device/rockchip/common/sepolicy/vendor/system_app.te b/device/rockchip/common/sepolicy/vendor/system_app.te
index ede1d64c4b..0bdd3ae68d 100644
--- a/device/rockchip/common/sepolicy/vendor/system_app.te
+++ b/device/rockchip/common/sepolicy/vendor/system_app.te
@@ -52,3 +52,5 @@ allow system_app proc_net:file { getattr open read };
 get_prop(system_app,serialno_prop)
 get_prop(system_app, vtech_prop)
 set_prop(system_app, vtech_prop)
+allow system_app vtechfs:dir rw_file_perms;
+allow system_app vtechfs:file rw_file_perms;
diff --git a/device/rockchip/common/sepolicy/vendor/vendor_init.te b/device/rockchip/common/sepolicy/vendor/vendor_init.te
index 3712d5d4e5..56b18df594 100644
--- a/device/rockchip/common/sepolicy/vendor/vendor_init.te
+++ b/device/rockchip/common/sepolicy/vendor/vendor_init.te
@@ -38,3 +38,9 @@ set_prop(vendor_init, dalvik_prop)
 set_prop(vendor_init, vendor_drm_prop)
 set_prop(vendor_init, public_vendor_system_prop)
 set_prop(vendor_init, public_vendor_default_prop)
+
+allow vendor_init vtechfs:dir rw_dir_perms;
+allow vendor_init vtech_block_device:lnk_file { relabelto };
+#============= vendor_init ==============
+allow vendor_init vtechfs:dir { create setattr getattr mounton };
+allow vendor_init sysfs:lnk_file { setattr getattr read open };
diff --git a/device/rockchip/common/sepolicy/vendor/vold.te b/device/rockchip/common/sepolicy/vendor/vold.te
index 53562ff34a..c1b81a0c8b 100644
--- a/device/rockchip/common/sepolicy/vendor/vold.te
+++ b/device/rockchip/common/sepolicy/vendor/vold.te
@@ -10,3 +10,5 @@ allow vold self:capability { setgid setuid };
 allow vold vold_device:blk_file ioctl;
 allow vold vold_exec:file execute_no_trans;
 allow vold self:capability { dac_override dac_read_search };
+allow vold vtechfs:dir { read open write getattr setattr };
+#allow vold vtechfs:dir ioctl;
diff --git a/device/rockchip/rk3326/VTECH_VP02/BoardConfig.mk b/device/rockchip/rk3326/VTECH_VP02/BoardConfig.mk
index 817f37284e..f552e2086a 100755
--- a/device/rockchip/rk3326/VTECH_VP02/BoardConfig.mk
+++ b/device/rockchip/rk3326/VTECH_VP02/BoardConfig.mk
@@ -24,3 +24,5 @@ TARGET_CPU_VARIANT := cortex-a53
 TARGET_CPU_SMP := true
 
 PRODUCT_KERNEL_CONFIG := rockchip_defconfig android-10-go.config rk3326.config
+#add by tuliyuan for default vtech parition
+#BOARD_VTECHIMAGE_PARTITION_SIZE := 52428800
diff --git a/device/rockchip/rk3326/VTECH_VP02/parameter.txt b/device/rockchip/rk3326/VTECH_VP02/parameter.txt
index 494598e87d..888983bcb0 100755
--- a/device/rockchip/rk3326/VTECH_VP02/parameter.txt
+++ b/device/rockchip/rk3326/VTECH_VP02/parameter.txt
@@ -8,4 +8,4 @@ MACHINE: 3326
 CHECK_MASK: 0x80
 PWR_HLD: 0,0,A,0,1
 TYPE: GPT
-CMDLINE:mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(trust),0x00002000@0x00008000(misc),0x00002000@0x0000a000(dtb),0x00002000@0x0000c000(dtbo),0x00000800@0x0000e000(vbmeta),0x00010000@0x0000e800(boot),0x00030000@0x0001e800(recovery),0x00038000@0x0004e800(backup),0x00002000@0x00086800(security),0x000c0000@0x00088800(cache),0x00008000@0x00148800(metadata),0x00000400@0x00150800(frp),0x004fe000@0x00150c00(super),-@0x0064ec00(userdata:grow)
+CMDLINE:mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(trust),0x00002000@0x00008000(misc),0x00002000@0x0000a000(dtb),0x00002000@0x0000c000(dtbo),0x00000800@0x0000e000(vbmeta),0x00010000@0x0000e800(boot),0x00030000@0x0001e800(recovery),0x00038000@0x0004e800(backup),0x00002000@0x00086800(security),0x000c0000@0x00088800(cache),0x00008000@0x00148800(metadata),0x00000400@0x00150800(frp),0x004fe000@0x00150c00(super),0x00010000@0x0064ec00(vtech),-@0x0065ec00(userdata:grow)
diff --git a/device/rockchip/rk3326/VTECH_VP02/recovery.fstab b/device/rockchip/rk3326/VTECH_VP02/recovery.fstab
index d66d0905b8..cb3d950cde 100755
--- a/device/rockchip/rk3326/VTECH_VP02/recovery.fstab
+++ b/device/rockchip/rk3326/VTECH_VP02/recovery.fstab
@@ -24,3 +24,4 @@
 /dev/block/by-name/baseparamer           /baseparamer         emmc             defaults                  defaults
 /dev/block/by-name/vbmeta                /vbmeta              emmc             defaults                  defaults
 /dev/block/by-name/dtbo                /dtbo              emmc             defaults                  defaults
+/dev/block/by-name/vtech               /vtech                 ext4             defaults	   defaults
diff --git a/mkimage.sh b/mkimage.sh
index 134a836cc5..3ffd5a82e9 100755
--- a/mkimage.sh
+++ b/mkimage.sh
@@ -82,6 +82,9 @@ BOARD_DTBO_IMG=$OUT/dtbo.img
 fi
 cp -a $BOARD_DTBO_IMG $IMAGE_PATH/dtbo.img
 echo "done."
+# add by tuliyuan for vtech.img
+echo -n "create vtech.img.... "
+cp -av $OUT/vtech.img $IMAGE_PATH/vtech.img
 
 echo "create boot.img.... "
 if [ "$BOARD_AVB_ENABLE" = "true" ]; then
diff --git a/system/core/rootdir/Android.mk b/system/core/rootdir/Android.mk
index 7ff1588b23..e1c24e5b5e 100644
--- a/system/core/rootdir/Android.mk
+++ b/system/core/rootdir/Android.mk
@@ -121,7 +121,7 @@ endif
 ifdef BOARD_USES_METADATA_PARTITION
   LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/metadata
 endif
-
+LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/vtech
 # For /odm partition.
 LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/odm
 # For Treble Generic System Image (GSI), system-as-root GSI needs to work on
diff --git a/system/sepolicy/prebuilts/api/29.0/public/domain.te b/system/sepolicy/prebuilts/api/29.0/public/domain.te
index 5f2b8ba694..7ed1ddb5df 100755
--- a/system/sepolicy/prebuilts/api/29.0/public/domain.te
+++ b/system/sepolicy/prebuilts/api/29.0/public/domain.te
@@ -838,6 +838,7 @@ full_treble_only(`
     -appdomain # TODO(b/34980020) remove exemption for appdomain
     -data_between_core_and_vendor_violators
     -init
+    -vold
     -vold_prepare_subdirs
     } {
       data_file_type
diff --git a/system/sepolicy/public/domain.te b/system/sepolicy/public/domain.te
index 5f2b8ba694..7ed1ddb5df 100755
--- a/system/sepolicy/public/domain.te
+++ b/system/sepolicy/public/domain.te
@@ -838,6 +838,7 @@ full_treble_only(`
     -appdomain # TODO(b/34980020) remove exemption for appdomain
     -data_between_core_and_vendor_violators
     -init
+    -vold
     -vold_prepare_subdirs
     } {
       data_file_type
-- 
2.17.1



Android 11 RK 3568新增分区

commit 51849e99cfaa66ea290611a6e8943e16e0f90909
Author: tuly <975150240@qq.com>
Date:   Mon Dec 5 15:58:06 2022 +0800

    [all] [New Partition] 1.新增分区Fos. 2.增加shell环境对fos的读写权限

diff --git a/build/make/core/Makefile b/build/make/core/Makefile
index eb82c5c96a..ce51222543 100755
--- a/build/make/core/Makefile
+++ b/build/make/core/Makefile
@@ -1722,6 +1722,13 @@ $(if $(filter $(2),cache),\
     $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
     $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
 )
+# add tuliyuan  fos parition --start
+ $(if $(filter $(2),fos),\
+    $(if $(BOARD_FOSIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "fos_fs_type=$(BOARD_FOSIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
+    $(if $(BOARD_FOSIMAGE_PARTITION_SIZE),$(hide) echo "fos_size=$(BOARD_FOSIMAGE_PARTITION_SIZE)" >> $(1))
+    $(hide) echo "fos_selinux_fc=$(SELINUX_FC)" >> $(1)
+)
+# add tuliyuan fos parition --end
 $(if $(filter $(2),vendor),\
     $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
     $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
@@ -1867,6 +1874,11 @@ PROP_DICTIONARY_IMAGES := oem
 ifdef BUILDING_CACHE_IMAGE
   PROP_DICTIONARY_IMAGES += cache
 endif
+#add tuliyuan fos parition --start
+ifdef BUILDING_FOS_IMAGE
+  PROP_DICTIONARY_IMAGES += fos
+endif
+#add tuliyuan fos parition --end
 ifdef BUILDING_SYSTEM_IMAGE
   PROP_DICTIONARY_IMAGES += system
 endif
@@ -3034,6 +3046,45 @@ else # BUILDING_CACHE_IMAGE
 IGNORE_CACHE_LINK := --exclude=cache
 endif # BUILDING_CACHE_IMAGE
 
+
+#tuliyuan add parition --end
+# -----------------------------------------------------------------
+# fos partition image
+ifdef BUILDING_FOS_IMAGE
+INTERNAL_FOSIMAGE_FILES := \
+    $(filter $(TARGET_OUT_FOS)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
+
+fosimage_intermediates := \
+    $(call intermediates-dir-for,PACKAGING,fos)
+BUILT_FOSIMAGE_TARGET := $(PRODUCT_OUT)/fos.img
+
+define build-fosimage-target
+  $(call pretty,"Target fos fs image: $(INSTALLED_FOSIMAGE_TARGET)")
+  @mkdir -p $(TARGET_OUT_FOS)
+  @mkdir -p $(fosimage_intermediates) && rm -rf $(fosimage_intermediates)/fos_image_info.txt
+  $(call generate-image-prop-dictionary, $(fosimage_intermediates)/fos_image_info.txt,fos,skip_fsck=true)
+  PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
+      $(BUILD_IMAGE) \
+          $(TARGET_OUT_FOS) $(fosimage_intermediates)/fos_image_info.txt \
+          $(INSTALLED_FOSIMAGE_TARGET) $(TARGET_OUT)
+  $(call assert-max-image-size,$(INSTALLED_FOSIMAGE_TARGET),$(BOARD_FOSIMAGE_PARTITION_SIZE))
+endef
+
+# We just build this directly to the install location.
+INSTALLED_FOSIMAGE_TARGET := $(BUILT_FOSIMAGE_TARGET)
+$(INSTALLED_FOSIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_FOSIMAGE_FILES)
+	$(build-fosimage-target)
+
+.PHONY: fosimage-nodeps
+fosimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
+	$(build-fosimage-target)
+	
+else # BUILDING_FOS_IMAGE
+# we need to ignore the broken fos link when doing the rsync
+IGNORE_FOS_LINK := --exclude=fos
+endif
+#tuliyuan add parition --end
+
 # -----------------------------------------------------------------
 # system_other partition image
 ifdef BUILDING_SYSTEM_OTHER_IMAGE
@@ -4586,6 +4637,7 @@ endif
 
 # Depending on the various images guarantees that the underlying
 # directories are up-to-date.
+#tuliyuan add  $(INSTALLED_FOSIMAGE_TARGET) for parition
 $(BUILT_TARGET_FILES_PACKAGE): \
 	    $(INSTALLED_RAMDISK_TARGET) \
 	    $(INSTALLED_BOOTIMAGE_TARGET) \
@@ -4594,6 +4646,7 @@ $(BUILT_TARGET_FILES_PACKAGE): \
 	    $(INSTALLED_RECOVERYIMAGE_TARGET) \
 	    $(INSTALLED_USERDATAIMAGE_TARGET) \
 	    $(INSTALLED_CACHEIMAGE_TARGET) \
+	    $(INSTALLED_FOSIMAGE_TARGET) \
 	    $(INSTALLED_VENDORIMAGE_TARGET) \
 	    $(INSTALLED_PRODUCTIMAGE_TARGET) \
 	    $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
diff --git a/build/make/core/board_config.mk b/build/make/core/board_config.mk
index 86162b6f37..871dba63c2 100755
--- a/build/make/core/board_config.mk
+++ b/build/make/core/board_config.mk
@@ -54,6 +54,7 @@ _board_strip_readonly_list := \
   WITH_DEXPREOPT \
 
 # File system variables
+#add tuliyuan fos parition add BOARD_FOSIMAGE_PARTITION_SIZE BOARD_FOSIMAGE_FILE_SYSTEM_TYPE
 _board_strip_readonly_list += \
   BOARD_FLASH_BLOCK_SIZE \
   BOARD_BOOTIMAGE_PARTITION_SIZE \
@@ -64,6 +65,8 @@ _board_strip_readonly_list += \
   BOARD_USERDATAIMAGE_PARTITION_SIZE \
   BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
   BOARD_CACHEIMAGE_PARTITION_SIZE \
+  BOARD_FOSIMAGE_FILE_SYSTEM_TYPE \
+  BOARD_FOSIMAGE_PARTITION_SIZE \
   BOARD_VENDORIMAGE_PARTITION_SIZE \
   BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE \
   BOARD_PRODUCTIMAGE_PARTITION_SIZE \
@@ -330,6 +333,22 @@ else ifeq ($(PRODUCT_BUILD_CACHE_IMAGE),true)
 endif
 .KATI_READONLY := BUILDING_CACHE_IMAGE
 
+#add tuliyuan add fos parition --start
+# Are we building a fos image
+BUILDING_FOS_IMAGE :=
+ifeq ($(PRODUCT_BUILD_FOS_IMAGE),)
+  ifdef BOARD_FOSIMAGE_FILE_SYSTEM_TYPE
+    BUILDING_FOS_IMAGE := true
+  endif
+else ifeq ($(PRODUCT_BUILD_FOS_IMAGE),true)
+  BUILDING_FOS_IMAGE := true
+  ifndef BOARD_FOSIMAGE_FILE_SYSTEM_TYPE
+    $(error PRODUCT_BUILD_FOS_IMAGE set to true, but BOARD_FOSIMAGE_FILE_SYSTEM_TYPE not defined)
+  endif
+endif
+.KATI_READONLY := BUILDING_FOS_IMAGE
+#add tuliyuan add fos parition --end
+
 # Are we building a boot image
 BUILDING_BOOT_IMAGE :=
 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
diff --git a/build/make/core/config.mk b/build/make/core/config.mk
index 90eea5ba99..2e973a7fea 100755
--- a/build/make/core/config.mk
+++ b/build/make/core/config.mk
@@ -1209,10 +1209,12 @@ endif
 
 # These goals don't need to collect and include Android.mks/CleanSpec.mks
 # in the source tree.
+#add tuliyuan add parition fosimage-nodeps
 dont_bother_goals := out \
     snod systemimage-nodeps \
     userdataimage-nodeps \
     cacheimage-nodeps \
+    fosimage-nodeps \
     bptimage-nodeps \
     vnod vendorimage-nodeps \
     pnod productimage-nodeps \
diff --git a/build/make/core/envsetup.mk b/build/make/core/envsetup.mk
index f4650f99f3..2a82001f95 100755
--- a/build/make/core/envsetup.mk
+++ b/build/make/core/envsetup.mk
@@ -581,7 +581,10 @@ $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_METRIC_TESTS := $(TARGET_OUT_DATA
 
 TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
 .KATI_READONLY := TARGET_OUT_CACHE
-
+#add tuliyuan add parition --start
+TARGET_OUT_FOS := $(PRODUCT_OUT)/fos
+.KATI_READONLY := TARGET_OUT_FOS
+#add tuliyuan add parition --end
 TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
 .KATI_READONLY := TARGET_OUT_VENDOR
 ifneq ($(filter address,$(SANITIZE_TARGET)),)
diff --git a/build/make/core/main.mk b/build/make/core/main.mk
index 85b5841a9b..73ec8b4fe1 100755
--- a/build/make/core/main.mk
+++ b/build/make/core/main.mk
@@ -1406,6 +1406,11 @@ endif
 .PHONY: cacheimage
 cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
 
+#add tuliyuan add parition --start
+.PHONY: fosimage
+fosimage: $(INSTALLED_FOSIMAGE_TARGET)
+#add tuliyuan add parition --end
+
 .PHONY: bptimage
 bptimage: $(INSTALLED_BPTIMAGE_TARGET)
 
@@ -1449,6 +1454,7 @@ vbmetaimage: $(INSTALLED_VBMETAIMAGE_TARGET)
 auxiliary: $(INSTALLED_AUX_TARGETS)
 
 # Build files and then package it into the rom formats
+#add tuliyuan add $(INSTALLED_FOSIMAGE_TARGET) \
 .PHONY: droidcore
 droidcore: $(filter $(HOST_OUT_ROOT)/%,$(modules_to_install)) \
     $(INSTALLED_SYSTEMIMAGE_TARGET) \
@@ -1461,6 +1467,7 @@ droidcore: $(filter $(HOST_OUT_ROOT)/%,$(modules_to_install)) \
     $(INSTALLED_VBMETAIMAGE_TARGET) \
     $(INSTALLED_USERDATAIMAGE_TARGET) \
     $(INSTALLED_CACHEIMAGE_TARGET) \
+    $(INSTALLED_FOSIMAGE_TARGET) \
     $(INSTALLED_BPTIMAGE_TARGET) \
     $(INSTALLED_VENDORIMAGE_TARGET) \
     $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
diff --git a/build/make/core/product.mk b/build/make/core/product.mk
index f8ba5936f8..3174da7912 100755
--- a/build/make/core/product.mk
+++ b/build/make/core/product.mk
@@ -375,6 +375,8 @@ _product_single_value_vars += PRODUCT_BUILD_PRODUCT_IMAGE
 _product_single_value_vars += PRODUCT_BUILD_SYSTEM_EXT_IMAGE
 _product_single_value_vars += PRODUCT_BUILD_ODM_IMAGE
 _product_single_value_vars += PRODUCT_BUILD_CACHE_IMAGE
+#add tuliyuan fos parition
+_product_single_value_vars += PRODUCT_BUILD_FOS_IMAGE
 _product_single_value_vars += PRODUCT_BUILD_RAMDISK_IMAGE
 _product_single_value_vars += PRODUCT_BUILD_USERDATA_IMAGE
 _product_single_value_vars += PRODUCT_BUILD_RECOVERY_IMAGE
diff --git a/build/make/tools/releasetools/build_image.py b/build/make/tools/releasetools/build_image.py
index 8cf074147e..c62bc558fa 100755
--- a/build/make/tools/releasetools/build_image.py
+++ b/build/make/tools/releasetools/build_image.py
@@ -614,6 +614,12 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
     copy_prop("cache_fs_type", "fs_type")
     copy_prop("cache_size", "partition_size")
     copy_prop("cache_selinux_fc", "selinux_fc")
+    #add tuliyuan add fos parition --start
+  elif mount_point == "fos":
+    copy_prop("fos_fs_type", "fs_type")
+    copy_prop("fos_size", "partition_size")
+    copy_prop("fos_selinux_fc", "selinux_fc")
+     #add tuliyuan add fos parition --end
   elif mount_point == "vendor":
     copy_prop("avb_vendor_hashtree_enable", "avb_hashtree_enable")
     copy_prop("avb_vendor_add_hashtree_footer_args",
@@ -787,6 +793,10 @@ def main(argv):
       mount_point = "data"
     elif image_filename == "cache.img":
       mount_point = "cache"
+    #add tuliyuan add fos parition --start
+    elif image_filename == "fos.img":
+      mount_point = "fos"
+     #add tuliyuan add fos parition --end
     elif image_filename == "vendor.img":
       mount_point = "vendor"
     elif image_filename == "odm.img":
diff --git a/device/rockchip/common/BoardConfig.mk b/device/rockchip/common/BoardConfig.mk
index e03c54f6a0..b41a56396c 100755
--- a/device/rockchip/common/BoardConfig.mk
+++ b/device/rockchip/common/BoardConfig.mk
@@ -139,6 +139,7 @@ DEVICE_MANIFEST_FILE ?= device/rockchip/common/manifest.xml
 DEVICE_MATRIX_FILE   ?= device/rockchip/common/compatibility_matrix.xml
 
 #Calculate partition size from parameter.txt
+#add by tuliyuan for fos partition BOARD_FOSIMAGE_PARTITION_SIZE
 USE_DEFAULT_PARAMETER := $(shell test -f $(TARGET_DEVICE_DIR)/parameter.txt && echo true)
 ifeq ($(strip $(USE_DEFAULT_PARAMETER)), true)
   ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS), true)
@@ -153,6 +154,7 @@ ifeq ($(strip $(USE_DEFAULT_PARAMETER)), true)
   BOARD_BOOTIMAGE_PARTITION_SIZE := $(shell python device/rockchip/common/get_partition_size.py $(TARGET_DEVICE_DIR)/parameter.txt boot)
   BOARD_DTBOIMG_PARTITION_SIZE := $(shell python device/rockchip/common/get_partition_size.py $(TARGET_DEVICE_DIR)/parameter.txt dtbo)
   BOARD_RECOVERYIMAGE_PARTITION_SIZE := $(shell python device/rockchip/common/get_partition_size.py $(TARGET_DEVICE_DIR)/parameter.txt recovery)
+  BOARD_FOSIMAGE_PARTITION_SIZE := $(shell python device/rockchip/common/get_partition_size.py $(TARGET_DEVICE_DIR)/parameter.txt fos)
   # Header V3, add vendor_boot
   ifeq (1,$(strip $(shell expr $(BOARD_BOOT_HEADER_VERSION) \>= 3)))
     BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE := $(shell python device/rockchip/common/get_partition_size.py $(TARGET_DEVICE_DIR)/parameter.txt vendor_boot)
@@ -289,7 +291,10 @@ RECOVERY_UPDATEIMG_RSA_CHECK ?= false
 
 # use ext4 cache for OTA
 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE ?= ext4
-
+# add tuliyuan add fos parition --start
+BOARD_FOSIMAGE_FILE_SYSTEM_TYPE ?= ext4
+BOARD_FOSIMAGE_PARTITION_SIZE := 52428800
+# add tuliyuan add fos parition --end
 TARGET_USES_MKE2FS ?= true
 
 RECOVERY_BOARD_ID ?= false
diff --git a/device/rockchip/common/build/rockchip/RebuildParameter.mk b/device/rockchip/common/build/rockchip/RebuildParameter.mk
index e1ccb55748..3688c02a82 100755
--- a/device/rockchip/common/build/rockchip/RebuildParameter.mk
+++ b/device/rockchip/common/build/rockchip/RebuildParameter.mk
@@ -35,7 +35,9 @@ endif
 ifeq ($(strip $(BOARD_SUPER_PARTITION_GROUPS)),rockchip_dynamic_partitions)
 partition_list := $(partition_list),super:$(BOARD_SUPER_PARTITION_SIZE)
 endif # BOARD_USE_DYNAMIC_PARTITIONS
-
+#add tuliyuan add fos parition --start
+partition_list := $(partition_list),fos:$(BOARD_FOSIMAGE_PARTITION_SIZE)
+#add tuliyuan --end
 intermediates := $(call intermediates-dir-for,FAKE,rockchip_parameter)
 rebuild_parameter := $(intermediates)/parameter.txt
 
diff --git a/device/rockchip/common/init.rk30board.rc b/device/rockchip/common/init.rk30board.rc
index db25dcb36e..40d9f67fab 100755
--- a/device/rockchip/common/init.rk30board.rc
+++ b/device/rockchip/common/init.rk30board.rc
@@ -17,6 +17,12 @@ on post-fs-data
     mkdir /data/vendor/logs 0755 root shell
     mkdir /data/vendor/audio 0755 system system
 
+on post-fs
+    #remount fos selinux perms
+    chown system system /fos
+    chmod 0771 /fos
+    restorecon_recursive /fos
+
 on early-init
     write /sys/devices/system/cpu/cpufreq/policy0/scaling_governor performance
     write /sys/class/devfreq/dmc/governor performance
diff --git a/device/rockchip/common/scripts/fstab_tools/fstab.in b/device/rockchip/common/scripts/fstab_tools/fstab.in
index 10c3d2ee85..d1e0c2eddb 100755
--- a/device/rockchip/common/scripts/fstab_tools/fstab.in
+++ b/device/rockchip/common/scripts/fstab_tools/fstab.in
@@ -10,6 +10,8 @@ ${_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
+#add tuliyuan add for fos parition
+/dev/block/by-name/fos          /fos              ext4      noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard                wait,check
 
 /devices/platform/*usb*   auto vfat defaults      voldmanaged=usb:auto
 
diff --git a/device/rockchip/common/sepolicy/vendor/device.te b/device/rockchip/common/sepolicy/vendor/device.te
index a3b4c8a34c..630f3ca2b2 100755
--- a/device/rockchip/common/sepolicy/vendor/device.te
+++ b/device/rockchip/common/sepolicy/vendor/device.te
@@ -33,3 +33,5 @@ type cec_device, dev_type;
 
 #for hid audio
 type hidraw_device, dev_type;
+#add tuliyuan add fos parition block device
+type fos_block_device, dev_type;
diff --git a/device/rockchip/common/sepolicy/vendor/file.te b/device/rockchip/common/sepolicy/vendor/file.te
index 464180c68b..ed68bb6d84 100755
--- a/device/rockchip/common/sepolicy/vendor/file.te
+++ b/device/rockchip/common/sepolicy/vendor/file.te
@@ -53,3 +53,5 @@ type sysfs_mmc, fs_type, sysfs_type;
 # input files
 type idc_file, file_type, vendor_file_type;
 type keylayout_file, file_type, vendor_file_type;
+# tuliyuan add fos partition
+type fos_data_file_type, file_type, mlstrustedobject;;
diff --git a/device/rockchip/common/sepolicy/vendor/file_contexts b/device/rockchip/common/sepolicy/vendor/file_contexts
index e0a46b296e..939d13fbfe 100755
--- a/device/rockchip/common/sepolicy/vendor/file_contexts
+++ b/device/rockchip/common/sepolicy/vendor/file_contexts
@@ -80,6 +80,8 @@
 /dev/block/by-name/baseparameter                u:object_r:baseparameter_block_device:s0
 /dev/block/by-name/super                        u:object_r:super_block_device:s0
 
+#add by tuliyuan for add fos partition
+/dev/block/by-name/fos  			u:object_r:fos_block_device:s0
 # for A/B
 /dev/block/by-name/boot_[ab]                    u:object_r:boot_block_device:s0
 /dev/block/by-name/uboot_[ab]                   u:object_r:uboot_block_device:s0
@@ -220,4 +222,5 @@
 
 #flash_img
 /vendor/bin/flash_img.sh u:object_r:vendor_install_recovery_exec:s0
-
+#add by tuliyuan for partition
+/fos(/.*)?   u:object_r:fos_data_file_type:s0
diff --git a/device/rockchip/common/sepolicy/vendor/fsck.te b/device/rockchip/common/sepolicy/vendor/fsck.te
index 77ed0b109c..68223596ee 100755
--- a/device/rockchip/common/sepolicy/vendor/fsck.te
+++ b/device/rockchip/common/sepolicy/vendor/fsck.te
@@ -2,3 +2,6 @@ allow fsck e2fsck_oem_block_device:blk_file rw_file_perms;
 allow fsck e2fsck_cache_block_device:blk_file rw_file_perms;
 allow fsck e2fsck_frp_block_device:blk_file rw_file_perms;
 allow fsck sysfs_dm:dir { search };
+#add tuliyuan add fos partition --start
+allow fsck fos_block_device:blk_file rw_file_perms;
+#add tuliyuan add fos partition --end
diff --git a/device/rockchip/common/sepolicy/vendor/init.te b/device/rockchip/common/sepolicy/vendor/init.te
index e614ec7fa3..5e5f7f58a3 100755
--- a/device/rockchip/common/sepolicy/vendor/init.te
+++ b/device/rockchip/common/sepolicy/vendor/init.te
@@ -61,3 +61,8 @@ set_prop(init, vendor_system_public_prop)
 r_dir_file(init, nativetest_data_file)
 rw_rockchip_graphic_device(init)
 set_prop(init, debug_prop)
+#add tuliyuan add fos partition --start
+allow init fos_block_device:lnk_file { relabelto };
+allow init fos_block_device:blk_file { write };
+allow init fos_data_file_type:dir { create setattr getattr mounton };
+#add tuliyuan add fos partition --end
diff --git a/device/rockchip/common/sepolicy/vendor/shell.te b/device/rockchip/common/sepolicy/vendor/shell.te
index 8abffee5dd..f9ecf36ad8 100755
--- a/device/rockchip/common/sepolicy/vendor/shell.te
+++ b/device/rockchip/common/sepolicy/vendor/shell.te
@@ -46,3 +46,7 @@ allow shell gpu_data_file:file rw_file_perms;
 allow shell metadata_file:file r_file_perms;
 
 rw_rockchip_graphic_device(shell)
+#add by tuliyuan for add fos parition --start
+allow vendor_init fos_data_file_type:dir rw_dir_perms;
+allow vendor_init fos_data_file_type:file rw_file_perms;
+#add by tuliyuan for add fos parition --end
diff --git a/device/rockchip/common/sepolicy/vendor/vendor_init.te b/device/rockchip/common/sepolicy/vendor/vendor_init.te
index d1f9511520..c6aff7cce5 100755
--- a/device/rockchip/common/sepolicy/vendor/vendor_init.te
+++ b/device/rockchip/common/sepolicy/vendor/vendor_init.te
@@ -35,3 +35,9 @@ set_prop(vendor_init, vendor_boot_complete_prop)
 get_prop(vendor_init, public_vendor_default_prop)
 get_prop(vendor_init, vendor_system_public_prop)
 get_prop(vendor_init, vendor_drm_prop)
+#tuliyuan add for fos partition --start
+allow vendor_init fos_block_device:lnk_file { relabelto };
+allow vendor_init fos_data_file_type:dir rw_dir_perms;
+allow vendor_init fos_data_file_type:file rw_file_perms;
+allow vendor_init fos_data_file_type:dir { mounton };
+#tuliyuan add for fos partition --end
diff --git a/device/rockchip/common/sepolicy/vendor/vold.te b/device/rockchip/common/sepolicy/vendor/vold.te
index 647b1ea54e..981964646e 100755
--- a/device/rockchip/common/sepolicy/vendor/vold.te
+++ b/device/rockchip/common/sepolicy/vendor/vold.te
@@ -11,3 +11,8 @@ allow vold vold_device:blk_file ioctl;
 allow vold vold_exec:file execute_no_trans;
 allow vold self:capability { dac_override dac_read_search };
 allow vold sysfs_mmc:file rw_file_perms;
+#tuliyuan add fos partition --start
+#avc: denied { ioctl } for path="/fos" dev="dm-0" ino=25 ioctlcmd=0x5879 scontext=u:r:vold:s0 tcontext=u:object_r:fos_data_file_type:s0 tclass=dir permissive=0
+allow vold fos_data_file_type:dir { read open write getattr setattr };
+allow vold fos_block_device:blk_file getattr;
+#tuliyuan add fos partition --end
diff --git a/device/rockchip/rk356x/rk3568_r/recovery.fstab b/device/rockchip/rk356x/rk3568_r/recovery.fstab
index 08567914fd..3e6b3e0f0f 100755
--- a/device/rockchip/rk356x/rk3568_r/recovery.fstab
+++ b/device/rockchip/rk356x/rk3568_r/recovery.fstab
@@ -27,3 +27,5 @@
 /dev/block/by-name/vbmeta                /vbmeta              emmc             defaults                  defaults
 /dev/block/by-name/dtbo                /dtbo              emmc             defaults                  defaults
 /dev/block/by-name/vendor_boot           /vendor_boot                emmc             defaults                  defaults
+#add bytuliyuan for add new parition
+/dev/block/by-name/fos                   /fos                 ext4             defaults	   defaults
diff --git a/mkimage.sh b/mkimage.sh
index 2aa485a797..fadf0b72d9 100755
--- a/mkimage.sh
+++ b/mkimage.sh
@@ -92,6 +92,187 @@ fi
 cp -a $BOARD_DTBO_IMG $IMAGE_PATH/dtbo.img
 echo "done."
 
+# add by tuliyuan for FOS.img
+echo -n "create fos.img.... "
+cp -av $OUT/fos.img $IMAGE_PATH/fos.img
+echo "done."
+
+echo "create resource.img..."
+if [ -f "kernel/resource.img" ]; then
+    cp -a kernel/resource.img $IMAGE_PATH/resource.img
+    echo "done."
+fi
+
+copy_images_from_out boot.img
+copy_images_from_out boot-debug.img
+copy_images_from_out vendor_boot.img
+copy_images_from_out vendor_boot-debug.img
+copy_images_from_out recovery.img
+copy_images_from_out super.img
+
+if [ ! "$PRODUCT_USE_DYNAMIC_PARTITIONS" = "true" ]; then
+copy_images_from_out system.img
+copy_images_from_out system_ext.img
+copy_images_from_out vendor.img
+copy_images_from_out odm.img
+copy_images_from_out product.img
+fi
+
+echo "create vbmeta.img..."
+if [ "$BOARD_AVB_ENABLE" = "true" ]; then
+cp -a $OUT/vbmeta.img $IMAGE_PATH/vbmeta.img
+else
+echo "BOARD_AVB_ENABLE is false, use default vbmeta.img"
+cp -a device/rockchip/common/vbmeta.img $IMAGE_PATH/vbmeta.img
+fi
+
+echo -n "create misc.img.... "
+cp -a rkst/Image/misc.img $IMAGE_PATH/misc.img
+cp -a rkst/Image/pcba_small_misc.img $IMAGE_PATH/pcba_small_misc.img
+cp -a rkst/Image/pcba_whole_misc.img $IMAGE_PATH/pcba_whole_misc.img
+echo "done."
+
+if [ -f $UBOOT_PATH/uboot.img ]
+then
+	echo "create uboot.img..."
+	cp -a $UBOOT_PATH/uboot.img $IMAGE_PATH/uboot.img
+else
+	echo "$UBOOT_PATH/uboot.img not fount! Please make it from $UBOOT_PATH first!"
+fi
+
+if [ -f $UBOOT_PATH/trust_nand.img ]
+then
+        echo "create trust.img..."
+        cp -a $UBOOT_PATH/trust_nand.img $IMAGE_PATH/trust.img
+elif [ -f $UBOOT_PATH/trust_with_ta.img ]
+then
+        echo "create trust.img..."
+        cp -a $UBOOT_PATH/trust_with_ta.img $IMAGE_PATH/trust.img
+elif [ -f $UBOOT_PATH/trust.img ]
+then
+        echo "create trust.img..."
+        cp -a $UBOOT_PATH/trust.img $IMAGE_PATH/trust.img
+else    
+        echo "$UBOOT_PATH/trust.img not fount! Please make it from $UBOOT_PATH first!"
+fi
+
+if [ "$HIGH_RELIABLE_RECOVERY_OTA" = "true" ]; then
+	if [ -f $UBOOT_PATH/uboot_ro.img ]
+	then
+		echo -n "HIGH_RELIABLE_RECOVERY_OTA is true. create uboot_ro.img..."
+		cp -a $UBOOT_PATH/uboot_ro.img $IMAGE_PATH/uboot_ro.img
+		cp -a $IMAGE_PATH/trust.img $IMAGE_PATH/trust_ro.img
+		echo "done."
+	else
+		echo "$UBOOT_PATH/uboot_ro.img not fount! Please make it from $UBOOT_PATH first!"
+	fi
+fi
+
+if [ -f $UBOOT_PATH/*_loader_*.bin ]
+then
+        echo "create loader..."
+        cp -a $UBOOT_PATH/*_loader_*.bin $IMAGE_PATH/MiniLoaderAll.bin
+else
+	if [ -f $UBOOT_PATH/*loader*.bin ]; then
+		echo "create loader..."
+		cp -a $UBOOT_PATH/*loader*.bin $IMAGE_PATH/MiniLoaderAll.bin
+	elif [ "$TARGET_PRODUCT" == "px3" -a -f $UBOOT_PATH/RKPX3Loader_miniall.bin ]; then
+        echo "create loader..."
+        cp -a $UBOOT_PATH/RKPX3Loader_miniall.bin $IMAGE_PATH/MiniLoaderAll.bin
+	else
+        echo "$UBOOT_PATH/*MiniLoaderAll_*.bin not fount! Please make it from $UBOOT_PATH first!"
+	fi
+fi
+
+if [ -f $FLASH_CONFIG_FILE ]
+then
+    echo "create config.cfg..."
+    cp -a $FLASH_CONFIG_FILE $IMAGE_PATH/config.cfg
+else
+    echo "$FLASH_CONFIG_FILE not fount!"
+fi
+
+if [ -f $PARAMETER ]
+then
+				if [ "$HIGH_RELIABLE_RECOVERY_OTA" = "true" ]; then
+	        echo -n "create parameter...HIGH_RELIABLE_RECOVERY_OTA is ture. "
+	        echo -n "create parameter from hrr..."
+	        if [ -f $PARAMETER ]; then
+						cp -a ${TARGET_DEVICE_DIR}/parameter_hrr.txt $IMAGE_PATH/parameter.txt
+						echo "done."
+	        else
+						echo "${TARGET_DEVICE_DIR}/parameter_hrr.txt not fount! Please make it from ${TARGET_DEVICE_DIR} first!"
+	        fi
+	      else
+					echo -n "create parameter..."
+	        cp -a $PARAMETER $IMAGE_PATH/parameter.txt
+	        echo "done."
+	      fi
+else
+    if [ -f $OUT/parameter.txt ]; then
+        cp -a $OUT/parameter.txt $IMAGE_PATH/parameter.txt
+    else
+        echo "$PARAMETER not fount!"
+    fi
+fi
+
+SHARED_LIBRARIES_DIR=out/host/linux-x86/lib64
+JAVA_LIBRARIES_DIR=out/host/linux-x86/framework
+OTA_KEY_DIR=build/target/product/security
+
+if [ $TARGET == $BOOT_OTA ]; then
+    echo "create update_loader.zip.."
+    python build/tools/releasetools/package_loader_zip.py  $IMAGE_PATH/MiniLoaderAll.bin  $IMAGE_PATH/update_loader_unsigned.zip
+    java -Djava.library.path=$SHARED_LIBRARIES_DIR -jar $JAVA_LIBRARIES_DIR/signapk.jar -w $OTA_KEY_DIR/testkey.x509.pem $OTA_KEY_DIR/testkey.pk8 $IMAGE_PATH/update_loader_unsigned.zip $IMAGE_PATH/update_loader.zip
+    rm $IMAGE_PATH/update_loader_unsigned.zip
+    echo "done."
+fi
+
+if [ "$TARGET_BASE_PARAMETER_IMAGE"x != ""x ]
+then
+    if [ -f $TARGET_BASE_PARAMETER_IMAGE ]
+    then
+        echo -n "create baseparameter..."
+        cp -a $TARGET_BASE_PARAMETER_IMAGE $IMAGE_PATH/baseparameter.img
+        echo "done."
+    else
+        echo "$TARGET_BASE_PARAMETER_IMAGE not fount!"
+    fi
+fi
+
+if [ $TARGET == $BOOT_OTA ]
+then
+if [ "$PRODUCT_USE_DYNAMIC_PARTITIONS" = "true" ]; then
+    cp -rf  $OUT/obj/PACKAGING/super.img_intermediates/super.img  $IMAGE_PATH/
+fi
+echo -n "create system.img boot.img oem.img vendor.img dtbo.img vbmeta.img for OTA..."
+cp -rf  $OUT/obj/PACKAGING/target_files_intermediates/*-target_files*/IMAGES/*.img  $IMAGE_PATH/
+rm -rf  $IMAGE_PATH/cache.img
+rm -rf  $IMAGE_PATH/recovery-two-step.img
+if [ "$PRODUCT_USE_DYNAMIC_PARTITIONS" = "true" ]; then
+    rm -rf  $IMAGE_PATH/super_empty.img
+fi
+if [ "$BOARD_AVB_ENABLE" = "true" ]; then
+    echo "AVB Enable"
+    cp -rf  $OUT/obj/PACKAGING/target_files_intermediates/*-target_files*/VENDOR/etc/recovery.img  $IMAGE_PATH/
+fi
+echo "done."
+fi
+
+IS_EBOOK=`get_build_var BUILD_WITH_RK_EBOOK`
+ebook_logo_tool=rkbin/tools/bmp2gray16
+if [ $IS_EBOOK == "true" ]; then
+    if [ -f ${TARGET_DEVICE_DIR}/waveform.img ]; then
+        cp ${TARGET_DEVICE_DIR}/waveform.img $IMAGE_PATH/
+    fi
+    if [ -f $ebook_logo_tool ]; then
+        EINK_LOGO_PATH=${TARGET_DEVICE_DIR}/eink_logo/
+        echo -n "create logo.img for uboot/charging/kernel logo"
+        $ebook_logo_tool --uboot-logo $EINK_LOGO_PATH/uboot_logo/uboot.bmp --kernel-logo $EINK_LOGO_PATH/kernel_logo/kernel.bmp --charge-logo $EINK_LOGO_PATH/uboot_logo/battery_0.bmp $EINK_LOGO_PATH/uboot_logo/battery_1.bmp $EINK_LOGO_PATH/uboot_logo/battery_2.bmp $EINK_LOGO_PATH/uboot_logo/battery_3.bmp $EINK_LOGO_PATH/uboot_logo/battery_4.bmp $EINK_LOGO_PATH/uboot_logo/battery_5.bmp $EINK_LOGO_PATH/uboot_logo/battery_fail.bmp --poweroff-logo $EINK_LOGO_PATH/uboot_logo/poweroff.bmp --output $IMAGE_PATH/logo.img
+    fi
+fi
+
+chmod a+r -R $IMAGE_PATH/
 echo "create resource.img..."
 if [ -f "kernel/resource.img" ]; then
     cp -a kernel/resource.img $IMAGE_PATH/resource.img
diff --git a/system/core/rootdir/Android.mk b/system/core/rootdir/Android.mk
index a9d0ed08a9..91d51bc853 100755
--- a/system/core/rootdir/Android.mk
+++ b/system/core/rootdir/Android.mk
@@ -125,6 +125,9 @@ ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
 else
   LOCAL_POST_INSTALL_CMD += ; ln -sf /data/cache $(TARGET_ROOT_OUT)/cache
 endif
+#add tuliyuan create fos parition --start
+LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/fos
+#add tuliyuan create fos parition --end
 ifdef BOARD_ROOT_EXTRA_SYMLINKS
 # BOARD_ROOT_EXTRA_SYMLINKS is a list of <target>:<link_name>.
   LOCAL_POST_INSTALL_CMD += $(foreach s, $(BOARD_ROOT_EXTRA_SYMLINKS),\

补充一下

--- a/RKTools/linux/Linux_Pack_Firmware/rockdev/package-file-rk356x
+++ b/RKTools/linux/Linux_Pack_Firmware/rockdev/package-file-rk356x
@@ -13,6 +13,7 @@ vbmeta      Image/vbmeta.img
 recovery    Image/recovery.img
 baseparameter    Image/baseparameter.img
 super      Image/super.img
+fos      Image/fos.img

diff --git a/device/rockchip/common/sepolicy/vendor/init.te b/device/rockchip/common/sepolicy/vendor/init.te
index 5e5f7f58a3..c5826d5fc0 100755
--- a/device/rockchip/common/sepolicy/vendor/init.te
+++ b/device/rockchip/common/sepolicy/vendor/init.te
@@ -63,6 +63,6 @@ rw_rockchip_graphic_device(init)
 set_prop(init, debug_prop)
 #add tuliyuan add fos partition --start
 allow init fos_block_device:lnk_file { relabelto };
-allow init fos_block_device:blk_file { write };
+allow init fos_block_device:blk_file { rw_file_perms };
 allow init fos_data_file_type:dir { create setattr getattr mounton };
 #add tuliyuan add fos partition --end
diff --git a/device/rockchip/common/sepolicy/vendor/vold.te b/device/rockchip/common/sepolicy/vendor/vold.te
index 981964646e..b4c4daba76 100755
--- a/device/rockchip/common/sepolicy/vendor/vold.te
+++ b/device/rockchip/common/sepolicy/vendor/vold.te
@@ -13,6 +13,6 @@ allow vold self:capability { dac_override dac_read_search };
 allow vold sysfs_mmc:file rw_file_perms;
 #tuliyuan add fos partition --start
 #avc: denied { ioctl } for path="/fos" dev="dm-0" ino=25 ioctlcmd=0x5879 scontext=u:r:vold:s0 tcontext=u:object_r:fos_data_file_type:s0 tclass=dir permissive=0
-allow vold fos_data_file_type:dir { read open write getattr setattr };
+allow vold fos_data_file_type:dir { read open write getattr setattr ioctl };
 allow vold fos_block_device:blk_file getattr;
 #tuliyuan add fos partition --end



获取分区大小和makefile中定义的关系



step 1 获取分区对应的块设备名称

ls -l /dev/block/platform/fe2e0000.mmc/by-name/boot 获取该分区对应的块设备名称

/dev/block/platform/fe2e0000.mmc/by-name/boot -> /dev/block/mmcblk1p7



step 2 获取块设备的大小

cat /proc/partitions | grep mmcblk1p7

 179        7      71680 mmcblk1p7

其中71680就是对应的分区大小,我们71680*1024得到的结果就是BOARD_BOOTIMAGE_PARTITION_SIZE定义的大小



版权声明:本文为qq_18906227原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。