当前位置:网站首页>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 .
边栏推荐
- Error when redis is started: could not create server TCP listening socket *: 6379: bind: address already in use - solution
- C language | Consortium
- Sword finger offer 09.30 Stack
- Understand the difference and use between jsonarray and jsonobject
- Intellij IDEA--格式化SQL文件的方法
- Correlation of XOR / and
- Combat readiness mathematical modeling 31 data interpolation and curve fitting 3
- Introduction to granular computing
- Usage of unique function
- SwiftUI找回丢失的列表视图(List)动画
猜你喜欢

How to mount cloud disks in ECS

Comparison of disk partition modes (MBR and GPT)

How to convert data in cell cell into data in matrix

Related knowledge of libsvm support vector machine

Sword finger offer 06.24.35 Linked list

Stream常用操作以及原理探索

How to personalize VIM editor format (DIY)

Codeforces Global Round 21A~D

常用控件及自定义控件

vmware部分设置
随机推荐
Sword finger offer 09.30 Stack
Summary of decimal point of amount and price at work and pit
2021-10-29 atcoder ABC157——B - Bingo
Leaflet load day map
Combat readiness mathematical modeling 32 correlation analysis 2
登录认证服务
扩展-Hooks
fileinput. js php,fileinput
MHA高可用配合及故障切换
Gartner 2022 Top Strategic Technology Trends Report
Matplotlib common operations
ArcGIS secondary development method - layer related operations (add, modify)
聊聊 RPA 方向的规划:简单有价值的事情长期坚持做
近期比较重要消息
Electron
Installation tutorial about origin2019
Eigen(3):error: ‘Eigen’ has not been declared
Electron
A remove the underline from the label
Excerpt from three body