当前位置:网站首页>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 .
边栏推荐
猜你喜欢

Pycharm远程连接服务器来跑代码

New specification of risc-v chip architecture

从Celsius到三箭:加密百亿巨头们的多米诺,史诗级流动性的枯竭

Combat readiness mathematical modeling 32 correlation analysis 2

NAACL2022:(代码实践)好的视觉引导促进更好的特征提取,多模态命名实体识别(附源代码下载)...

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

使用宝塔面板部署flask环境

FreeFileSync 文件夹比较与同步软件

Freefilesync folder comparison and synchronization software

'教练,我想打篮球!' —— 给做系统的同学们准备的 AI 学习系列小册
随机推荐
MHA高可用配合及故障切换
STM32F1和GD32F1有什么区别?
idea快捷键
VMware partial settings
Atcoder bit operation & Conclusion + formula derivation
Electron
ArcGIS secondary development - arcpy delete layer
秒懂JSONArray和JSONObject的区别和使用
印尼投资部长:鸿海考虑在其新首都建立电动公交系统、城市物联网
ThreadLocal giant pit! Memory leaks are just Pediatrics
Online bull Blogger
Experience sharing of mathematical modeling: comparison between China and USA / reference for topic selection / common skills
网上股票开户安不安全?谁给回答一下
Codeforces Global Round 21A~D
A remove the underline from the label
ArcGIS batch export layer script
Sword finger offer 15.65.56 I 56Ⅱ. Bit operation (simple - medium)
Server create virtual environment run code
The annual salary of 500000 is one line, and the annual salary of 1million is another line
C language | file operation and error prone points