[Feature][T108][task-view-289]Integration of fstrim tool and development of corresponding gsw hal layer code

Only Configure: No
Affected branch: GSW_V1453
Affected module: filesystem
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no

Change-Id: I6ddd5ce8b84aefaa5dace1291c5b2db4e3f57325
diff --git a/config/defconfig_asr1806p301 b/config/defconfig_asr1806p301
index da1843c..7d97dde 100755
--- a/config/defconfig_asr1806p301
+++ b/config/defconfig_asr1806p301
@@ -98,7 +98,7 @@
 # Global build settings
 #
 CONFIG_MBTK_BUILD_PROJECT="T108"
-#CONFIG_MBTK_ADB_SEC_SUPPORT is not set
+# CONFIG_MBTK_ADB_SEC_SUPPORT is not set
 CONFIG_MBTK_DRIVERS=y
 # CONFIG_CUSTOMER_DRIVERS is not set
 # CONFIG_MPIPE_SHARE_NETWORK is not set
@@ -2180,7 +2180,7 @@
 # Linux System Utilities
 #
 # CONFIG_BUSYBOX_CONFIG_ACPID is not set
-# CONFIG_BUSYBOX_CONFIG_BLKDISCARD is not set
+CONFIG_BUSYBOX_CONFIG_BLKDISCARD=y
 # CONFIG_BUSYBOX_CONFIG_BLKID is not set
 # CONFIG_BUSYBOX_CONFIG_BLOCKDEV is not set
 # CONFIG_BUSYBOX_CONFIG_CAL is not set
@@ -2206,7 +2206,7 @@
 # CONFIG_BUSYBOX_CONFIG_FREERAMDISK is not set
 # CONFIG_BUSYBOX_CONFIG_FSCK_MINIX is not set
 # CONFIG_BUSYBOX_CONFIG_FSFREEZE is not set
-# CONFIG_BUSYBOX_CONFIG_FSTRIM is not set
+CONFIG_BUSYBOX_CONFIG_FSTRIM=y
 # CONFIG_BUSYBOX_CONFIG_GETOPT is not set
 CONFIG_BUSYBOX_CONFIG_HEXDUMP=y
 # CONFIG_BUSYBOX_CONFIG_HD is not set
@@ -5659,7 +5659,7 @@
 # CONFIG_PACKAGE_libmodbus is not set
 # CONFIG_PACKAGE_libmosquitto-nossl is not set
 # CONFIG_PACKAGE_libmosquitto-ssl is not set
-# CONFIG_PACKAGE_libmount is not set
+CONFIG_PACKAGE_libmount=y
 # CONFIG_PACKAGE_libmpc is not set
 # CONFIG_PACKAGE_libmpdclient is not set
 # CONFIG_PACKAGE_libmpeg2 is not set
@@ -5776,7 +5776,7 @@
 # CONFIG_PACKAGE_libshout-nossl is not set
 # CONFIG_PACKAGE_libsispmctl is not set
 # CONFIG_PACKAGE_libslang2 is not set
-# CONFIG_PACKAGE_libsmartcols is not set
+CONFIG_PACKAGE_libsmartcols=y
 # CONFIG_PACKAGE_libsndfile is not set
 # CONFIG_PACKAGE_libsoc is not set
 # CONFIG_PACKAGE_libsocketcan is not set
@@ -7377,7 +7377,7 @@
 # CONFIG_PACKAGE_f2fs-tools is not set
 # CONFIG_PACKAGE_f2fsck is not set
 # CONFIG_PACKAGE_filefrag is not set
-# CONFIG_PACKAGE_fstrim is not set
+CONFIG_PACKAGE_fstrim=y
 # CONFIG_PACKAGE_fuse-utils is not set
 # CONFIG_PACKAGE_fuse3-utils is not set
 # CONFIG_PACKAGE_hfsfsck is not set
diff --git a/mbtk/libgsw_lib/gsw_hwpin_interface.c b/mbtk/libgsw_lib/gsw_hwpin_interface.c
index d132b01..af452ac 100755
--- a/mbtk/libgsw_lib/gsw_hwpin_interface.c
+++ b/mbtk/libgsw_lib/gsw_hwpin_interface.c
@@ -770,5 +770,19 @@
 

 int gsw_hwpin_fstrim_emmc(const char *emmc_path)

 {

+    char cmd[256] = {0};

+    int ret = 0;

+

+    if(!emmc_path || access(emmc_path, F_OK) != 0) 

+    {

+        LOGE("Invalid path : %s", emmc_path);

+        return ret;

+    }

+

+    sprintf(cmd, "fstrim -v %s", emmc_path);

+    ret = system(cmd);

+

+    LOGI("command %s, ret : %d", cmd, ret);

+

     return GSW_HAL_SUCCESS;

 }
\ No newline at end of file
diff --git a/target/linux/mmp/base-files/lib/preinit/emmc_mount.sh b/target/linux/mmp/base-files/lib/preinit/emmc_mount.sh
index fa3993e..260f7ee 100644
--- a/target/linux/mmp/base-files/lib/preinit/emmc_mount.sh
+++ b/target/linux/mmp/base-files/lib/preinit/emmc_mount.sh
@@ -75,7 +75,7 @@
 		#Ïȳ¢ÊÔÊÇ·ñ¿ÉÒÔmountÉÏ, Èç¹ûÒѾ­¸ñʽ»¯£¬Ö»ÒªÖ´ÐйÒÔØ¾Í¿ÉÒÔ£¬¾¡Á¿²»¸ñʽ»¯emmc
 			echo "find $file_emmc_partition, and mount to $file_mount_point" >> $file_log
 			mkdir $file_mount_point
-			mount -t ext4 $file_emmc_partition $file_mount_point
+			mount -t ext4 -o discard $file_emmc_partition $file_mount_point
 		#¼ì²éÊÇ·ñ¿ÉÒÔ¹ÒÔØÉÏ
 			mountCheck bbb
 			echo "bbb find mount_point:$find_mount_point, find_format:$find_format" >> $file_log
@@ -109,7 +109,7 @@
 			if [ $find_mount_point -eq 0 -o $find_format -eq 0 ] ; then
 				echo "try mount $file_emmc_partition after proper process" >> $file_log
 				mkdir $file_mount_point
-				mount -t auto $file_emmc_partition $file_mount_point
+				mount -t auto -o discard $file_emmc_partition $file_mount_point
 				sleep 1s
 				#¼ì²éÊÇ·ñ¿ÉÒÔ¹ÒÔØÉÏ
 				mountCheck zzz