片上 flash 读写,这里介绍 FAL 的用法
准备工作
FAL 准备
board/Kconfig 添加
1 | config BSP_USING_ON_CHIP_FLASH |
启用 fal
1 | RT-Thread online packages ---> |
on_chip_flash 目录复制到你的 applications 目录
SConscript 添加如下
1 | CPPPATH += [cwd + '/on_chip_flash'] |
测试命令
1 | fal probe xxx |
lfs 准备
scons --menuconfig 选中
1 | RT-Thread Components ---> |
1 | RT-Thread Components ---> |
1 | RT-Thread Components ---> |
1 | RT-Thread online packages ---> |
需要注意的地方
1 | 需要根据你需要的大小修改rtt自带驱动里面的`const struct fal_flash_dev stm32_onchip_flash_xxk` |
romfs 准备
使用场景:如果需要挂载多个 fs,可以使用 romfs 先创建几个文件夹,然后启动以后把几个 fs 分别挂载到不同的目录
1 | RT-Thread Components ---> |
注意,需要使用下面的命令重新生成 romfs 的源码
1 | python2 ./rt-thread/tools/mkromfs.py 你的文件目录 ./rt-thread/components/dfs/filesystems/romfs/romfs.c |
代码
elm_demo.c
1 |
|
fal_cfg.h
1 |
|
fal_demo.c
1 |
|
lfs_demo.c
1 |
|
romfs_init.c
1 |
|
注意
已知的问题:在某些板子上,fal 和 lfs 不兼容,同时启用以后,会导致 fal 的 erase 挂掉,当然 lfs 的格式化也会挂掉
elm 貌似格式化会报错,不管了