当前位置:网站首页>这才是优美的文件系统挂载方式,亲测有效
这才是优美的文件系统挂载方式,亲测有效
2022-06-26 13:42:00 【RT-Thread物联网操作系统】
本文由RT-Thread论坛用户@mumumu原创发布:https://club.rt-thread.org/ask/article/573ddf0ba553a87c.html
按照手册与其它例子来挂载文件系统感觉不是很优美,研究了一下装载表的方式
然后在你的代码里(不限定具体文件,只要参与编译即可)加入以下代码:
//必要的头文件
#include <fal.h>
#include <dfs_fs.h>
#include <dfs_romfs.h>
#include <dfs_ramfs.h>
#include <dfs_posix.h>
rt_uint8_t rampool[1024];
#define FAL_PART_NAME "filesystem" //在fal_cfg.h中FAL_PART_TABLE定义
//ROMFS需要创建的目录,创建的目录位于/目录下给其它文件系统挂载
const struct romfs_dirent _root_dirent[] =
{
{
ROMFS_DIRENT_DIR, "ram", 0, 0},
{
ROMFS_DIRENT_DIR, "flash", 0, 0},
};
//自动挂载表
const struct dfs_mount_tbl mount_table[] =
{
{
RT_NULL, "/", "rom", 0, &(romfs_root)},//必须先创建rom文件系统,以提供后面的挂载目录
{
RT_NULL, "/ram", "ram", 0, (const void*)rampool},
{
FAL_PART_NAME, "/flash", "lfs", 0, 0},
{
0}
};
void norflash_init()
{
fal_init();
/* Create a block device on the file system partition of spi flash*/
struct rt_device *flash_dev = fal_mtd_nor_device_create(FAL_PART_NAME);
}
//上电自动初始化norflash创建,保证在norflash挂载前创建设备,其它需要前期初始化的也可放入此函数
INIT_COMPONENT_EXPORT(norflash_init);
以下是执行结果:
\ | /
- RT - Thread Operating System
/ | \ 4.0.5 build Jun 23 2022 16:33:28
2006 - 2021 Copyright by rt-thread team
lwIP-2.1.2 initialized!
[4] I/sal.skt: Socket Abstraction Layer initialize success.
[D/FAL] (fal_flash_init:47) Flash device | norflash0 | addr:
0x80000000 | len: 0x01000000 | blk_size: 0x00001000 |initialized finish.
m
[I/FAL] | name | flash_dev | offset | length |
m
[I/FAL] | app | norflash0 | 0x00000000 | 0x00400000 |
[I/FAL] | easyflash | norflash0 | 0x00400000 | 0x00300000 |
[I/FAL] | download | norflash0 | 0x00700000 | 0x00500000 |
[I/FAL] | filesystem | norflash0 | 0x00c00000 | 0x00400000 |
m
0m
[I/FAL] The FAL MTD NOR device (filesystem) created successfully
Not find the device(winUSB).Not find the device(i2c1).msh />[2098] I/NO_TAG
: PHY Status: Link up
[2098] I/NO_TAG: PHY Speed: 100Mbps
[2098] I/NO_TAG: PHY Duplex: full duplex
msh />mount
filesystem device mountpoint
---------- ------ ----------
devfs (NULL) /dev
rom (NULL) /
ram (NULL) /ram
lfs filesy /flash
msh />cd flash
msh /flash>ls
Directory /flash:
hello <DIR>
msh /flash>mkdir hs
msh /flash>ls
Directory /flash:
hello <DIR>
hs <DIR>
当然了必要的硬件与驱动需要打开,这里不再赘述。
需要加新的文件系统只用修改这个表即可,需要提前初始化的加到norflash_init()里面即可。
边栏推荐
- 秒懂JSONArray和JSONObject的区别和使用
- Pycharm远程连接服务器来跑代码
- RISC-V 芯片架构新规范
- Linear basis count (k large XOR sum)
- DOS command
- Sword finger offer 45.61 Sort (simple)
- Gartner 2022 Top Strategic Technology Trends Report
- Matlab programming related knowledge
- SwiftUI找回丢失的列表视图(List)动画
- How to call self written functions in MATLAB
猜你喜欢
Sword finger offer 09.30 Stack
STM32F1和GD32F1有什么区别?
One article of the quantification framework backtrader read observer
Codeforces Global Round 21A~D
Sword finger offer 21.57.58 I Double pointer (simple)
Intellij IDEA--格式化SQL文件的方法
Jianzhi offer 43.47.46.48 dynamic planning (medium)
A must for programmers, an artifact utools that can improve your work efficiency n times
从Celsius到三箭:加密百亿巨头们的多米诺,史诗级流动性的枯竭
ArcGIS batch export layer script
随机推荐
oracle11g数据库导入导出方法教程[通俗易懂]
Knowledge about adsorption
Server create virtual environment run code
Assert and constd13
C language ---getchar() and putchar()
Practice with the topic of bit operation force deduction
Correlation analysis related knowledge
Niuke challenge 53:c. strange magic array
《三体》摘录
Sword finger offer 18.22.25.52 Double pointer (simple)
Setup instance of layout manager login interface
vmware部分设置
Luogu p4145 seven minutes of God created questions 2 / Huashen travels around the world
fileinput.js php,fileinput
布局管理器~登录界面的搭建实例
Why is there always a space (63 or 2048 sectors) in front of the first partition when partitioning a disk
BP neural network for prediction
常用控件及自定义控件
Sword finger offer 10 Ⅰ 10Ⅱ. 63 dynamic planning (simple)
Svn commit error after deleting files locally