1 /*
2  * Copyright (c) 2006-2021, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author        Notes
8  * 2011-01-13     weety     first version
9  */
10 
11 
12 /**
13  * @addtogroup dm365
14  */
15 /*@{*/
16 
17 #include <rtthread.h>
18 
19 #ifdef RT_USING_DFS
20 /* dfs Filesystem APIs */
21 #include <dfs_fs.h>
22 #endif
23 
24 #ifdef RT_USING_SDIO
25 #include <drivers/dev_mmcsd_core.h>
26 #endif
27 
main(void)28 int main(void)
29 {
30     int timeout = 0;
31 
32 /* Filesystem Initialization */
33 #ifdef RT_USING_DFS
34     {
35 
36 #if defined(RT_USING_DFS_ROMFS)
37         if (dfs_mount(RT_NULL, "/rom", "rom", 0, &romfs_root) == 0)
38         {
39             rt_kprintf("ROM File System initialized!\n");
40         }
41         else
42             rt_kprintf("ROM File System initialzation failed!\n");
43 #endif
44 
45 #if defined(RT_USING_DFS_UFFS)
46     {
47         /* mount flash device as flash directory */
48         if(dfs_mount("nand0", "/nand0", "uffs", 0, 0) == 0)
49             rt_kprintf("UFFS File System initialized!\n");
50         else
51             rt_kprintf("UFFS File System initialzation failed!\n");
52     }
53 #endif
54 
55 #ifdef RT_USING_SDIO
56     timeout = 0;
57     while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2))
58     {
59         rt_thread_delay(1);
60     }
61 
62     if (timeout < RT_TICK_PER_SECOND*2)
63     {
64         /* mount sd card fat partition 1 as root directory */
65         if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
66         {
67             rt_kprintf("File System initialized!\n");
68         }
69         else
70             rt_kprintf("File System initialzation failed!%d\n", rt_get_errno());
71     }
72     else
73     {
74         rt_kprintf("No SD card found.\n");
75     }
76 #endif
77     }
78 #endif
79 
80     /* put user application code here */
81 
82 }
83 
84 
85 /* NFSv3 Initialization */
86 #if defined(RT_USING_DFS) && defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
87 #include <dfs_nfs.h>
nfs_start(void)88 void nfs_start(void)
89 {
90     nfs_init();
91 
92     if (dfs_mount(RT_NULL, "/nfs", "nfs", 0, RT_NFS_HOST_EXPORT) == 0)
93     {
94         rt_kprintf("NFSv3 File System initialized!\n");
95     }
96     else
97         rt_kprintf("NFSv3 File System initialzation failed!\n");
98 }
99 
100 #include "finsh.h"
101 FINSH_FUNCTION_EXPORT(nfs_start, start net filesystem);
102 #endif
103 
104 /*@}*/
105