mnt.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * File : mnt.c
  3. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * Change Logs:
  20. * Date Author Notes
  21. * 2017-08-08 Yang the first version
  22. */
  23. #include <rtthread.h>
  24. #include <dfs.h>
  25. #include <dfs_fs.h>
  26. #ifdef RT_USING_DFS_ROMFS
  27. #include <dfs_romfs.h>
  28. #endif
  29. #include "drv_sd.h"
  30. #ifdef RT_USING_DFS_ROMFS
  31. #define SD_ROOT "/sdcard"
  32. #else
  33. #define SD_ROOT "/"
  34. #endif
  35. int mnt_init(void)
  36. {
  37. #ifdef RT_USING_DFS_ROMFS
  38. /* initialize the device filesystem */
  39. dfs_init();
  40. dfs_romfs_init();
  41. /* mount rom file system */
  42. if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) == 0)
  43. {
  44. rt_kprintf("ROM file system initializated!\n");
  45. }
  46. #endif
  47. #ifdef BSP_DRV_SDCARD
  48. /* initilize sd card */
  49. mci_hw_init("sd0");
  50. #endif
  51. #ifdef RT_DFS_ELM_REENTRANT
  52. /* mount sd card fat partition 1 as root directory */
  53. if (dfs_mount("sd0", SD_ROOT, "elm", 0, 0) == 0)
  54. rt_kprintf("File System initialized!\n");
  55. else
  56. rt_kprintf("File System init failed!\n");
  57. #endif
  58. return 0;
  59. }
  60. INIT_ENV_EXPORT(mnt_init);