mnt.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2019, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-09-19 Gavin first version
  9. *
  10. */
  11. #include <rtthread.h>
  12. #ifdef RT_USING_DFS_RAMFS
  13. #include <dfs_fs.h>
  14. extern struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size);
  15. int mnt_init(void)
  16. {
  17. rt_uint8_t *pool = RT_NULL;
  18. rt_size_t size = 8*1024*1024;
  19. pool = rt_malloc(size);
  20. if (pool == RT_NULL)
  21. return 0;
  22. if (dfs_mount(RT_NULL, "/", "ram", 0, (const void *)dfs_ramfs_create(pool, size)) == 0)
  23. rt_kprintf("RAM file system initializated!\n");
  24. else
  25. rt_kprintf("RAM file system initializate failed!\n");
  26. return 0;
  27. }
  28. INIT_ENV_EXPORT(mnt_init);
  29. #endif
  30. #ifdef BSP_USING_SDCARD_FATFS
  31. #include <dfs_fs.h>
  32. #include <dfs_file.h>
  33. #define DBG_TAG "app.filesystem"
  34. #define DBG_LVL DBG_INFO
  35. #include <rtdbg.h>
  36. static int filesystem_mount(void)
  37. {
  38. while(rt_device_find("sd0") == RT_NULL)
  39. {
  40. rt_thread_mdelay(1);
  41. }
  42. int ret = dfs_mount("sd0", "/", "elm", 0, 0);
  43. if (ret != 0)
  44. {
  45. rt_kprintf("ret: %d\n",ret);
  46. LOG_E("sd0 mount to '/' failed!");
  47. return ret;
  48. }
  49. return RT_EOK;
  50. }
  51. INIT_ENV_EXPORT(filesystem_mount);
  52. #endif