1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Email: opensource_embedded@phytium.com.cn
7  *
8  * Change Logs:
9  * Date           Author       Notes
10  * 2023-04-27     huanghe      first version
11  * 2023-07-14   liqiaozhong    add SD file sys mount func
12  *
13  */
14 #include <rtthread.h>
15 #include <rtdbg.h>
16 #ifndef RT_USING_SMART
17 #include <dfs_fs.h>
18 #include <dfs_file.h>
19 
ram_disk_mount(const char * mount_point)20 static int ram_disk_mount(const char *mount_point)
21 {
22     extern struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size);
23 
24     rt_uint8_t *pool = RT_NULL;
25     rt_size_t size = 8 * 1024 * 1024;
26 
27     pool = rt_malloc(size);
28     if (pool == RT_NULL)
29     {
30         LOG_E("Malloc fail!");
31     }
32 
33     if (dfs_mount(RT_NULL, mount_point, "ram", 0, (const void *)dfs_ramfs_create(pool, size)) == 0)
34     {
35         LOG_I("RAM file system initializated!");
36     }
37     else
38     {
39         LOG_E("RAM file system initializate failed!");
40     }
41 
42     return RT_EOK;
43 }
44 
filesystem_mount(void)45 static int filesystem_mount(void)
46 {
47     return ram_disk_mount("/"); /* mount ramdisk as / */
48 }
49 INIT_APP_EXPORT(filesystem_mount);
50 #endif