summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Chen <[email protected]>2023-11-22 16:19:36 +0800
committerGitHub <[email protected]>2023-11-22 16:19:36 +0800
commitddbf2be2bc6d0ca40fc56e65c9c33cdde8ebd1e1 (patch)
tree826d7aa4af867e611b056d03432d475b694ebf5c
parent873fd76b2f180ec42b2d0e50b24cde07a1453975 (diff)
enable art-pi spi flash use elmfatfs (#7690)
-rw-r--r--bsp/stm32/stm32h750-artpi/board/port/filesystem.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/bsp/stm32/stm32h750-artpi/board/port/filesystem.c b/bsp/stm32/stm32h750-artpi/board/port/filesystem.c
index a774907b33..a88c1b1b95 100644
--- a/bsp/stm32/stm32h750-artpi/board/port/filesystem.c
+++ b/bsp/stm32/stm32h750-artpi/board/port/filesystem.c
@@ -20,7 +20,7 @@
#endif
#include <dfs_fs.h>
-#include "dfs_romfs.h"
+
#ifdef BSP_USING_SDCARD_FS
#include <board.h>
#include "drv_sdio.h"
@@ -32,17 +32,30 @@
#define DBG_LVL DBG_INFO
#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[] =
{
{ROMFS_DIRENT_DIR, "flash", RT_NULL, 0},
{ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0}
};
+#endif
const struct romfs_dirent romfs_root =
{
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root) / sizeof(_romfs_root[0])
};
+
#ifdef BSP_USING_SDCARD_FS
/* SD Card hot plug detection pin */
@@ -116,10 +129,12 @@ static void sd_mount(void *parameter)
int mount_init(void)
{
+ #ifdef RT_USING_DFS_ROMFS
if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) != 0)
{
LOG_E("rom mount to '/' failed!");
}
+ #endif
#ifdef BSP_USING_SPI_FLASH_FS
struct rt_device *flash_dev = RT_NULL;
@@ -130,6 +145,30 @@ int mount_init(void)
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)
{
//mount filesystem
@@ -150,8 +189,9 @@ int mount_init(void)
}
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