[Feature][ZXW-241]merge P56U01 version
Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: I7985538dde6951dd824c36149bf9a1e3ca23c734
diff --git a/allbins/tools/mkfs_sh/gen_ubi_para.sh b/allbins/tools/mkfs_sh/gen_ubi_para.sh
new file mode 100755
index 0000000..26f11f4
--- /dev/null
+++ b/allbins/tools/mkfs_sh/gen_ubi_para.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+
+#########可修改---开始#########
+#分区大小,单位MB,可以是带小数
+if [ $# -eq 0 ]; then
+ INPUT_MTD_SIZE=32
+else
+ INPUT_MTD_SIZE=$1
+fi
+
+#擦除块大小
+MTD_ERASE_SIZE=0x40000
+
+#flash页大小
+MTD_PAGE_SIZE=4096
+
+#子页subpage大小
+MTD_SUBPAGE_SIZE=4096
+
+#BEB保留数,每1024预留多少个给坏快
+BEB_RESERVE_LIMIT=20
+#########可修改---结束#########
+
+function gen_mtd_para()
+{
+ MTD_NAME=$1
+ MTD_SIZE_MB=$2
+ MTD_SIZE_KB=$(awk "BEGIN { print $MTD_SIZE_MB * 1024 }")
+ BLOCK_SIZE_KB=$[$MTD_ERASE_SIZE / 1024]
+ BLOCK_CNT_1MB=$[0x100000 / $MTD_ERASE_SIZE]
+ MTD_BLOCK_CNT=$(awk "BEGIN { print $MTD_SIZE_MB * $BLOCK_CNT_1MB }")
+ BEB_RESERVE_CNT=$(awk "BEGIN { print int($BEB_RESERVE_LIMIT * $MTD_BLOCK_CNT / 1024) }")
+ if [ $BEB_RESERVE_CNT -lt 2 ]; then
+ BEB_RESERVE_CNT=2
+ fi
+ MAX_LEB_CNT=$[$MTD_BLOCK_CNT - $BEB_RESERVE_CNT - 4]
+ if [ $MTD_SUBPAGE_SIZE -lt $MTD_PAGE_SIZE ]; then
+ LEB_SIZE=$[$MTD_ERASE_SIZE - $MTD_PAGE_SIZE]
+ else
+ LEB_SIZE=$[$MTD_ERASE_SIZE - $MTD_PAGE_SIZE - $MTD_PAGE_SIZE]
+ fi
+ LEB_SIZE_KB=$[$LEB_SIZE / 1024]
+ VOL_SIZE_KB=$[$LEB_SIZE_KB * $MAX_LEB_CNT]
+ VOL_SIZE_MB0=$(awk "BEGIN { print $VOL_SIZE_KB / 1024 }")
+ VOL_SIZE_MB=$(awk "BEGIN { print int($VOL_SIZE_KB / 1024) }")
+
+ echo "$MTD_NAME MKUBIFS_ARGS=\"-m $MTD_PAGE_SIZE -e $LEB_SIZE -c $MAX_LEB_CNT -x zlib -F\""
+ echo "$MTD_NAME UBINIZE_ARGS=\"-m $MTD_PAGE_SIZE -p $MTD_ERASE_SIZE -s $MTD_SUBPAGE_SIZE\""
+ #echo "$MTD_NAME vol_size=\"${VOL_SIZE_MB}MiB\""
+}
+
+echo "generate $INPUT_MTD_SIZE MB parameter"
+gen_mtd_para ubifs $INPUT_MTD_SIZE
+
diff --git a/allbins/tools/mkfs_sh/readme.txt b/allbins/tools/mkfs_sh/readme.txt
index ed531f9..8ce613a 100755
--- a/allbins/tools/mkfs_sh/readme.txt
+++ b/allbins/tools/mkfs_sh/readme.txt
@@ -23,11 +23,18 @@
oem重新打包类似。若开启selinux,需要提供selinux context文件。
-4、ubifs打包示例
-编辑ubifs_demo.sh,检查下面参数配置
+4、ubifs cfg打包示例
+编辑ubifs_from_cfg_demo.sh,检查下面参数配置
UBI_ARGS为nandflash UBI参数配置。参考oemdata-ubi-default.cfg配置自己的cfg文件。
-bash ubifs_demo.sh cap_oemdata.img oemdata-ubi-default.cfg
+bash ubifs_from_cfg_demo.sh cap_oemdata.img oemdata-ubi-default.cfg
cap_oemdata.img为输出文件,oemdata-ubi-default.cfg为配置文件。
特殊注明:避免将一个目录打包成ubifs镜像,否则需要mkfs.ubifs命令,并且要计算max leb count值,这样就会和很多参数耦合,也不利于ubifs异常恢复。
ubifs的预置文件可以放到squashfs文件系统里,第一次启动的时候拷贝到ubifs里。
+5、ubifs 目录打包示例
+编辑gen_ubi_para.sh,检查里面的下面参数MTD_ERASE_SIZE、MTD_PAGE_SIZE和MTD_SUBPAGE_SIZE是否和flash参数一致。
+运行bash gen_ubi_para.sh 分区大小(单位MB),将所得的参数配置到ubifs_from_dir_demo.sh,包括UBIFS_ARGS和UBI_ARGS
+UBIFS_ARGS和UBI_ARGS参数除了数字参数之外,其他参数可以手动调整或者增加。比如调整压缩算法。
+运行 ubifs_from_dir_demo.sh 输出文件名 打包目录 分区名
+例如:bash ubifs_from_dir_demo.sh cap_oemdata.bin oemdata oemdata
+
diff --git a/allbins/tools/mkfs_sh/rootfs_mksqushfs_demo.sh b/allbins/tools/mkfs_sh/rootfs_mksqushfs_demo.sh
index 6403a6b..8ea67d1 100755
--- a/allbins/tools/mkfs_sh/rootfs_mksqushfs_demo.sh
+++ b/allbins/tools/mkfs_sh/rootfs_mksqushfs_demo.sh
@@ -56,6 +56,7 @@
echo "dm-verity fail"
exit -1
fi
+ cp -v ${VOL_NAME}.dm ${OUT_NAME}.dm
mv ${VOL_NAME}.dm ${VOL_NAME}.out
else
echo "disable dm-verity"
diff --git a/allbins/tools/mkfs_sh/ubifs_demo.sh b/allbins/tools/mkfs_sh/ubifs_from_cfg_demo.sh
similarity index 100%
rename from allbins/tools/mkfs_sh/ubifs_demo.sh
rename to allbins/tools/mkfs_sh/ubifs_from_cfg_demo.sh
diff --git a/allbins/tools/mkfs_sh/ubifs_from_dir_demo.sh b/allbins/tools/mkfs_sh/ubifs_from_dir_demo.sh
new file mode 100755
index 0000000..53edcf4
--- /dev/null
+++ b/allbins/tools/mkfs_sh/ubifs_from_dir_demo.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+WORKDIR=$PWD
+export PATH=$WORKDIR/bin:$PATH
+
+UBIFS_ARGS="-m 4096 -e 253952 -c 702 -x zlib -F"
+UBI_ARGS="-m 0x1000 -p 0x40000 -s 0x1000 -Q 1024"
+
+if [ $# -lt 3 ]; then
+ echo "[error] $0 parameter to less"
+ echo "$0 outfile dir_name mtd_name"
+ exit -1
+fi
+outfile=$1
+dir_name=$2
+vol_name=vol_$3
+cfg_file_name=${outfile}.cfg
+
+echo "outfile:$outfile"
+echo "dir_name:$dir_name"
+echo "vol_name:$vol_name"
+echo "UBIFS_ARGS:$UBIFS_ARGS"
+echo "UBI_ARGS:$UBI_ARGS"
+
+rm -fr ${outfile} ${outfile}.ubifs ${outfile}.cfg
+
+mkfs.ubifs -r $dir_name $UBIFS_ARGS -o ${outfile}.ubifs
+if [ $? -ne 0 ]; then
+ echo "mkfs.ubifs error"
+ exit -1
+else
+ echo "mkfs.ubifs ok"
+fi
+
+filesize="$(stat -c%s ${outfile}.ubifs)"
+
+echo "[ubifs]" > $cfg_file_name
+echo "mode=ubi" >> $cfg_file_name
+echo "image=${outfile}.ubifs" >> $cfg_file_name
+echo "vol_id=0" >> $cfg_file_name
+echo "vol_size=${filesize}" >> $cfg_file_name
+echo "vol_type=dynamic" >> $cfg_file_name
+echo "vol_name=${vol_name}" >> $cfg_file_name
+echo "vol_flags=autoresize" >> $cfg_file_name
+
+#cat $cfg_file_name
+
+./ubinize-cfg.sh $outfile $cfg_file_name "$UBI_ARGS"