海思3751系列新建自定义分区
分区新建分为两个步骤完成
第一步创建分区盘符,第二步给新建分区设置访问权限。
新建分区盘符
涉及文件如下:
- device/hisilicon/Hi3751V350/etc/Hi3751V350-slaveboot-emmc.xml ,新建对应分区表信息;
<Part Sel="0" PartitionName="selfdata" FlashType="emmc" FileSystem="ext3/4" Start="2148M" Length="100M" SelectFile="selfdata.ext4"/>
- device/hisilicon/bigfish/build/bigfish.mk ,新建分区对应的文件目录;
INSTALLED_SELFIMAGE_TARGET := $(PRODUCT_OUT)/selfdata.img
TARGET_OUT_SELF:=$(PRODUCT_OUT)/selfdata
- device/hisilicon/bigfish/build/ext4.mk ,新建分区大小配置与生成;
$(EXT4_IMG):$(INSTALLED_SYSTEMIMAGE) $(INSTALLED_USERDATAIMAGE_TARGET) $(INSTALLED_CACHEIMAGE_TARGET) $(INSTALLED_VENDORIMAGE_TARGET) atv securestore logimage selfdataimage
cp -r $(PRODUCT_OUT)/system.img $(EMMC_PRODUCT_OUT)/system.ext4
cp -r $(PRODUCT_OUT)/userdata.img $(EMMC_PRODUCT_OUT)/userdata.ext4
cp -r $(PRODUCT_OUT)/cache.img $(EMMC_PRODUCT_OUT)/cache.ext4
include $(CLEAR_VARS)
$(shell mkdir -p $(TARGET_ROOT_OUT)/selfdata )
selfdata_intermediates := $(call intermediates-dir-for,PACKAGING, selfdata)
SELF_IMAGE := $(selfdata_intermediates)/selfdata.img
$(SELF_IMAGE): $(INSTALLED_VENDORIMAGE_TARGET)
mkdir -p $(TARGET_OUT_SELF)
$(hide) rm -rf $(selfdata_intermediates) && mkdir -p $(selfdata_intermediates)
$(call generate-userimage-prop-dictionary, $(selfdata_intermediates)/selfdata_image_info.txt, \
mount_point=selfdata \
partition_size=104857600 \
skip_fsck=true \
extfs_rsv_pct=0)
build/make/tools/releasetools/build_image.py $(TARGET_OUT_SELF) \
$(selfdata_intermediates)/selfdata_image_info.txt $(INSTALLED_SELFIMAGE_TARGET) $(PRODUCT_OUT)
.PHONY: selfdataimage
selfdataimage: $(SELF_IMAGE)
cp -r $(PRODUCT_OUT)/selfdata.img $(EMMC_PRODUCT_OUT)/selfdata.ext4
- device/hisilicon/bigfish/etc/fstab.bigfish ,分区格式定义;
/dev/block/platform/soc/f9830000.emmc/by-name/selfdata /selfdata ext4 nosuid,nodev,noatime,barrier=1,data=ordered wait
修改分区访问权限
涉及文件如下:
- device/hisilicon/bigfish/etc/initrc/vendor/etc/init/hw/init.bigfish.rc ,修改文件夹访问权限;
on fs
# selfdata partition
chown system system /selfdata
chmod 777 /selfdata
restorecon_recursive /selfdata
2.te文件属性配置,新增新建分区可访问te配置;
device/hisilicon/bigfish/external/sepolicy/patch/recovery_adapt/file_contexts
# for recovery
/dev/block/mmcblk0p26 u:object_r:userdata_block_device:s0
device/hisilicon/bigfish/external/sepolicy/patch/recovery_default/file_contexts
# for recovery
/dev/block/mmcblk0p26 u:object_r:userdata_block_device:s0
device/hisilicon/bigfish/external/sepolicy/vendor/file.te
type selfdata_file,file_type;
device/hisilicon/bigfish/external/sepolicy/vendor/file_contexts
# p18(tconparam) p19(demura) p20(system) p21(vendor) p22(atv) p23(log) p25(selfdata)
/dev/block/mmcblk0p25 u:object_r:hifsck_block_device:s0
#selfdata files
/selfdata(/.*)? u:object_r:selfdata_file:s0
device/hisilicon/bigfish/external/sepolicy/vendor/init.te
allow init selfdata_file:dir { mounton };
device/hisilicon/bigfish/external/sepolicy/vendor/kernel.te
allow kernel selfdata_file:dir { write open read getattr remove_name add_name search };
allow kernel selfdata_file:file { read write open getattr rename unlink create };
device/hisilicon/bigfish/external/sepolicy/vendor/shell.te
allow shell selfdata_file:dir { getattr setattr search create read open write add_name remove_name };
allow shell selfdata_file:file { create getattr setattr open read append rename };
device/hisilicon/bigfish/external/sepolicy/vendor/system_app.te
allow system_app selfdata_file:dir{ search getattr read open };
allow system_app selfdata_file:file{ read write open create getattr setattr };