mnt.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /* initilize sd card */
  48. mci_hw_init("sd0");
  49. #ifdef RT_DFS_ELM_REENTRANT
  50. /* mount sd card fat partition 1 as root directory */
  51. if (dfs_mount("sd0", SD_ROOT, "elm", 0, 0) == 0)
  52. rt_kprintf("File System initialized!\n");
  53. else
  54. rt_kprintf("File System init failed!\n");
  55. #endif
  56. return 0;
  57. }
  58. INIT_ENV_EXPORT(mnt_init);