当前位置:网站首页>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 .
边栏推荐
- Hard (magnetic) disk (I)
- Stream常用操作以及原理探索
- From Celsius to the three arrows: encrypting the domino of the ten billion giants, and drying up the epic liquidity
- Oracle ASMM and AMM
- BM3D in popular language
- Win10 home vs pro vs enterprise vs enterprise LTSC
- C language | Consortium
- Hard (magnetic) disk (II)
- Chinese output of PostGIS console is garbled
- C language | the difference between heap and stack
猜你喜欢
随机推荐
Sword finger offer 21.57.58 I Double pointer (simple)
备战数学建模32-相关性分析2
1075 pat judge (25 points)
FreeFileSync 文件夹比较与同步软件
H5关闭当前页面,包括微信浏览器(附源码)
Hard (magnetic) disk (II)
Record: why is there no lightning 4 interface graphics card docking station and mobile hard disk?
网上股票开户安不安全?谁给回答一下
Server create virtual environment run code
Experience sharing of mathematical modeling: comparison between China and USA / reference for topic selection / common skills
9項規定6個嚴禁!教育部、應急管理部聯合印發《校外培訓機構消防安全管理九項規定》
[wc2006] director of water management
ArcGIS secondary development -- arcpy batch automatic map publishing service
Stream常用操作以及原理探索
Sectigo的IP证书申请流程
The annual salary of 500000 is one line, and the annual salary of 1million is another line
【async/await】--异步编程最终解决方案
DOS command
这才是优美的文件系统挂载方式,亲测有效
K gold Chef (two conditions, two points and difference)








