Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逝缘~
rt-thread
提交
1f13b6d5
R
rt-thread
项目概览
逝缘~
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1f13b6d5
编写于
8月 05, 2021
作者:
mysterywolf
提交者:
GitHub
8月 05, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #52 from YJ98/STM32F407_add_littlefs
Stm32 f407 add littlefs
上级
054f6db3
addfbefe
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
98 addition
and
3 deletion
+98
-3
bsp/stm32/stm32f407-atk-explorer/board/Kconfig
bsp/stm32/stm32f407-atk-explorer/board/Kconfig
+11
-0
bsp/stm32/stm32f407-atk-explorer/board/ports/drv_filesystem.c
...stm32/stm32f407-atk-explorer/board/ports/drv_filesystem.c
+67
-1
bsp/stm32/stm32f407-atk-explorer/board/ports/fal_cfg.h
bsp/stm32/stm32f407-atk-explorer/board/ports/fal_cfg.h
+20
-2
未找到文件。
bsp/stm32/stm32f407-atk-explorer/board/Kconfig
浏览文件 @
1f13b6d5
...
...
@@ -91,6 +91,17 @@ menu "Onboard Peripheral Drivers"
range 0 24000000
depends on BSP_USING_SDCARD
default 1000000
config BSP_USING_SPI_FLASH_LITTLEFS
bool "Enable LITTLEFS"
select RT_USING_DFS
select RT_USING_DFS_ROMFS
select RT_USING_MTD_NOR
select BSP_USING_SPI_FLASH
select BSP_USING_FS
select RT_USING_SYSTEM_WORKQUEUE
default n
endmenu
endmenu
...
...
bsp/stm32/stm32f407-atk-explorer/board/ports/drv_filesystem.c
浏览文件 @
1f13b6d5
...
...
@@ -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
);
...
...
bsp/stm32/stm32f407-atk-explorer/board/ports/fal_cfg.h
浏览文件 @
1f13b6d5
...
...
@@ -14,10 +14,12 @@
#include <rtthread.h>
#include <board.h>
#ifdef BSP_USING_SPI_FLASH_LITTLEFS
extern
struct
fal_flash_dev
nor_flash0
;
#else
#define FLASH_SIZE_GRANULARITY_16K (4 * 16 * 1024)
#define FLASH_SIZE_GRANULARITY_64K (64 * 1024)
#define FLASH_SIZE_GRANULARITY_128K (7 * 128 * 1024)
#define STM32_FLASH_START_ADRESS_16K STM32_FLASH_START_ADRESS
#define STM32_FLASH_START_ADRESS_64K (STM32_FLASH_START_ADRESS_16K + FLASH_SIZE_GRANULARITY_16K)
#define STM32_FLASH_START_ADRESS_128K (STM32_FLASH_START_ADRESS_64K + FLASH_SIZE_GRANULARITY_64K)
...
...
@@ -25,24 +27,40 @@
extern
const
struct
fal_flash_dev
stm32_onchip_flash_16k
;
extern
const
struct
fal_flash_dev
stm32_onchip_flash_64k
;
extern
const
struct
fal_flash_dev
stm32_onchip_flash_128k
;
#endif
/* flash device table */
#ifdef BSP_USING_SPI_FLASH_LITTLEFS
#define FAL_FLASH_DEV_TABLE \
{ \
&nor_flash0, \
}
#else
#define FAL_FLASH_DEV_TABLE \
{ \
&stm32_onchip_flash_16k, \
&stm32_onchip_flash_64k, \
&stm32_onchip_flash_128k, \
}
#endif
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/* partition table */
#ifdef BSP_USING_SPI_FLASH_LITTLEFS
#define FAL_PART_TABLE \
{ \
{FAL_PART_MAGIC_WROD, "filesystem",FAL_USING_NOR_FLASH_DEV_NAME, 0 , 16 * 1024 * 1024, 0}, \
}
#else
#define FAL_PART_TABLE \
{ \
{FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_16k", 0 , FLASH_SIZE_GRANULARITY_16K , 0}, \
{FAL_PART_MAGIC_WROD, "param", "onchip_flash_64k", 0 , FLASH_SIZE_GRANULARITY_64K , 0}, \
{FAL_PART_MAGIC_WROD, "app", "onchip_flash_128k", 0 , FLASH_SIZE_GRANULARITY_128K, 0}, \
}
#endif
#endif
/* FAL_PART_HAS_TABLE_CFG */
#endif
/* _FAL_CFG_H_ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录