Linux MTD hierarchy

Source: Internet
Author: User

MTD (memory technology device) is a Linux subsystem used to access memory devices (ROM, flash. The main purpose of MTD is to make the drive of the new memory device easier. Therefore, MTD provides an abstract interface between the hardware and the upper layer. All source code of MTD is in the/Drivers/MTD subdirectory. I divide the MTD device of the CFI interface into four layers (from the device node to the underlying hardware driver). The four layers are as follows: device node, MTD device layer, MTD raw device layer, and hardware driver layer.

I. Flash hardware driver layer: the hardware driver layer is responsible for driving flash hardware during init
The nor flash chip driver of MTD follows the CFI interface standard. The driver is located in the drivers/MTD/chips subdirectory. NAND Flash Driver
The Order is in the/Drivers/MTD/NAND subdirectory.

2. MTD original device: the original device layer consists of two parts: the common code of the MTD original device and the data of each specific flash, such as partitioning.
The data structure used to describe the original MTD device is mtd_info, which defines a large amount of MTD data and operation functions. Mtd_table (mtdcore. c) is
There is a list of MTD raw devices. mtd_part (mtd_part.c) is the structure used to represent the MTD raw device partition, which contains mtd_info, because every partition has
Is regarded as an MTD raw device added to mtd_table, most of the data in mtd_part.mtd_info is from the primary partition of the partition
Mtd_part-> master.
The drivers/MTD/maps/sub-directory stores specific flash data. Each file describes the flash on a board. Call
Add_mtd_device () and del_mtd_device () Create/Delete the mtd_info structure and add/Delete the mtd_table (or call
Add_mtd_partition () and del_mtd_partition () (mtdpart. c) Create/Delete the mtd_part structure and
Mtd_part.mtd_info ).

3. MTD device layer: based on the original MTD device, the Linux system can define MTD Block devices (master device number 31) and character devices (device Number 90 ). The MTD character device is defined in
Mtdchar. C, by registering a series of Files
Operation functions (lseek, open, close, read, and write ). MTD Block devices define a structure that describes MTD Block devices.
Mtdblk_dev, and declares an array of pointers named mtdblks.
Mtd_info corresponds to each other.

4. device node: Use mknod to create MTD character device nodes (primary device Number 90) and MTD block device nodes (primary device number 31) in the/dev subdirectory ), you can access MTD character devices and Block devices by accessing this device node.

5. root file system: in bootloader, burn jffs (or jffs2) file system image jffs. Image (or jffs2.img) to flash
In a partition, the partition is mounted as the root file system in the your_fixup function of the/ARCH/ARM/Mach-Your/arch. c file.

6. File System: After the kernel is started, the mount command can be used to mount the remaining partitions in flash as the file system to mountpoint.

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.