Embedded file System detailed

Source: Internet
Author: User
Tags garbage collection

In the embedded field, Flash is a kind of common storage device, flash flash memory as the main storage device of embedded system has its own characteristics. Fash write operation can only change the corresponding position of 1 to 0, and not 0 to 1, and erase fash is to restore the contents of the corresponding storage block to 1. Therefore, in general, when writing to Fash, the corresponding storage interval needs to be erased, and this erasure is done in blocks (Bock). Flash memory mainly has nor and NAND two kinds of technology. Because flash memory has a limited number of erase writes, NAND Flash has a special hardware interface and read-write timing, so there is a file system specifically for Flash. More commonly used are jffs2,yaffs2,logfs,ubifs. Traditional file systems such as EXT2, EXT3, NTFS, etc. are designed for mechanical hard drives, and are used as fash file systems for many drawbacks.


Under Embedded Linux, MTD (memorytechnology device, storage technology equipment) provides a unified abstraction interface between the underlying hardware (flash memory) and the upper layer (file system), that is, the Flash file system is based on the MTD driver layer. The main advantage of using the MTD driver is that it is specifically designed for a variety of nonvolatile memory (mainly flash), so it has better support, management, and sector-based erasure, read/write interface for Flash. In addition, a flash chip can be divided into multiple partitions, each partition can be different file system, two flash chips can also be combined into a single partition, using a file system. That is, the file system is for the memory partition, not the memory chip. According to the different storage devices, the embedded file system can be divided into three categories: Flash-based file system, memory-based file system, network-based file system.

(a) Flash-based file system

(1) jffs2:journalling Flash FileSystem jffs file system was originally developed by the Swedish Axiscommunications company based on the Linux2.0 kernel for embedded systems.
JFFS2 (journalling flash FileSystem log Flash file System version 2) is RedHat's improved file system based on Woodhouse and is the actual file system for the original flash chip of the micro embedded device. The JFFS2 file system is a log-structured, read-write file system, so JFFS2 can also be used in Linux,uclinux. The advantages and disadvantages of JFFS2 are as follows:
Advantages:
A compressed file format is used. The most important feature is the read-write operation.
Disadvantages:

JFFS2 file system mounts require scanning of the entire JFFS2 file system, so when the JFFS2 file system partition grows, the mount time is correspondingly longer. Using the JFFS2 format may result in a small amount of wasted Flash space. This is largely due to the excessive overhead of log files and the useless storage units used to reclaim the system, which is roughly a number of data segments wasted. Another drawback of the JFFS2 is that when the file system is full or nearly full, the JFFS2 runs faster. This is because of garbage collection problems. Note:

(1) The log structure file system does not take the local update, but instead uses the asynchronous update method, that is, when a block of data needs to be updated, a new block is found to write the new data, and then erase the old block.     However, the old data is not erased immediately in Flash, but is saved as a log as a history, which lays the groundwork for the file system's recovery operations. (2) is not suitable for NAND flash memory mainly because the capacity of the NAND flash memory is generally large, so that jffs to maintain the log node occupies a rapid increase in memory space, in addition to jffs file system in the mount need to scan the entire Flash content, to find all the log nodes, establish the file structure, Large-capacity NAND flash memory can be time consuming.

(2) Yaffs:yet another Flash File System
The YAFFS/YAFFS2 is an embedded file system specifically designed for NAND Flash. It is a log-structured file system that provides loss balancing and power-down protection to effectively avoid accidental power-down effects on file system consistency and integrity. Compared to JFFS2, it reduces functionality (for example, data compression is not supported), so it is faster, has a short mount time, and uses less memory. It is a cross-platform file system, in addition to Linux and Ecos, also supports wince, PSOs and THREADX.
The advantages and disadvantages of YAFFS/YAFFS2 are as follows:
Advantages:
Specifically for NAND Flash, the software structure is optimized and fast.
Use the spare area region of the hardware to store the file organization information, which only needs to scan the organization information and start faster.
Using multi-strategy garbage collection algorithm can improve the efficiency and fairness of garbage collection, and achieve the goal of loss balance.
Disadvantages:

