|
@@ -16,6 +16,7 @@
|
|
|
#include <dfs_romfs.h>
|
|
|
#include <dfs_fs.h>
|
|
|
#include <dfs_posix.h>
|
|
|
+#include <fal.h>
|
|
|
|
|
|
#if DFS_FILESYSTEMS_MAX < 4
|
|
|
#error "Please define DFS_FILESYSTEMS_MAX more than 4"
|
|
@@ -75,12 +76,73 @@ static int onboard_sdcard_mount(void)
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#ifdef BSP_USING_SPI_FLASH_LITTLEFS
|
|
|
+
|
|
|
+#define FS_PARTITION_NAME "filesystem"
|
|
|
+
|
|
|
+static void spiflash_mount(void *parameter)
|
|
|
+{
|
|
|
+ struct rt_device *mtd_dev = RT_NULL;
|
|
|
+ fal_init();
|
|
|
+ mtd_dev = fal_mtd_nor_device_create(FS_PARTITION_NAME);
|
|
|
+ if (!mtd_dev)
|
|
|
+ {
|
|
|
+ LOG_E("Can't create a mtd device on '%s' partition.", FS_PARTITION_NAME);
|
|
|
+ }
|
|
|
+ while (1)
|
|
|
+ {
|
|
|
+ rt_thread_mdelay(500);
|
|
|
+ if(rt_device_find(FS_PARTITION_NAME) != RT_NULL)
|
|
|
+ {
|
|
|
+ if (dfs_mount(FS_PARTITION_NAME, "/flash", "lfs", 0, 0) == RT_EOK)
|
|
|
+ {
|
|
|
+ LOG_I("spi flash mount to '/flash'");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LOG_W("spi flash mount to '/flash' failed!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static int onboard_spiflash_mount(void)
|
|
|
+{
|
|
|
+ rt_thread_t tid;
|
|
|
+
|
|
|
+ if (dfs_mount(FS_PARTITION_NAME, "/flash", "lfs", 0, 0) == RT_EOK)
|
|
|
+ {
|
|
|
+ LOG_I("spi flash mount to '/flash'");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tid = rt_thread_create("spiflash_mount", spiflash_mount, RT_NULL,
|
|
|
+ 1024, RT_THREAD_PRIORITY_MAX - 3, 20);
|
|
|
+ if (tid != RT_NULL)
|
|
|
+ {
|
|
|
+ rt_thread_startup(tid);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LOG_E("create spiflash_mount thread err!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return RT_EOK;
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
static const struct romfs_dirent _romfs_root[] =
|
|
|
{
|
|
|
#ifdef BSP_USING_SDCARD
|
|
|
{ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0},
|
|
|
#endif
|
|
|
-// {ROMFS_DIRENT_DIR, "flash", RT_NULL, 0},
|
|
|
+
|
|
|
+#ifdef BSP_USING_SPI_FLASH_LITTLEFS
|
|
|
+ {ROMFS_DIRENT_DIR, "flash", RT_NULL, 0},
|
|
|
+#endif
|
|
|
};
|
|
|
|
|
|
const struct romfs_dirent romfs_root =
|
|
@@ -98,6 +160,10 @@ static int filesystem_mount(void)
|
|
|
onboard_sdcard_mount();
|
|
|
#endif
|
|
|
|
|
|
+#ifdef BSP_USING_SPI_FLASH_LITTLEFS
|
|
|
+ onboard_spiflash_mount();
|
|
|
+#endif
|
|
|
+
|
|
|
return RT_EOK;
|
|
|
}
|
|
|
INIT_APP_EXPORT(filesystem_mount);
|