mnt.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * File : mnt_init.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2008 - 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2017-11-8 Tangyuxin first version
  23. */
  24. #include <rtthread.h>
  25. #include <rtdevice.h>
  26. #ifdef RT_USING_DFS
  27. #include <dfs_fs.h>
  28. int mnt_init(void)
  29. {
  30. rt_kprintf("init filesystem...\n");
  31. #ifdef RT_USING_MTD_NOR
  32. //mount rootfs
  33. if (dfs_mount("rootfs", "/", "elm", 0, 0) == 0)
  34. {
  35. rt_kprintf("File System on root initialized!\n");
  36. }
  37. else
  38. {
  39. rt_kprintf("File System on root initialization failed!\n");
  40. }
  41. //mount appfs
  42. if (dfs_mount("appfs", "/appfs", "elm", 0, 0) == 0)
  43. {
  44. rt_kprintf("File System on appfs initialized!\n");
  45. }
  46. else
  47. {
  48. rt_kprintf("File System on appfs initialization failed!\n");
  49. }
  50. #endif
  51. #if (defined(RT_USING_SDIO) && defined(RT_USING_MSC0))
  52. rt_thread_delay(RT_TICK_PER_SECOND/5);
  53. if (dfs_mount("sd0", "/sd", "elm", 0, 0) == 0)
  54. {
  55. rt_kprintf("File System on TF initialized!\n");
  56. }
  57. else
  58. {
  59. rt_kprintf("File System on TF fail!\n");
  60. }
  61. #endif
  62. return 0;
  63. }
  64. INIT_ENV_EXPORT(mnt_init);
  65. #endif