mnt.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2006-2020, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020/12/31 Bernard Add license info
  9. */
  10. #include <rtthread.h>
  11. #define DBG_TAG "FileSystem"
  12. #define DBG_LVL DBG_INFO
  13. #include <rtdbg.h>
  14. #ifdef RT_USING_DFS
  15. #include <dfs_fs.h>
  16. int mnt_init(void)
  17. {
  18. rt_thread_delay(RT_TICK_PER_SECOND);
  19. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  20. {
  21. LOG_I("file system initialization done!\n");
  22. return 0;
  23. }
  24. else
  25. {
  26. LOG_W("[sd0] File System on SD ('sd0') initialization failed!");
  27. LOG_W("[sd0] Try to format and re-mount...");
  28. if (dfs_mkfs("elm", "sd0") == 0)
  29. {
  30. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  31. {
  32. LOG_I("[sd0] File System on SD ('sd0') initialized!");
  33. return 0;
  34. }
  35. }
  36. LOG_E("[sd0] File System on SD ('sd0') initialization failed!");
  37. return -1;
  38. }
  39. }
  40. INIT_ENV_EXPORT(mnt_init);
  41. #endif