qspi_mnt.c 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-04-11 ZYH first version
  9. */
  10. #include <rtthread.h>
  11. #if defined(RT_USING_FAL)
  12. #include <fal.h>
  13. #include <dfs_fs.h>
  14. int mnt_init(void)
  15. {
  16. fal_init();
  17. #if defined(BSP_MOUNT_QSPI_WITH_LFS)
  18. fal_mtd_nor_device_create("qspiflash");
  19. if (dfs_mount("qspiflash", "/", "lfs", 0, 0) == 0)
  20. {
  21. rt_kprintf("Mount \"qspiflash\" on \"/\" success\n");
  22. }
  23. else
  24. {
  25. dfs_mkfs("lfs","qspiflash");
  26. if (dfs_mount("qspiflash", "/", "lfs", 0, 0) == 0)
  27. {
  28. rt_kprintf("Mount \"qspiflash\" on \"/\" success\n");
  29. }
  30. else
  31. {
  32. rt_kprintf("Mount \"qspiflash\" on \"/\" fail\n");
  33. return -1;
  34. }
  35. }
  36. #endif
  37. return 0;
  38. }
  39. INIT_ENV_EXPORT(mnt_init);
  40. #endif