Skip to content

Commit 963cce1

Browse files
committed
解决没有选定FAL和littlefs软件包的问题,解决挂载顺序不合理的问题,重命名spiflash设备为spiflash0
1 parent 1f13b6d commit 963cce1

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed

bsp/stm32/stm32f407-atk-explorer/board/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ menu "Onboard Peripheral Drivers"
9999
select RT_USING_MTD_NOR
100100
select BSP_USING_SPI_FLASH
101101
select BSP_USING_FS
102+
select PKG_USING_FAL
103+
select FAL_USING_SFUD_PORT
104+
select PKG_USING_LITTLEFS
102105
select RT_USING_SYSTEM_WORKQUEUE
103106
default n
104107

bsp/stm32/stm32f407-atk-explorer/board/ports/drv_filesystem.c

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <dfs_romfs.h>
1717
#include <dfs_fs.h>
1818
#include <dfs_posix.h>
19-
#include <fal.h>
2019

2120
#if DFS_FILESYSTEMS_MAX < 4
2221
#error "Please define DFS_FILESYSTEMS_MAX more than 4"
@@ -77,71 +76,49 @@ static int onboard_sdcard_mount(void)
7776
#endif
7877

7978
#ifdef BSP_USING_SPI_FLASH_LITTLEFS
79+
#include <fal.h>
80+
#define FS_PARTITION_NAME "spiflash0"
8081

81-
#define FS_PARTITION_NAME "filesystem"
82-
83-
static void spiflash_mount(void *parameter)
82+
static int onboard_spiflash_mount(void)
8483
{
8584
struct rt_device *mtd_dev = RT_NULL;
85+
8686
fal_init();
8787
mtd_dev = fal_mtd_nor_device_create(FS_PARTITION_NAME);
8888
if (!mtd_dev)
8989
{
9090
LOG_E("Can't create a mtd device on '%s' partition.", FS_PARTITION_NAME);
9191
}
92-
while (1)
93-
{
94-
rt_thread_mdelay(500);
95-
if(rt_device_find(FS_PARTITION_NAME) != RT_NULL)
96-
{
97-
if (dfs_mount(FS_PARTITION_NAME, "/flash", "lfs", 0, 0) == RT_EOK)
98-
{
99-
LOG_I("spi flash mount to '/flash'");
100-
break;
101-
}
102-
else
103-
{
104-
LOG_W("spi flash mount to '/flash' failed!");
105-
}
106-
}
107-
}
108-
}
109-
110-
static int onboard_spiflash_mount(void)
111-
{
112-
rt_thread_t tid;
11392

114-
if (dfs_mount(FS_PARTITION_NAME, "/flash", "lfs", 0, 0) == RT_EOK)
93+
if (dfs_mount(FS_PARTITION_NAME, "/spiflash", "lfs", 0, 0) == RT_EOK)
11594
{
116-
LOG_I("spi flash mount to '/flash'");
95+
LOG_I("spi flash mount to '/spiflash'");
11796
}
11897
else
11998
{
120-
tid = rt_thread_create("spiflash_mount", spiflash_mount, RT_NULL,
121-
1024, RT_THREAD_PRIORITY_MAX - 3, 20);
122-
if (tid != RT_NULL)
99+
dfs_mkfs("lfs", FS_PARTITION_NAME);
100+
if (dfs_mount(FS_PARTITION_NAME, "/spiflash", "lfs", 0, 0) == RT_EOK)
123101
{
124-
rt_thread_startup(tid);
102+
LOG_I("spi flash mount to '/spiflash'");
125103
}
126104
else
127105
{
128-
LOG_E("create spiflash_mount thread err!");
106+
LOG_E("spi flash failed to mount to '/spiflash'");
129107
}
130108
}
131109

132110
return RT_EOK;
133111
}
134112
#endif
135113

136-
137114
static const struct romfs_dirent _romfs_root[] =
138115
{
139116
#ifdef BSP_USING_SDCARD
140117
{ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0},
141118
#endif
142119

143120
#ifdef BSP_USING_SPI_FLASH_LITTLEFS
144-
{ROMFS_DIRENT_DIR, "flash", RT_NULL, 0},
121+
{ROMFS_DIRENT_DIR, "spiflash", RT_NULL, 0},
145122
#endif
146123
};
147124

bsp/stm32/stm32f407-atk-explorer/board/ports/fal_cfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern const struct fal_flash_dev stm32_onchip_flash_128k;
5252
#ifdef BSP_USING_SPI_FLASH_LITTLEFS
5353
#define FAL_PART_TABLE \
5454
{ \
55-
{FAL_PART_MAGIC_WROD, "filesystem",FAL_USING_NOR_FLASH_DEV_NAME, 0 , 16 * 1024 * 1024, 0}, \
55+
{FAL_PART_MAGIC_WROD, "spiflash0", FAL_USING_NOR_FLASH_DEV_NAME, 0 , 16 * 1024 * 1024, 0}, \
5656
}
5757
#else
5858
#define FAL_PART_TABLE \

0 commit comments

Comments
 (0)