From 0aacac3dbb746dfe98179d0366bc8dc9638bd383 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Sat, 03 Aug 2019 00:15:59 +0800
Subject: [PATCH] update rootfs, update and add more command and add apps auto mount

---
 ok335xD/linux-bsp/build.sh |   53 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/ok335xD/linux-bsp/build.sh b/ok335xD/linux-bsp/build.sh
index fb9b394..d9f2a77 100755
--- a/ok335xD/linux-bsp/build.sh
+++ b/ok335xD/linux-bsp/build.sh
@@ -82,6 +82,7 @@
 
 
 	show_banner "|          start uboot build task...          |"
+    chmod a+x build.sh
     bash build.sh
 	show_banner "|           uboot build task over!            |"
 
@@ -92,7 +93,7 @@
 function build_kernel()
 {
     if [ ! -d ${ROOTFS_SRC} ] ; then 
-        echo "WARNNING: Maybe need input sudo passwd here: "
+        echo "WARNNING: decompress rootfs need input sudo passwd here: "
         sudo tar -xJf ${PACK_PATH}/${ROOTFS_SRC}.tar.xz
     fi
 
@@ -105,29 +106,44 @@
     fi
 
 	show_banner "|           start kernel build task...        |"
-    echo "WARNNING: Maybe need input sudo passwd here: "
-    sudo bash build.sh
+    chmod a+x build.sh
+    bash build.sh
 	show_banner "|            kernel build task over!          |"
 
 	cd -
 }
 
+#/tmp >: ubiattach -m 5 -d 5 /dev/ubi_ctrl
+#[  822.268210] UBI: attaching mtd5 to ubi5
+#[  822.272237] UBI: physical eraseblock size:   131072 bytes (128 KiB)
+#[  822.278848] UBI: logical eraseblock size:    126976 bytes
+#[  822.284479] UBI: smallest flash I/O unit:    2048
+#[  822.289398] UBI: VID header offset:          2048 (aligned 2048)
+#[  822.295665] UBI: data offset:                4096
+
 function build_ubifs()
 {
-    mkfs.ubifs –F -q -r ${ROOTFS_SRC} -m 2048 -e 126976 -c 2047 -o ubi.img
-    cat > ubinize.cfg <<EOF
-[ubifs]
-mode=ubi
-image=ubi.img
-vol_id=0
-vol_size=231MiB
-vol_type=dynamic
-vol_name=rootfs
-vol_flags=autoresize
-EOF
+    ubinize_cfg=ubinize.cfg 
+    ubimg_tmp=ubi.img
 
-    ubinize -o ${ROOTFS_IMG} -m 2048 -p 128KiB ubinize.cfg
-    rm -f ubi.img  ubinize.cfg
+    partition_size=140  # MiB 
+
+    # PEB counter: PartitionSize / PagesPerBlock(64) / PageSize(2K)
+    partition_peb_cnt=`expr $partition_size \* 1024 / 64 / 2`
+
+    # LEB counter need reserved some blocks for UBI badblock used.
+    partition_leb_cnt=`expr $partition_peb_cnt - 20`
+
+    echo "Parition size ${partition_size}MiB set LEB=$partition_leb_cnt"
+    set -x
+    mkfs.ubifs -F -d ${ROOTFS_SRC} -m 2048 -e 126976 -c $partition_leb_cnt -o ubi.img
+    set +x
+
+    printf "[ubifs] \nmode=ubi \nimage=${ubimg_tmp} \nvol_id=0 \nvol_size=${partition_size}MiB\n" > $ubinize_cfg 
+    printf "vol_type=dynamic \nvol_name=rootfs \nvol_flags=autoresize\n" >> $ubinize_cfg
+
+    ubinize -o ${ROOTFS_IMG} -m 2048 -p 128KiB $ubinize_cfg
+    rm -f $ubimg_tmp $ubinize_cfg
 
     chmod a+x ${ROOTFS_IMG}
 }
@@ -135,7 +151,7 @@
 function build_rootfs()
 {
     if [ ! -d ${ROOTFS_SRC} ] ; then 
-        echo "WARNNING: Maybe need input sudo passwd here: "
+        echo "WARNNING: decompress rootfs need input sudo passwd here: "
         sudo tar -xJf ${PACK_PATH}/${ROOTFS_SRC}.tar.xz
     fi
 
@@ -150,6 +166,9 @@
     if [ -d ${TFTP_PATH} ] ; then
         cp -f ${ROOTFS_IMG} ${TFTP_PATH}
     fi
+
+    rm -f ${ROOTFS_IMG}
+    ls ${IMGS_PATH}
 }
 
 

--
Gitblit v1.9.1