当前位置:网站首页>STM32 RT-Thread虚拟文件系统挂载操作
STM32 RT-Thread虚拟文件系统挂载操作
2022-07-28 02:53:00 【数与形】
有关RT-Thread虚拟文件系统的相关介绍,我这里就不再赘述,需要了解的自行查看RT-Thread 文档中心 -->组件–>虚拟文件系统RT-Thread 文档中心我这里只讲如果配置以及挂载和最终的操作,具体的一些文件相关的API自行查看文档。
具体步骤
步骤一
- 首先你要有一个bsp文件,如果没有就不用往下看了步骤二
- 打开 stm32cubemx来开启配置

- 2.
这时候只是配置了相关设置,并没有把sd添加到设备中
步骤三,编写Kconfig来添加sd设备,参照rtthread源码bsp中stm32 中任意一个board中的kconfig,将这两段代码加入Kconfig(board --> Kconfig)
步骤四:打开menuconfig,开启sd设备驱动

3.
4 .打开虚拟文件系统dfs
6.重新编译工程,并且下载到开发板
步骤五:
这里就可以看到已经有sd设备注册了
步骤六:挂载文件系统到sd设备,注意添加相关路径以及头文件
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
/* defined the LED0 pin: PB1 */
#define LED0_PIN GET_PIN(B, 0)
static rt_device_t sd_card = RT_NULL;
int main(void)
{
int count = 1;
/* set LED0 pin mode to output */
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
// while (count++)
// {
// rt_pin_write(LED0_PIN, PIN_HIGH);
// rt_thread_mdelay(100);
// rt_pin_write(LED0_PIN, PIN_LOW);
// rt_thread_mdelay(100);
// }
//虚拟文件系统测
rt_thread_mdelay(5000); //这个延时是保证sd卡有个初始时间
sd_card = rt_device_find("sd0");
if(sd_card != RT_NULL)
{
rt_kprintf("sd card find ok\n");
#if 0
if(0 == dfs_mkfs("elm","sd0")) //格式化文件系统
{
rt_kprintf("格式化文件系统成功\n");
}
else
{
rt_kprintf("格式化文件系统失败\n");
}
#endif
if (0 == dfs_mount("sd0","/","elm",0,0)) //挂载文件系统
{
rt_kprintf("文件系统挂载成功\n");
}
else
{
rt_kprintf("文件系统挂载失败\n");
}
}
else
{
rt_kprintf("sd card find err\n");
}
rt_thread_mdelay(100);
return RT_EOK;
}
步骤七:程序下载到开发板,查看设备是否成功挂载
显示文件挂载成功,并且出现文件的相关操作finsh指令,这时候就可以调用虚拟文件相关的API来实现虚拟文件系统的操作。
- 注意,如果sd卡没有挂载成功,多次复位,重新下载程序,有时是这样。
边栏推荐
- 嵌入式数据库--SQLite
- Brush questions every day to consolidate knowledge
- Contour detection based on OpenCV (3)
- [uni app advanced practice] take you hand-in-hand to learn the development of a purely practical complex project 2/100
- The object array is converted to string and then separated by strings, including the competition to select the children of a field, or the sum,
- 【Codeforces Round #806 (Div. 4)(A~F)】
- Thread Foundation
- STM32之IO模拟串口篇
- 【2022 牛客第二场J题 Link with Arithmetic Progression】三分套三分/三分极值/线性方程拟合最小二乘法
- 数字孪生技术驱动智能工厂减负赋能提升运维效益
猜你喜欢

关于权重衰退和丢弃法

C#实现弹出一个对话框的同时,后面的form不可用

Detailed tutorial of one click reinstallation of win7 system

Summary of static blog building tools

Summary of redis classic interview questions

工程电磁场复习基本知识点

Win11怎么显示固定应用?

Review basic knowledge points of engineering electromagnetic field

Redis 5 kinds of data structure analysis

SSM integration (integrated configuration)
随机推荐
Leetcode 208. implement trie (prefix tree) (2022.07.27)
The test post changes jobs repeatedly, jumping and jumping, and then it disappears
随机森林与集成方法学习笔记
动画(animation)
vba批量读取sql的create文来创建表
QFileDevice、QFile、QSaveFile、QTemporaryFile
Redis 5 kinds of data structure analysis
蓝桥杯:第九届—“彩灯控制器”
Yiwen teaches you to distinguish between continuous integration, continuous delivery and continuous deployment
exness:日本物价上涨收入下降,英镑/日元突破 165
stm32F407-------DSP学习
工程地质实习-工程地质 题集
Is the securities account given by qiniu safe? Can qiniu open an account and buy funds
Redis内存回收
Embedded database -- SQLite
【AcWing 327. 玉米田】状压dp
版本兼容的问题
What are the fragments of MySQL
stm32F407-------FPU学习
Redis memory recycling
