Analysis of file system and storage mechanism in embedded Linux

Source: Internet
Author: User
Article title: analysis of the file system and its storage mechanism in embedded Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Embedded systems are different from general-purpose PCs. Generally, they do not have storage devices such as hard disks. Instead, they use Flash chips, small Flash cards, and other storage devices designed for embedded systems, this article analyzes the commonly used storage devices in embedded systems and their management mechanisms, and introduces the commonly used file system types based on FLASH.

1. Analysis of storage devices and management mechanisms of embedded systems

Building a Linux file system suitable for embedded systems involves two key points. one is the selection of file system types, which is related to the read/write performance and size of the file system; the other is the choice of the content of the root file system, which is related to the functions and sizes provided by the root file system.

Memory used in embedded devices is a storage device designed for embedded systems, such as Flash memory chips and small Flash cards. Flash is a mainstream memory widely used in embedded systems. its main features are full/sector erasure and byte programming. it has the advantages of low power consumption, high density, and small size. Currently, Flash is classified into either NOR or NAND.

NOR flash memory can directly read the data stored in the chip, so the speed is relatively fast, but the price is relatively high. The address line of the NOR chip is separated from the data line. Therefore, the NOR chip can be connected to the data line like the SRAM, and the NOR chip can be operated as the basic unit. Therefore, the transmission efficiency is very high, applications can run directly in Flash without having to read the code to the system RAM. The biggest difference between it and SRAM is that write operations need to be erased and written.

The NAND flash memory chip shares the address line and data line, and internal data is stored in blocks. it is difficult to directly start the NAND chip. NAND flash memory is a continuous storage medium and is suitable for file amplification. The NOR device is erased in blocks of-kB, and the write/erase operation is performed in 5 s. the NAND device is erased in blocks of 8-kB, it takes up to 4 ms to perform the same operation.

The unit size of NAND Rash is almost half the size of the NOR device. due to the simpler production process, the NAND structure can provide higher capacity within the given mold size, thus reducing the price accordingly. NOR flash occupies a capacity of 1? Most of the 16 MB flash memory market, while NAND flash is only used in 8? Among the MB products, this also shows that NOR is mainly used in code storage media, and NAND is suitable for data storage.

Lifetime (durability): in NAND flash memory, the maximum number of writes to each block is 1 million, and the number of writes to NOR is 100,000. In addition to having a block erasure cycle of 10 to 1, the typical NAND block size is eight times smaller than that of the NOR device, each NAND memory block is deleted less frequently within a given period of time.

All embedded systems must start with at least some form of permanent storage devices. they need appropriate drivers. Currently, there are three common block drivers available in embedded Linux.

● Blkmem driver layer

The Blkmem driver is specially designed for uclinux and one of the earliest block drivers. many embedded Linux operating systems still use it as a block driver, especially in uClinux. It is relatively simple, and only supports the root file system established in the NOR Flash and RAM. Using the Blkmem driver makes it difficult to create a Flash partition configuration. This type of driver provides some basic erasure/write operations for Flash.

● RAMdisk driver layer

The RAMdisk driver layer is usually used to start a non-disk workstation in a standard Linux system and does not provide any direct support for Flash memory. a RAM disk virtualizes some memory into a block device during startup, decompress the prepared file system image to the RAM disk environment. When a compressed file system is placed in Flash, you can extract the file system to RAM, and use the RAM disk driver layer to support a file system that is kept in RAM.

● MTD driver layer

To avoid using different tools for different technologies and provide the same capabilities for different technologies, the Linux kernel incorporates the MTD subsystem (memory Technology Device ). It provides consistent and unified interfaces, allowing the underlying MTD chip driver to be seamlessly combined with higher-level interfaces.

JFFS2, Cramfs, YAFFS and other file systems can be installed as MTD devices. The MTD driver can also support the NOR Flash that supports the CFI interface. Although MTD can be built on RAM, it is designed for Flash-based devices. MTD contains drivers for specific Flash chips. developers should choose Flash chip drivers suitable for their systems. The Flash chip driver provides read, write, erase, and other basic operations to the upstream layer. MTD encapsulates these operations and provides MTD char and MTD block devices to the user layer.

Devices of the MTD char type include/dev/mtd0,/dev/mtdl, and they provide access to the original Flash characters. MTD block devices include/dev/mtdblock0,/dev/mtdblock1, etc. MTD block devices simulate Flash into block devices, so that they can create block devices like Cramfs on these simulated block devices, JFFS2 and other format file systems.

The MTD driver layer also allows you to create multiple Flash partitions in one Flash. each partition is used as an MTD block device and system software and data can be allocated to different partitions, at the same time, you can use a file system format that is not used in different partitions. This is very important because it provides flexibility for the establishment of multiple file systems in embedded systems.

[1] [2] Next page

Related Article

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.