enable art-pi spi flash use elmfatfs (#7690)

This commit is contained in:
Robin Chen 2023-11-22 16:19:36 +08:00 committed by GitHub
parent 873fd76b2f
commit ddbf2be2bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 42 additions and 2 deletions

View File

@ -20,7 +20,7 @@
#endif #endif
#include <dfs_fs.h> #include <dfs_fs.h>
#include "dfs_romfs.h"
#ifdef BSP_USING_SDCARD_FS #ifdef BSP_USING_SDCARD_FS
#include <board.h> #include <board.h>
#include "drv_sdio.h" #include "drv_sdio.h"
@ -32,17 +32,30 @@
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#include <rtdbg.h> #include <rtdbg.h>
#include "dfs_romfs.h"
#ifdef RT_USING_DFS_ELMFAT
static const struct romfs_dirent _romfs_root[] =
{
{ROMFS_DIRENT_DIR, "flash", RT_NULL, 0},
{ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0},
{ROMFS_DIRENT_DIR, "filesystem", RT_NULL, 0}
};
#else
static const struct romfs_dirent _romfs_root[] = static const struct romfs_dirent _romfs_root[] =
{ {
{ROMFS_DIRENT_DIR, "flash", RT_NULL, 0}, {ROMFS_DIRENT_DIR, "flash", RT_NULL, 0},
{ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0} {ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0}
}; };
#endif
const struct romfs_dirent romfs_root = const struct romfs_dirent romfs_root =
{ {
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root) / sizeof(_romfs_root[0]) ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root) / sizeof(_romfs_root[0])
}; };
#ifdef BSP_USING_SDCARD_FS #ifdef BSP_USING_SDCARD_FS
/* SD Card hot plug detection pin */ /* SD Card hot plug detection pin */
@ -116,10 +129,12 @@ static void sd_mount(void *parameter)
int mount_init(void) int mount_init(void)
{ {
#ifdef RT_USING_DFS_ROMFS
if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) != 0) if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) != 0)
{ {
LOG_E("rom mount to '/' failed!"); LOG_E("rom mount to '/' failed!");
} }
#endif
#ifdef BSP_USING_SPI_FLASH_FS #ifdef BSP_USING_SPI_FLASH_FS
struct rt_device *flash_dev = RT_NULL; struct rt_device *flash_dev = RT_NULL;
@ -130,6 +145,30 @@ int mount_init(void)
flash_dev = fal_mtd_nor_device_create("filesystem"); flash_dev = fal_mtd_nor_device_create("filesystem");
#ifdef RT_USING_DFS_ELMFAT
flash_dev = fal_blk_device_create("filesystem");
if (flash_dev)
{
//mount filesystem
if (dfs_mount(flash_dev->parent.name, "/filesystem", "elm", 0, 0) != 0)
{
LOG_W("mount to '/filesystem' failed! try to mkfs %s", flash_dev->parent.name);
dfs_mkfs("elm", flash_dev->parent.name);
if (dfs_mount(flash_dev->parent.name, "/filesystem", "elm", 0, 0) == 0)
{
LOG_I("mount to '/filesystem' success!");
}
}
else
{
LOG_I("mount to '/filesystem' success!");
}
}
else
{
LOG_E("Can't create block device filesystem or bt_image partition.");
}
#else
if (flash_dev) if (flash_dev)
{ {
//mount filesystem //mount filesystem
@ -150,8 +189,9 @@ int mount_init(void)
} }
else else
{ {
LOG_E("Can't create block device filesystem or bt_image partition."); LOG_E("Can't create block device filesystem or bt_image partition.");
} }
#endif
#endif #endif