mnt.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**************************************************************************//**
  2. *
  3. * @copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Change Logs:
  8. * Date Author Notes
  9. * 2020-1-16 Wayne First version
  10. *
  11. ******************************************************************************/
  12. #include <rtthread.h>
  13. #if defined(RT_USING_DFS)
  14. #include <dfs_fs.h>
  15. #include <dfs_file.h>
  16. #include <unistd.h>
  17. #include <stdio.h>
  18. #include <sys/stat.h>
  19. #include <sys/statfs.h>
  20. #endif
  21. #if defined(PKG_USING_FAL)
  22. #include <fal.h>
  23. #endif
  24. #if defined(BOARD_USING_STORAGE_SPIFLASH)
  25. #define MOUNT_POINT_SPIFLASH0 "/"
  26. #endif
  27. #if defined(BOARD_USING_STORAGE_SPIFLASH)
  28. #if defined(RT_USB_DEVICE_MSTORAGE)
  29. int mnt_init_spiflash0(void)
  30. {
  31. rt_kprintf("Sorry, you enabled RT_USB_DEVICE_MSTORAGE option in menu, so we won't mount flash0 on /.\n");
  32. return 0;
  33. }
  34. #else
  35. int mnt_init_spiflash0(void)
  36. {
  37. if (dfs_mount("flash0", MOUNT_POINT_SPIFLASH0, "elm", 0, 0) != 0)
  38. {
  39. rt_kprintf("Failed to mount elm on %s.\n", MOUNT_POINT_SPIFLASH0);
  40. rt_kprintf("Try to execute 'mkfs -t elm flash0' first, then reboot.\n");
  41. goto exit_mnt_init_spiflash0;
  42. }
  43. rt_kprintf("mount flash0 with elmfat type: ok\n");
  44. exit_mnt_init_spiflash0:
  45. return 0;
  46. }
  47. #endif
  48. INIT_ENV_EXPORT(mnt_init_spiflash0);
  49. #endif