1. Introduction of multiple embedded file systems Linux supports a variety of file systems, including ext2, ext3, vfat, ntfs, iso9660, jffs, romfs, and nfs. For the unified management of various types of file systems, Linux introduced the Virtual File System (VFS) for each file system. The class file system provides a unified operation interface and application programming interface. When Linux starts, the first file system that must be mounted is the root file system. If the system cannot mount the root file system from the specified device, the system will exit with error. Afterwards, other file systems can be automatically or manually mounted. Therefore, different file systems can exist simultaneously in one system. Different file system types have different characteristics, and therefore have different application occasions depending on the hardware characteristics of the storage device, system requirements, and the like. In embedded Linux applications, the main storage devices are RAM (DRAM, SDRAM) and ROM (usually FLASH memory). Common types of file systems based on storage devices include: Jffs2, yaffs, cramfs, romfs, ramdisk, ramfs/tmpfs, etc. 1.1. FLASH-based file system Flash (Flash), as the main storage medium for embedded systems, has its own characteristics. Flash write operation can only change the corresponding position of 1 to 0, but can not modify 0 to 1 (Erasing Flash is to restore the contents of the corresponding memory block to 1), so under normal circumstances, write content to Flash In this case, the corresponding memory area needs to be erased first. This erasure is performed in units of blocks. Flash memory mainly includes NOR and NAND technologies (see Appendix for a simple comparison). The number of flash memory flashes is limited, and NAND flash has special hardware interfaces and read and write timings. Therefore, a file system that meets application requirements must be designed for the hardware characteristics of Flash; traditional file systems such as ext2, etc., have a number of drawbacks when used as a file system for Flash. Under embedded Linux, MTD (Memory Technology Device) provides a unified abstract 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 ( See the file system structure diagram under Linux above). The main advantage of using the MTD driver is that it is designed for a variety of non-volatile memory (flash-based), so it has better support for flash, management and sector-based erase, read / Write operation interface. By the way, a Flash chip can be divided into multiple partitions, each partition can use a different file system; two Flash chips can also be combined into one partition, using a file system. That is, the file system is for memory partitions, not memory chips. 1.1.1. jffs2 The JFFS file system was originally a file system developed by the Swedish Axis Communications company based on the Linux2.0 kernel for embedded systems. JFFS2 is a flash file system developed by Red Hat based on JFFS. It was originally developed for Red Hat's embedded product eCos, so JFFS2 can also be used in Linux and uCLinux. Jffs2: Journalling Flash File System v2 Mainly used for NOR-type flash memory, based on the MTD driver layer, characterized by: readable and writable, support for data compression, log file system based on hash table, and provides crash/power-down security protection, providing "write balance" Support etc. The main disadvantage is that when the file system is full or nearly full, jffs2 slows down because of garbage collection. Currently jffs3 is under development. For detailed documentation on the use of the jffs file system, refer to the MTD patch package mtd-jffs-HOWTO.txt. Jffsx is not suitable for NAND flash memory mainly because the capacity of NAND flash memory is generally larger, which causes jffs to quickly increase the memory space occupied by the log node. In addition, the jffsx file system needs to scan the entire FLASH content when it is mounted. To find all the log nodes and establish the file structure, it takes a lot of time for large-capacity NAND flash memory. 1.1.2. yaffs Yaffs/yaffs2 (Yet Another Flash File System) is a log file system designed for NAND-type flash memory for embedded systems. Compared with jffs2, it reduces some functions (for example, does not support data compression), so it is faster, has a shorter mount time, and consumes less memory. In addition, it is a cross-platform file system, in addition to Linux and eCos, also supports WinCE, pSOS and ThreadX. Yaffs/yaffs2 comes with a driver for the NAND chip and provides an API for direct access to the file system for embedded systems. Users can directly manipulate the file system without using MTD and VFS in Linux. Of course, yaffs can also be used with the MTD driver. The main difference between yaffs and yaffs2 is that the former only supports small page (512 Bytes) NAND flash memory, while the latter supports large page (2KB) NAND flash memory. At the same time, yaffs2 has significantly increased its memory footprint, garbage collection speed, and read/write speed. 1.1.3. ubifs The Unsorted Block Image File System (UBIFS) is used on solid-state hard disk storage devices and competes with LogFS as one of the subsequent file systems of JFFS2. Really started to develop in 2007, and in the first time in October 2008 to join the stable version of the Linux kernel 2.6.27 version. UBIFS was first designed by IBM and Nokia engineers Thomas Gleixner and Artem Bityutskiy in 2006 to solve the bottleneck encountered by MTD (Memory Technology Device) devices. Due to the skyrocketing Nand Flash capacity, YAFFS and so on can no longer control the Nand Flash space. UBIFS handles the actions between the subsystem UBI and the MTD device. Like JFFS2, UBIFS is built on the MTD device and is therefore incompatible with the general block device. JFFS2 runs on MTD devices, while UBIFS only works on UBI volume. It can also be said that UBIFS involves three subsystems: 1. The MTD subsystem provides access to the flash chip. The MTD subsystem provides the concept of an MTD device, such as /dev/mtdx. The MTD can be thought of as a raw flash. 2. UBI subsystem provides wear-leveling and volume management functions for flash devices; UBI works on MTD devices and provides UBI volume; UBI is a high-level representation of MTD devices, and some upper MTDs have to be shielded. Problems such as wearing and bad block management 3. UBIFS file system, working on UBI The following are some of the features of UBIFS: Scalability: UBIFS has good scalability for flash size; that is, mount time, memory consumption, and I/O speed are not dependent on flash size (it is not completely accurate for memory consumption, but the dependency is very low. UBIFS can be well adapted to GB flashes; of course, UBI itself has scalability problems. In any case, UBI/UBIFS is more scalable than JFFS2. In addition, if UBI becomes a bottleneck, UBI can be upgraded without change. UBIFS Fast mount: unlike JFFS2, UBIFS does not need to scan the entire file system during the mount phase. The UBIFS mount media takes only milliseconds, and the time does not depend on the size of the flash. However, UPI initialization time is dependent on the size of the flash, so it must be This time is taken into account Write-back support: Write-back or delayed writes are more accurate and can significantly increase file system throughput compared to write-through of JFFS2. Abnormal unmount fitness: UBIFS is a log file system that can tolerate sudden power failures and unclean reboots; UBIFS restores unclean unmounts through replay logs, in which case replay will take some time, so the mount time will increase slightly, but the replay process Does not scan the entire flash media, so the UBIFS mount time is about a fraction of a second. Fast I/O - even if we disable write-back (you can use the -o sync mount option on unmount), UBIFS performance is still close to JFFS2; remember, JFFS2's synchronous I/O is very alarming because JFFS2 doesn't need to be The indexing data structure is maintained on the flash, so there is no burden on it; and UBIFS precisely has index data. UBIFS is fast enough because UBIFS submits logs: instead of moving data from one place to another, it just adds the address of the data to the index of the file system and then selects a different erase block as the new log block. There are multi-headed log methods and other techniques. On-the_flight compression - The data stored on the flash media is compressed; it can also be turned on and off flexibly for a single file; for example, compression may need to be turned on for a specific file, or compression may be supported by default. , but turn off compression for multimedia files. Recoverability - UBIFS can recover from index destruction; each piece of information in UBIFS has a header to describe, so you can reconstruct the file system by scanning this flash media, which is very similar to JFFS2; imagine if you Eliminating the FAT file system FAT table is a fatal error for FAT FS, but if you erase the UBIFS index, you can actually rebuild the file system, of course, this requires a specific user-space program to do this recovery Integrity - UBIFS guarantees the integrity of the data by writing checksums to the flash media. UBIFS does not ignore corrupted file data or meta-data. By default, UBIFS only checks the CRC of meta-data, but you can use the mount option. Force data CRC check Ubifs details 1.1.4. Cramfs Cramfs (Compressed ROM File System) is a read-only compressed file system developed by Linux founder Linus Torvalds. It is also based on the MTD driver. In the cramfs file system, each page (4KB) is individually compressed and can be accessed on a random page with a compression ratio of up to 2:1, saving a large amount of Flash storage space for embedded systems, enabling the system to be stored through lower-capacity FLASH memory. The same file, thereby reducing system costs. The Cramfs file system is stored in a compressed manner and decompressed at runtime, so applications are not supported to run in XIP mode. All application programs are required to be copied to RAM for running, but this does not mean that Ramfs needs more RAM space than Ramfs requires. A bit, because Cramfs uses the page compression mode to store files, when reading files, it will not consume too much memory space at once. It only allocates the memory for the currently read part, but the part that has not been read yet does not. Allocate memory space. When the file we read is not in memory, the Cramfs file system automatically calculates the location of the compressed data and decompresses it into RAM immediately. In addition, it is fast, efficient, and its read-only features help protect file systems from damage and improve system reliability. Due to the above features, Cramfs is widely used in embedded systems. However, its read-only attribute is also a big flaw in it, which makes it impossible for users to extend and expand their content. The Cramfs image is usually placed in Flash, but it can also be placed on another file system, using a loopback device to install it on another file system. (5) Romfs The traditional Romfs file system is a simple, compact, read-only file system. It does not support dynamic erase and save, and stores data in sequence, thus supporting applications running in XIP (eXecute In Place) mode. Saves RAM space when the system is running. The uClinux system usually uses the Romfs file system. Other file systems: fat/fat32 can also be used for the extended memory of actual embedded systems (such as SD cards for PDAs, Smartphones, and digital cameras). This is mainly for better compatibility with the most popular Windows desktop operating systems. Ext2 can also be used as an embedded Linux file system, but there are many drawbacks to using it in flash memory. 1.2. RAM-based file system 1.2.1. Ramdisk Ramdisk uses a portion of fixed-size memory as a partition. It is not an actual file system, but a mechanism to load the actual file system into memory, and it can be used as the root file system. Putting some files that are frequently accessed and not changed (such as a read-only root file system) into memory through Ramdisk can significantly improve system performance. During the Linux startup phase, initrd provides a mechanism for loading the kernel image with the root file system into memory. 1.2.2. ramfs/tmpfs Ramfs is a memory-based file system developed by Linus Torvalds. It works on the virtual file system (VFS) layer and cannot be formatted. Multiple files can be created, and the maximum memory size can be specified when creating it. (Actually, VFS can essentially be thought of as a memory file system that unifies the presentation of files in the kernel and buffers disk file systems.) The Ramfs/tmpfs file system puts all files in RAM, so read/write operations occur in RAM. You can use ramfs/tmpfs to store temporary or frequently modified data, such as the /tmp and /var directories. This not only avoids the loss of read and write to the flash memory, but also improves the speed of reading and writing data. The main difference between Ramfs/tmpfs and traditional Ramdisk is that it cannot be formatted, and the size of the file system can vary depending on the size of the contents of the included files. One drawback of Tmpfs is that all data is lost when the system reboots. 1.2.3. NFS The NFS Network File System is a technology developed and developed by Sun to share files across networks between different machines and operating systems. During the development and debugging phase of an embedded Linux system, this technique can be used to create an NFS-based root file system on a host and mount it on an embedded device, which can easily modify the contents of the root file system. The above discussion is based on a memory-based file system, which can be used as a Linux root file system. In fact, Linux also supports logical or pseudo file systems, such as procfs (proc file system), for obtaining system information, and devfs (device file system) and sysfs for maintaining device files. 2 Appendix: Comparison of NOR Flash and NAND Flash NOR FLASHNAND FLASH Interface timing with SRAM, easy to use address/data line multiplexing, narrow data bits Faster read speed Slow read speed Erasing speed is slow, the erase speed is fast in blocks of 64-128KB, in units of 8-32KB blocks Write speed is slow (because generally erased first) Write speed Random access speed is faster, support XIP (eXecute In Place, on-chip execution), suitable for code storage. In embedded systems, it is often used to store boot programs, root file systems, and so on. Sequential read speeds are fast, random access speeds are slow, and are suitable for data storage (such as high-capacity multimedia applications). In embedded systems, it is often used to store user file systems. Small chip capacity, 1-32MB single chip capacity, 8-128MB, increased cell density Audio Video Cable:Video cable, referred to as video cable, is composed of video cable and connector. Among them, video cable is coaxial shielded cable with characteristic impedance of 75 Ω (Ω). Common specifications are divided into - 3 and - 5 according to wire diameter, single core wire and multi-core wire according to core wire, common specifications of connector are divided into pressure joint and welding joint according to cable end connection mode, and equipment There are BNC (commonly known as bayonet) and RCA (commonly known as lotus head). Audio cable, referred to as audio cable, is composed of audio cable and connector. The audio cable is generally a dual core shielded cable, and the common connectors are RCA (commonly known as lotus head), XLR (commonly known as XLR head) and trsjacks (commonly known as pen plug). Audio Video Cable ShenZhen Antenk Electronics Co,Ltd , https://www.atkconnectors.com