当前位置:网站首页>这才是优美的文件系统挂载方式,亲测有效
这才是优美的文件系统挂载方式,亲测有效
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()里面即可。
边栏推荐
- How to check if a text field is empty or not in swift
- MHA高可用配合及故障切换
- Common operation and Principle Exploration of stream
- Experience sharing of mathematical modeling: comparison between China and USA / reference for topic selection / common skills
- Pychar remotely connects to the server to run code
- 扩展-Hooks
- Why is there always a space (63 or 2048 sectors) in front of the first partition when partitioning a disk
- Chinese output of PostGIS console is garbled
- oracle11g数据库导入导出方法教程[通俗易懂]
- 1075 pat judge (25 points)
猜你喜欢

Sword finger offer 06.24.35 Linked list

Electron

Related knowledge of libsvm support vector machine

Common operation and Principle Exploration of stream

备战数学建模32-相关性分析2

Freefilesync folder comparison and synchronization software

Electron

Pointer

Sword finger offer 18.22.25.52 Double pointer (simple)

Correlation of XOR / and
随机推荐
1075 pat judge (25 points)
Setup instance of layout manager login interface
在线牛人博主
Matplotlib common operations
Why is there always a space (63 or 2048 sectors) in front of the first partition when partitioning a disk
量化框架backtrader之一文读懂observer观测器
Chinese output of PostGIS console is garbled
【async/await】--异步编程最终解决方案
MySQL | basic commands
ThreadLocal巨坑!内存泄露只是小儿科...
Online bull Blogger
PostGIS create spatial database
Common evaluation indexes of classification model -- confusion matrix and ROC curve
Can wptx64 be uninstalled_ Which software of win10 can be uninstalled
From Celsius to the three arrows: encrypting the domino of the ten billion giants, and drying up the epic liquidity
How to personalize VIM editor format (DIY)
Eigen(3):error: ‘Eigen’ has not been declared
Hard (magnetic) disk (I)
Two dimensional DFS
First k large XOR value problem