From ddbf2be2bc6d0ca40fc56e65c9c33cdde8ebd1e1 Mon Sep 17 00:00:00 2001 From: Robin Chen <56245435+IcyFeather233@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:19:36 +0800 Subject: [PATCH] enable art-pi spi flash use elmfatfs (#7690) --- .../stm32h750-artpi/board/port/filesystem.c | 44 ++++++++++++++++++- 1 file 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 -#include "dfs_romfs.h" + #ifdef BSP_USING_SDCARD_FS #include #include "drv_sdio.h" @@ -32,17 +32,30 @@ #define DBG_LVL DBG_INFO #include + +#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