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 * 2018-12-13 balanceTWK add sdcard port file
9 * 2021-05-10 Meco Man fix a bug that cannot use fatfs in the main thread at starting up
10 * 2021-07-28 Meco Man implement romfs as the root filesystem
11 */
12 #include <rtthread.h>
13 #include <dfs_fs.h>
14 #include <dfs_file.h>
15
16 #define DBG_TAG "app.filesystem"
17 #define DBG_LVL DBG_INFO
18 #include <rtdbg.h>
19
littlefs_mount(void)20 static int littlefs_mount(void)
21 {
22 if (rt_device_find("mflash") == RT_NULL)
23 {
24 LOG_E("mflash device not find!!");
25 return -RT_EIO;
26 }
27 int ret = dfs_mount("mflash", "/", "lfs", 0, 0);
28 if (ret != 0)
29 {
30 LOG_E("mflash mount to '/' failed!");
31 ret = dfs_mkfs("lfs", "mflash");
32 if (ret != 0)
33 return ret;
34 ret = dfs_mount("mflash", "/", "lfs", 0, 0);
35 if (ret != 0)
36 return ret;
37 }
38
39 LOG_D("mflash mount to '/' successed");
40
41 return RT_EOK;
42 }
43 INIT_APP_EXPORT(littlefs_mount);
44