当前位置:网站首页>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卡没有挂载成功,多次复位,重新下载程序,有时是这样。
边栏推荐
- Industry insight | is speech recognition really beyond human ears?
- 决策树与随机森林学习笔记(1)
- Data Lake (XVII): Flink and iceberg integrate datastream API operations
- Redis5种数据结构解析
- Redis经典面试题总结
- Redis implements distributed locks
- 20 soul chicken soup beautiful sentences, sentence by sentence warm heart!
- Redis persistence mechanism
- 在线问题反馈模块实战(十六):实现查详情功能
- Uniapp——拨打电话、发送短信
猜你喜欢

静态博客搭建工具汇总

bp svm的缺陷检测 树叶缺陷 叶片缺陷检测的系统设计

Analysis of redis network model
![[2022 Niuke Game 2 J question link with arithmetic progress] three part set three part / three part extreme value / linear equation fitting least square method](/img/4f/56033956739971d821637ae54be1bd.png)
[2022 Niuke Game 2 J question link with arithmetic progress] three part set three part / three part extreme value / linear equation fitting least square method

Stm32f407 ------- DSP learning

Kubernetes -- Introduction

并发编程面试题总结

Scheme sharing | experts gather to jointly explore accent AI speech recognition

ECCV 2022 | open source for generative knowledge distillation of classification, detection and segmentation

Engineering Geology Practice - engineering geology problem set
随机推荐
[acwing 1064 little king] shaped pressure DP
My approval of OA project (meeting inquiry & meeting signature)
Kubernetes -- Introduction
Redis经典面试题总结
阿里云国际版邮件服务套餐购买流程
Uniapp——拨打电话、发送短信
Redis5种数据结构解析
上位机与MES对接的几种方式
What are the fragments of MySQL
[acwing 327. corn field] shaped pressure DP
Leetcode 208. implement trie (prefix tree) (2022.07.27)
QFileDevice、QFile、QSaveFile、QTemporaryFile
Talk about the speech synthesis function of Baidu University of science and technology news Feiyun Zhisheng
傅里叶级数
ssm整合(整合配置)
Win11输入法的选字框不见了怎么办?
Brush questions every day to consolidate knowledge
C WinForm development: how to add pictures to project resources
Shell:一键部署pxe
20条心灵鸡汤唯美句子,句句温情暖心!
