当前位置:网站首页>STM32 RT thread virtual file system mount operation
STM32 RT thread virtual file system mount operation
2022-07-28 03:34:00 【Number and form】
of RT-Thread Introduction to virtual file system , I won't go into details here , Self check what you need to know RT-Thread Document center --> Components –> Virtual file system RT-Thread Document center I will only talk about the configuration, mounting and final operation , Specific documents related API View documents by yourself .
Specific steps
Step one
- First you need to have a bsp file , If there is no need to look downStep two
- open stm32cubemx To enable configuration

- 2.
At this time, only relevant settings are configured , Not yet sd Add to device
Step three , To write Kconfig To add sd equipment , reference rtthread Source code bsp in stm32 Any one of board Medium kconfig, Add these two pieces of code Kconfig(board --> Kconfig)
Step four : open menuconfig, Turn on sd Device drivers

3.
4 . Open the virtual file system dfs
6. Recompile project , And download to the development board 
Step five :
Here you can see that there are already sd Device registered 
Step six : Mount the file system to sd equipment , Pay attention to adding relevant paths and header files
#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);
// }
// Virtual file system test
rt_thread_mdelay(5000); // This delay is guaranteed sd The card has an initial time
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")) // Format file system
{
rt_kprintf(" Format file system successfully \n");
}
else
{
rt_kprintf(" Failed to format file system \n");
}
#endif
if (0 == dfs_mount("sd0","/","elm",0,0)) // Mount file system
{
rt_kprintf(" File system mounted successfully \n");
}
else
{
rt_kprintf(" File system mount failed \n");
}
}
else
{
rt_kprintf("sd card find err\n");
}
rt_thread_mdelay(100);
return RT_EOK;
}
Step seven : Download the program to the development board , Check whether the device is successfully mounted 
It shows that the file is successfully mounted , And the relevant operations of the file appear finsh Instructions , At this time, you can call the virtual file related API To realize the operation of virtual file system .
- Be careful , If sd The card was not successfully attached , Multiple reset , Download the program again , Sometimes it is .
边栏推荐
- 颜色的识别方法和探索 基于matlab
- Hotel VR panoramic display shooting provides more opportunities for cooperation and negotiation
- The wonderful use of asemi rectifier bridge GBPC3510 in DC brush motor
- Golang gets the tag of the loop nested structure
- Redis implements distributed locks
- Redis persistence mechanism
- bp svm的缺陷检测 树叶缺陷 叶片缺陷检测的系统设计
- Version compatibility issues
- 如何解决mysql深分页问题
- ThreadLocal使用场景
猜你喜欢

Log analysis tool (Splunk)

Summary of redis classic interview questions

MySQL事务的ACID特性及并发问题实例分析

Practice of online problem feedback module (16): realize the function of checking details

8000字讲透OBSA原理与应用实践

光年(Light Year Admin)后台管理系统模板

如何解决mysql深分页问题

超好看的Nteam官网PHP程序源码

Summary of concurrent programming interview questions

53. Maximum subarray maximum subarray sum
随机推荐
2022-07-27: Xiao Hong got an array arr with a length of N. she is going to modify it only once. She can modify any number arr[i] in the array to a positive number not greater than P (the modified numb
Leetcode 29th day
光年(Light Year Admin)后台管理系统模板
Win11怎么显示固定应用?
Softek Barcode Reader 9.1.5
Animation
Shell:资源监控脚本和高负载报警
Hotel VR panoramic display shooting provides more opportunities for cooperation and negotiation
C -- switch case statement
Shell:一键部署pxe
4天Excel实战训练营,0.01元特惠仅三天,赠200套学习资料包
[download file] uniapp develops small programs, downloads files and saves them locally
[5g NR] RRC reject analysis
Log analysis tool (Splunk)
C language to achieve a dynamic version of the address book
响应式高端网站模板源码图库素材资源下载平台源码
MySQL stored procedures use cursors to synchronize data between two tables
Four methods of closing forms in C #
Response to questions about the balanced beacon group of Hubei University of Arts and Sciences
2022最新Android Handler相关面试题总结
