当前位置:网站首页>这才是优美的文件系统挂载方式,亲测有效
这才是优美的文件系统挂载方式,亲测有效
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()里面即可。
边栏推荐
- array
- Self created notes (unique in the whole network, continuously updated)
- Notes: the 11th and 12th generation mobile versions of Intel support the native thunderbolt4 interface, but the desktop version does not
- oracle11g数据库导入导出方法教程[通俗易懂]
- Half search, character array definition, character array uses D11
- 9项规定6个严禁!教育部、应急管理部联合印发《校外培训机构消防安全管理九项规定》
- fileinput.js php,fileinput
- Sword finger offer 21.57.58 I Double pointer (simple)
- 服务器创建虚拟环境跑代码
- Comparison of disk partition modes (MBR and GPT)
猜你喜欢

永远不要使用Redis过期监听实现定时任务!

Electron

Build your own PE manually from winpe of ADK

Sword finger offer 05.58 Ⅱ string

登录认证服务

Wechat applet Registration Guide

9項規定6個嚴禁!教育部、應急管理部聯合印發《校外培訓機構消防安全管理九項規定》

Gartner 2022 Top Strategic Technology Trends Report

Usage of unique function

Common operation and Principle Exploration of stream
随机推荐
BP neural network for prediction
idea快捷键
Educational Codeforces Round 117 (Rated for Div. 2)E. Messages
扩展-Hooks
(improved) bubble sorting and (improved) cocktail sorting
Sword finger offer 15.65.56 I 56Ⅱ. Bit operation (simple - medium)
Assert and constd13
[wc2006] director of water management
One article of the quantification framework backtrader read observer
Leaflet loading ArcGIS for server map layers
fileinput. js php,fileinput
量化框架backtrader之一文读懂observer观测器
"Scoi2016" delicious problem solution
vmware部分设置
Introduction to granular computing
Wechat applet Registration Guide
Sword finger offer 21.57.58 I Double pointer (simple)
New specification of risc-v chip architecture
Matplotlib common operations
[jsoi2015] string tree