当前位置:网站首页>This is the graceful file system mounting method, which is effective through personal testing
This is the graceful file system mounting method, which is effective through personal testing
2022-06-26 14:38:00 【RT thread IOT operating system】
This paper is written by RT-Thread Forum user @mumumu Original release :https://club.rt-thread.org/ask/article/573ddf0ba553a87c.html
Mounting the file system according to the manual and other examples doesn't feel very beautiful , I studied the way to load tables 
And then in your code ( There are no specific documents , Just participate in the compilation ) Add the following code :
// Necessary header files
#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" // stay fal_cfg.h in FAL_PART_TABLE Definition
//ROMFS The directory you need to create , Created directory at / Directory to other file systems
const struct romfs_dirent _root_dirent[] =
{
{
ROMFS_DIRENT_DIR, "ram", 0, 0},
{
ROMFS_DIRENT_DIR, "flash", 0, 0},
};
// Auto mount table
const struct dfs_mount_tbl mount_table[] =
{
{
RT_NULL, "/", "rom", 0, &(romfs_root)},// Must be created first rom file system , To provide the following mount directory
{
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);
}
// Power on automatic initialization norflash establish , Guaranteed at norflash Create a device before mounting , Other items requiring early initialization can also be put into this function
INIT_COMPONENT_EXPORT(norflash_init);
Here are the results :
\ | /
- 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>
Of course, the necessary hardware and drivers need to be turned on , No more details here .
To add a new file system, just modify this table , Those that need to be initialized in advance are added to norflash_init() Just inside .
边栏推荐
- Introduction to granular computing
- Codeforces Round #765 (Div. 2) D. Binary Spiders
- Sword finger offer 10 Ⅰ 10Ⅱ. 63 dynamic planning (simple)
- Hard (magnetic) disk (II)
- 备战数学建模32-相关性分析2
- Win10 home vs pro vs enterprise vs enterprise LTSC
- Usage of unique function
- DOS command
- Setup instance of layout manager login interface
- wptx64能卸载吗_win10自带的软件哪些可以卸载
猜你喜欢

登录认证服务

Sword finger offer 09.30 Stack

Codeforces Global Round 21A~D

Electron

PostGIS create spatial database

数学建模经验分享:国赛美赛对比/选题参考/常用技巧

Matplotlib common operations

9 articles, 6 interdits! Le Ministère de l'éducation et le Ministère de la gestion des urgences publient et publient conjointement neuf règlements sur la gestion de la sécurité incendie dans les établ

The annual salary of 500000 is one line, and the annual salary of 1million is another line

Server create virtual environment run code
随机推荐
Oracle11g database import and export method tutorial [easy to understand]
ArcGIS secondary development - arcpy delete layer
工作上对金额价格类小数点的总结以及坑
ArcGIS batch export layer script
大学生值得珍藏的实用网站推荐
量化框架backtrader之一文读懂observer观测器
VIM auto fill auto indent explanation
A solution to the problem that the display of newff function in neural network cannot be converted from double to struct
布局管理器~登录界面的搭建实例
聊聊 RPA 方向的规划:简单有价值的事情长期坚持做
K gold Chef (two conditions, two points and difference)
Lucky numbers in the matrix
印尼投资部长:鸿海考虑在其新首都建立电动公交系统、城市物联网
Error when redis is started: could not create server TCP listening socket *: 6379: bind: address already in use - solution
Record: why is there no lightning 4 interface graphics card docking station and mobile hard disk?
Setup instance of layout manager login interface
这才是优美的文件系统挂载方式,亲测有效
Heap optimization dijkstra/hash table storage node number
《三体》摘录
C language | file operation and error prone points