mnt.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_posix.h>
  16. #endif
  17. #if defined(PKG_USING_FAL)
  18. #include <fal.h>
  19. #endif
  20. #if defined(BOARD_USING_STORAGE_SPIFLASH)
  21. #define MOUNT_POINT_SPIFLASH0 "/"
  22. #endif
  23. #if defined(BOARD_USING_STORAGE_SPIFLASH)
  24. #if defined(RT_USB_DEVICE_MSTORAGE)
  25. int mnt_init_spiflash0(void)
  26. {
  27. rt_kprintf("Sorry, you enabled RT_USB_DEVICE_MSTORAGE option in menu, so we won't mount flash0 on /.\n");
  28. return 0;
  29. }
  30. #else
  31. int mnt_init_spiflash0(void)
  32. {
  33. if (dfs_mount("flash0", MOUNT_POINT_SPIFLASH0, "elm", 0, 0) != 0)
  34. {
  35. rt_kprintf("Failed to mount elm on %s.\n", MOUNT_POINT_SPIFLASH0);
  36. rt_kprintf("Try to execute 'mkfs -t elm flash0' first, then reboot.\n");
  37. goto exit_mnt_init_spiflash0;
  38. }
  39. rt_kprintf("mount flash0 with elmfat type: ok\n");
  40. exit_mnt_init_spiflash0:
  41. return 0;
  42. }
  43. #endif
  44. INIT_ENV_EXPORT(mnt_init_spiflash0);
  45. #endif