mnt.c 1.3 KB

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