No compressed file format is used. The YAFFS2 image file is larger than the JFFS2 image file when it contains the same content.Note:
The main difference between yaffs and YAFFS2 is that the former only supports small page (Bytes) NAND flash, while the latter supports large page (2KB) NAND flash memory. At the same time, YAFFS2 has a significant increase in memory footprint, garbage collection speed, read/write speed, and so on. Compared to JFFS2, it reduces functionality (for example, data compression is not supported), so it is faster, has a short mount time, and uses less memory.

(3) cramfs:compressed ROM File System
Cramfs is the founder of Linux Linustorvalds, a read-only compressed file system involved in the development. It is also based on the MTD driver. In the Cramfs file system, each page (4KB) is individually compressed and can be accessed randomly, with a compression ratio of up to 2:1, which saves a large amount of flash storage space for the embedded system, allowing the system to store the same files through lower volume flash, thereby reducing system costs.
The Cramfs file system is stored in compression, uncompressed at run time, so the application is not supported to run in XIP mode, and all application requirements are copied into RAM to run, but this does not mean that the RAM space is a little larger than the RAMFS requirement, Because Cramfs is the use of page compression to store the file, in the reading of the file, will not consume too much memory space, only the actual portion of the memory allocated for the current read, not yet read the portion of the unallocated memory space, when we read the file is not in memory, The Cramfs file system automatically calculates the location of the compressed data and then instantly unzip it into RAM. In addition, it is fast and efficient, and its read-only features help protect file systems from damage and improve system reliability.
Due to the above characteristics, CRAMFS is widely used in embedded systems.However, its read-only property is also a major flaw, which makes it impossible for users to expand their content .。 Cramfs images are usually placed in flash, but can also be placed in other file systems, and the loopback device can be used to install it in other file systems.

(4) Romfs
The traditional Romfs file system is a simple, compact, read-only file system that does not support dynamic erase saves and stores data sequentially, thus enabling applications to run in XIP (EXecute on Place, on-chip), saving RAM space while the system is running. Uclinux systems typically use the Romfs file system.
Other file systems: Fat/fat32 can also be used for the actual embedded system of extended memory (such as pda,smartphone, digital cameras, etc.), which is primarily intended to be better compatible with the Windows desktop operating system. Ext2 can also be used as a file system for embedded Linux, but there are many drawbacks to using it for flash flash memory.

(ii) RAM-based file system

(1) Ramdisk RAMDisk is to use a portion of the fixed-size memory as a partition. It is not an actual file system, but a mechanism for loading the actual file system into memory and can be used as the root filesystem. The performance of the system can be significantly improved by placing some files that are frequently accessed without changes, such as a read-only root file system, by RAMDisk in memory.
During the Linux start-up phase, INITRD provides a mechanism to load the kernel image and the root file system together into memory.

(2) Ramfs/tmpfs
Ramfs is a memory-based file system developed by Linustorvalds that works on a virtual file system (VFS) layer, cannot be formatted, can create multiple, and can specify its maximum memory size when it is created. (In fact, VFS can essentially be seen as a memory file system that unifies how files are represented in the kernel and buffers disk file systems.) )
The Ramfs/tmpfs file system puts all the files in RAM, so the read/write operation occurs in RAM and can be used to store some temporary or frequently modified data, such as the/TMP and/var directories, which avoids read and write loss to flash memory. , and also improves the data read and write speed.
The difference between R Amfs/tmpfs and traditional ramdisk is that it cannot be formatted, and the file system size can vary with the size of the file content .
One drawback of TMPFS is that all data is lost when the system reboots.

(iii) Network File system NFS

NFS is a technology developed and developed by Sun that shares files across a network between different machines and different operating systems. In the development and debugging stage of embedded Linux system, this technology can be used to establish the NFS-based root file system on the host computer and mount it to the embedded device, which can easily modify the contents of the root file system.


All of the above discussed are storage-based file systems (Memory-basedfile system), which can be used as root file systems for Linux. In fact, Linux also supports logical or pseudo file systems (logical Orpseudo file system), such as Procfs (proc filesystem), for obtaining system information, as well as DEVFS (device file system) and SYSFS for maintaining device files.



Reference Documentation:

https://blog.csdn.net/firstlai/article/details/50631278

Http://blog.chinaunix.net/uid-26833883-id-4574720.html








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.