From e43548f46f679a9950001059d13d06bbf32a1986 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 16 May 2022 01:21:47 -0400 Subject: [PATCH] =?UTF-8?q?[simulator]=20=E4=BC=98=E5=8C=96SD=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=EF=BC=8C=E5=9C=A8=E9=A6=96=E6=AC=A1=E6=8C=82=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=90=8E=E6=A0=BC=E5=BC=8F=E5=8C=96=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E5=B0=9D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/simulator/applications/mnt.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/bsp/simulator/applications/mnt.c b/bsp/simulator/applications/mnt.c index 170f104c75..d7e49b854f 100644 --- a/bsp/simulator/applications/mnt.c +++ b/bsp/simulator/applications/mnt.c @@ -10,10 +10,14 @@ #include #include +#define DBG_TAG "FileSystem" +#define DBG_LVL DBG_INFO +#include + #ifdef RT_USING_DFS #include -int mnt_init(void) +static int mnt_init(void) { #ifdef RT_USING_DFS_WINSHAREDIR extern int dfs_win32_init(void); @@ -24,29 +28,40 @@ int mnt_init(void) if (dfs_mount("wshare", "/", "wdir", 0, 0) == 0) { - rt_kprintf("File System on root initialized!\n"); + LOG_I("[wshare] File System on root ('wshare') initialized!"); } else { - rt_kprintf("File System on root initialization failed!\n"); + LOG_E("[wshare] File System on root ('wshare') initialization failed!"); } if (dfs_mount("sd0", "/sd", "elm", 0, 0) == 0) { - rt_kprintf("File System on sd initialized!\n"); + LOG_I("[sd0] File System on SD ('sd0') initialized!"); } else { - rt_kprintf("File System on sd initialization failed!\n"); + LOG_W("[sd0] File System on SD ('sd0') initialization failed!"); + LOG_W("[sd0] Try to format and re-mount again..."); + if (dfs_mkfs("elm", "sd0") == 0) + { + if (dfs_mount("sd0", "/sd", "elm", 0, 0) == 0) + { + LOG_I("[sd0] File System on SD ('sd0') initialized!"); + return 0; + } + } + + LOG_E("[sd0] File System on SD ('sd0') initialization failed!"); } #else if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) { - rt_kprintf("File System on sd initialized!\n"); + LOG_I("[sd0] File System on sd initialized!"); } else { - rt_kprintf("File System on sd initialization failed!\n"); + LOG_E("[sd0] File System on sd initialization failed!"); } #endif