From 034166dfb9fa985f4a7f0c75c29902bbc6c21bf8 Mon Sep 17 00:00:00 2001 From: "bernard.xiong" Date: Thu, 11 Feb 2010 15:55:46 +0000 Subject: [PATCH] use ELM FatFs as FAT file system. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@406 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/stm3210/project_filesystem/application.c | 71 ++++++-------------- bsp/stm3210/project_filesystem/project.Uv2 | 16 +---- bsp/stm3210/project_filesystem/project.ewp | 40 +---------- bsp/stm3210/project_filesystem/rtconfig.h | 12 +++- 4 files changed, 36 insertions(+), 103 deletions(-) diff --git a/bsp/stm3210/project_filesystem/application.c b/bsp/stm3210/project_filesystem/application.c index 9258aa0449..698f4a9bf0 100644 --- a/bsp/stm3210/project_filesystem/application.c +++ b/bsp/stm3210/project_filesystem/application.c @@ -24,67 +24,38 @@ #include /* dfs filesystem:EFS filesystem init */ #include +/* dfs filesystem:ELM FatFs filesystem init */ +#include /* dfs Filesystem APIs */ #include #endif -/* filesystem test */ -#include -static char fullpath[256 + 1]; -void ls_root() -{ - DIR *dir; - - dir = opendir("/"); - if (dir != RT_NULL) - { - struct dfs_dirent* dirent; - struct dfs_stat s; - - do - { - dirent = readdir(dir); - if (dirent == RT_NULL) break; - rt_memset(&s, 0, sizeof(struct dfs_stat)); - - /* build full path for each file */ - rt_sprintf(fullpath, "/%s", dirent->d_name); - - stat(fullpath, &s); - if ( s.st_mode & DFS_S_IFDIR ) - { - rt_kprintf("%s\t\t\n", dirent->d_name); - } - else - { - rt_kprintf("%s\t\t%lu\n", dirent->d_name, s.st_size); - } - } while (dirent != RT_NULL); - - closedir(dir); - } - else rt_kprintf("open root directory failed\n"); -} - void rt_init_thread_entry(void* parameter) { /* Filesystem Initialization */ #ifdef RT_USING_DFS { - /* init the device filesystem */ - dfs_init(); - /* init the efsl filesystam*/ - efsl_init(); + /* init the device filesystem */ + dfs_init(); +#ifdef RT_USING_DFS_EFSL + /* init the efsl filesystam*/ + efsl_init(); - /* mount sd card fat partition 1 as root directory */ - if (dfs_mount("sd0", "/", "efs", 0, 0) == 0) - { - rt_kprintf("File System initialized!\n"); - ls_root(); - } - else - rt_kprintf("File System init failed!\n"); + /* mount sd card fat partition 1 as root directory */ + if (dfs_mount("sd0", "/", "efs", 0, 0) == 0) + rt_kprintf("File System initialized!\n"); + else + rt_kprintf("File System init failed!\n"); +#elif defined(RT_USING_DFS_ELMFAT) + /* init the elm FAT filesystam*/ + elm_init(); + /* mount sd card fat partition 1 as root directory */ + if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) + rt_kprintf("File System initialized!\n"); + else + rt_kprintf("File System init failed!\n"); +#endif } #endif } diff --git a/bsp/stm3210/project_filesystem/project.Uv2 b/bsp/stm3210/project_filesystem/project.Uv2 index d786e7e14d..668dc9e6f1 100644 --- a/bsp/stm3210/project_filesystem/project.Uv2 +++ b/bsp/stm3210/project_filesystem/project.Uv2 @@ -66,22 +66,12 @@ File 5,2,<..\..\libcpu\arm\stm32\fault_rvds.S> File 5,2,<..\..\libcpu\arm\stm32\start_rvds.s> File 5,1,<..\..\libcpu\arm\stm32\serial.c> File 6,1,<..\..\filesystem\dfs\src\dfs_util.c> -File 6,1,<..\..\filesystem\dfs\src\dfs_cache.c> File 6,1,<..\..\filesystem\dfs\src\dfs_fs.c> File 6,1,<..\..\filesystem\dfs\src\dfs_init.c> File 6,1,<..\..\filesystem\dfs\src\dfs_posix.c> File 6,1,<..\..\filesystem\dfs\src\dfs_raw.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\base\plibc.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\base\efs.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\base\extract.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\base\partition.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\ui.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\dir.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\fat.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\file.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\fs.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\ls.c> -File 6,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\time.c> +File 6,1,<..\..\filesystem\dfs\filesystems\elmfat\dfs_elm.c> +File 6,1,<..\..\filesystem\dfs\filesystems\elmfat\ff.c> Options 1,0,0 // Target 'RT-Thread STM32' @@ -142,7 +132,7 @@ Options 1,0,0 // Target 'RT-Thread STM32' ADSCMISC () ADSCDEFN (USE_STDPERIPH_DRIVER, STM32F10X_HD,) ADSCUDEF () - ADSCINCD (.\Libraries\STM32F10x_StdPeriph_Driver\inc;.\Libraries\CMSIS\Core\CM3;..\..\include;.;..\..\libcpu\arm\stm32;..\..\filesystem\dfs;..\..\filesystem\dfs\include;..\..\filesystem\dfs\filesystems\efsl\src\include;..\..\filesystem\dfs\filesystems\efsl\src\base\include;..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\include) + ADSCINCD (.\Libraries\STM32F10x_StdPeriph_Driver\inc;.\Libraries\CMSIS\Core\CM3;..\..\include;.;..\..\libcpu\arm\stm32;..\..\filesystem\dfs;..\..\filesystem\dfs\include;..\..\finsh) ADSASFLG { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } ADSAMISC () ADSADEFN () diff --git a/bsp/stm3210/project_filesystem/project.ewp b/bsp/stm3210/project_filesystem/project.ewp index 09c3528631..5bc9e840d6 100644 --- a/bsp/stm3210/project_filesystem/project.ewp +++ b/bsp/stm3210/project_filesystem/project.ewp @@ -287,9 +287,6 @@ $PROJ_DIR$\..\..\libcpu\arm\stm32 $PROJ_DIR$\..\..\filesystem\dfs $PROJ_DIR$\..\..\filesystem\dfs\include - $PROJ_DIR$\..\..\filesystem\dfs\filesystems\efsl\src\include - $PROJ_DIR$\..\..\filesystem\dfs\filesystems\efsl\src\base\include - $PROJ_DIR$\..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\include