This post was last edited by jj1989 on 2019-4-27 18:47
【RT-Thread Reading Notes】Virtual File System## Preface I have been paying attention to the RT-Thread embedded real-time operating system for a long time, and recently I have applied it to the project. From the actual use point of view, the real-time performance and stability are good, and it is also convenient to use. The official provides a large number of routines and Chinese materials to facilitate everyone to learn. If you want to learn an embedded operating system, RT-Thread is highly recommended. ## Views on operating systems In ordinary projects, many friends like bare metal programming, that is, not using an operating system, which I call naked running here. The reason for this choice is that the code logic is not complicated, the system is relatively simple, and naked running can be easily handled. Second, compared with the operating system, its code is more streamlined and the execution efficiency is higher. Third, I am worried about the reliability of the system, and even if there is a problem with naked running, it is easy to find and solve. By the way, I have had some similar ideas before. But as the complexity of the project system becomes higher and higher. In the case of implementing business logic and ensuring real-time performance, bare metal programming seems a bit inadequate. So I started looking for a real-time operating system. At first, I came into contact with FreeRTOS, which has a large number of users, and then I came across RT-Thread. Both have their own advantages. The reason for choosing the latter is that it has the same coding style as Linux, and secondly, the official provides a large number of components, such as the virtual file system that will be introduced in this article. It is very convenient to use and cannot be too friendly to developers. ## Introduction to DFS The introduction to Device File System-Device Virtual File System has been introduced in detail in the book. Here I will briefly summarize the content of the book. The structure of DFS is as follows
It is mainly divided into POSIX interface layer, virtual file system layer and device abstraction layer. As can be seen from the figure, DFS is an abstraction of each specific file system. When using DFS, users do not need to care about the differences between different file system types. ### Use of DFS To use the file system in RT-Thread, you need to go through the following steps. First, call the dfs_init() function to initialize DFS, and use the dfs_register() function to register the newly initialized file system to DFS. Then register the storage device, such as SPI Flash, as a block device for subsequent mounting. Then call dfs_mkfs() to format the file system. Finally, call dfs_mount() to mount the file system. The file system operation mainly involves file operations and directory operations. File operations mainly involve the following operations: Open and close files Read and write data Rename Get file status Delete files Synchronize file data to storage devices Query file system related information Monitor I/O device status Directory operations mainly involve the following operations: Create and delete directories Open and close directories Read directories Get the read position of directory streams Set the position of the next directory read Reset the read directory position to the beginning For detailed descriptions of each operation method, please see the official RT-Thread API Reference Manual. ## Summary This article first talked about why we switched from running naked to using an operating system, and then selected Chapter 15-Virtual File System in the book "Design and Implementation of Embedded Real-Time Operating System RT-Thread" to make a brief summary of its content. If there is anything wrong in the article, please correct it.
This content is originally created by EEWORLD forum user jj1989. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source.
Because the file system is used, the bad block management problem must be considered. If this problem is not handled well, the product will be a mess. I wonder if RT-Thread has bad block management for FLASH
Details
Published on 2019-4-28 10:03
Haha, how do you know? RT-Thread's components are well made and easy to use, not as complicated as you might think.
Details
Published on 2019-4-28 08:57
Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
Because the file system is used, the bad block management problem must be considered. If this problem is not handled properly, the product will be ruined. I wonder if RT-Thread has bad block management for FLASH?
Details
Published on 2019-4-28 10:03
jj1989 posted on 2019-4-28 08:57 Haha, how do you know? RT-Thread's components are very well made and easy to use, not as complicated as imagined.
Because the file system is used, the bad block management problem must be considered. If this problem is not handled well, the product will be a mess. I wonder if RT-Thread has bad block management for FLASH