attention,Star publicnumber, Don’t miss great content
Source: Internet
Editing: strongerHuang
For many IoT devices, having a small and flexible file system is essential.
There are not many file systems running on the MCU. Most people should be aware of the FatFS file system. Today I will tell you about the contents of FatFS and LittleFS, and some of the differences between them.
One, the file system FatFS
FatFs is a universal file system (FAT/exFAT) module used to implement FAT file system in small embedded systems.
URL:
http://elm-chan.org/fsw/ff/00index_e.html
The writing of FatFs components follows ANSI C (C89) and is completely separated from the disk I/O layer, so it does not depend on the hardware platform. It can be embedded in microcontrollers with limited resources, such as 8051, PIC, AVR, ARM, Z80, RX, etc., without any modification.
---From Baidu Encyclopedia
feature
a.DOS/Windows compatible FAT/exFAT file system.
b. Platform is independent and easy to transplant.
c. The space occupied by the program code and work area is very small.
d. Support the following various configuration options:
Long file name in ANSI/OEM or Unicode.
The exFAT file system, 64-bit LBA and GPT can store large amounts of data.
Thread safety of RTOS.
Multiple volumes (physical drives and partitions).
Variable sector size.
Multiple code pages, including DBCS.
Read only, optional API, I/O buffer, etc...
If you know how to use STM32CubeMX, it is very easy to use FatFS. You can "turn" STM32 into a USB flash drive in a few easy steps.
Second, the file system Littlefs
There are relatively few people who know the Littlefs file system, but most people who have used the Mbed OS system should know.
Mbed OS is a set of free, open-source and open-source embedded operating systems developed by Arm for the Cortex-M series of processors for IoT, specifically designed for the "things" in the Internet of Things.
And Littlefs justPart of the content of Mbed is as follows:
Source address:
https://github.com/armmbed/mbed-littlefs
Littlefs features:
Small resource occupation: IoT devices are limited by ROM and RAM.
Power failure recovery capability: The file system is required to be consistent and refresh data to the underlying storage.
Average wear and tear: Generally, storage supports a limited number of erases per block, so using the entire storage device is very important for reliability.
The usage is also quite simple, see the official routine:
#include "LittleFileSystem2.h"
#include "SPIFBlockDevice.h"
// Physical block device, can be any device that supports the BlockDevice API
SPIFBlockDevice bd(PTE2, PTE4, PTE1, PTE5);
// Storage for the littlefs
LittleFileSystem2 fs("fs");
// Entry point
int main() {
// Mount the filesystem
int err = fs.mount(&bd);
if (err) {
// Reformat if we can't mount the filesystem,
// this should only happen on the first boot
LittleFileSystem2::format(&bd);
fs.mount(&bd);
}
// Read the boot count
uint32_t boot_count = 0;
FILE *f = fopen("/fs/boot_count", "r+");
if (!f) {
// Create the file if it doesn't exist
f = fopen("/fs/boot_count", "w+");
}
fread(&boot_count, sizeof(boot_count), 1, f);
// Update the boot count
boot_count += 1;
rewind(f);
fwrite(&boot_count, sizeof(boot_count), 1, f);
// Remember that storage may not be updated until the file
// is closed successfully
fclose(f);
// Release any resources we were using
fs.unmount();
// Print the boot count
printf("boot_count: %ld\n", boot_count);
}
Three, file system comparison
Every product has its value,The same is true for file systems, each with its own advantages and disadvantages. Here are a few simple differences between them.
1. Resource RAM/ROM size
Littlefs is a high integrity embedded file system in Mbed OS, optimized for use with MCUs with limited RAM and ROM.
LittlefsThe highly integrated embedded file system uses 13K ROM less than FAT and less than 4K RAM.
2. Power loss recovery ability
Littlefs has a strong copy-on-write guarantee, and the storage on the disk is always kept in a valid state. A system that may have random power failures is suitable for this file system.
3. Wear leveling
Most memory chips used in embedded devices support a limited erase set per sector. If there is no equalization, the life of the embedded device may be affected.
Reference source:
https://os.mbed.com/blog/entry/littlefs-high-integrity-embedded-fs/
Disclaimer: The source network of this article, the copyright belongs to the original author. If the copyright issue of the work is involved, please contact me to delete it.
‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧ END ‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧
Recommended reading:
Featured Summary | Directory | Search
Why does CPU pipeline improve code execution efficiency?
The routine of counterfeit chips, how to identify counterfeit materials?
Follow the WeChat public account "strongerHuang", reply "1024" in the background to view more content, reply "Add group" to join the technical exchange group according to the rules.
Long press to follow the official account included in the picture
the difference: 1. Essentially: int is one of the eight basic data types, and integer is a packaging class of int 2. Use: integer must be instantiated before it can be used, int is not required 3. Mem...
"==" compares the content and address of the string, equals compares the content of the string. Example 1: Shallow copy public class Test { public static void main(String[] args) { String g=...
The main difference between the two: 1. The default engine: Before MySQL5.5, MyISAM was the default engine of MySQL; after MySQL5.5, InnoDB was the default engine of MySQL. 2. Whether to support row-l...
== compares the address values of two objects, equals compares the contents of the two objects. Compare str1 and str2: Summary: In some cases, it can be common, but in some cases, you need to pay at...
Comparison between variables Comparison of int, Integer, string result: Compare of int a==b? false (a+b)==c? true c==d? true ------------------------------------ Compare of integer t1==t2? false (t1+t...
1. Definition introduction (1).XML definition Extensible Markup Language (XML) is a markup language used to mark electronic files to make them structured. It can be used to mark data and define data t...
“==": The numerical comparison is made, if the object is used for more comparisonTwo memory address values equals : A comparative method provided by the class, you can do it directlyJudgmen...
I probably understand todaypartition byandgroup byDifferential contact. 1. Group by is a group function,Partition by is an analysis function(Then likeSUM (), etc.); 2. In the execution order, The foll...
"==" operator role 1, for comparison of basic data types 2. Determine if the reference points to the same block address of the heap memory. Equals location: In the Object class, and Object i...
What is the cloud? Cloud technology refers to unifying hardware, software, network and other resources in a wide area network or a local area network to realize data.Calculation,StorageProcessing ands...