File System of embedded devices
The system needs a method for storing and retrieving information in a structured format, which requires the participation of the file system. Ramdisk (see references) is a mechanism for creating and mounting a file system by using the computer's ram as a device. It is usually used for diskless systems (including micro-embedded devices, of course, it only contains flash chips used as permanent storage media ).
You can select a file system type based on reliability, robustness, and/or enhanced features. The next section describes several available options and their advantages and disadvantages.
Version 2 extended File System (ext2fs)
Ext2fs is the de facto standard file system for Linux and has replaced its predecessor-extended File System (or extfs ). The maximum file size supported by extfs is 2 GB, and the maximum file name size supported is 255 characters-and it does not support index nodes (including data modification time tags ). Ext2fs is doing better; itsAdvantagesYes:
- Ext2fs supports up to 4 TB of memory.
- The ext2fs file name can contain a maximum of 1012 characters.
- When creating a file system, the administrator can select the logical block size (typically 1024, 2048, and 4096 bytes ).
- Ext2fs implements a fast symbolic link: you do not need to allocate data blocks for this purpose, and store the target name directly in the inode table. This improves performance, especially in terms of speed.
Because of the stability, reliability, and robustness of the ext2 file system, ext2 file systems are used in almost all Linux-based systems, including desktops, servers, workstations, and even some embedded devices. However, when ext2fs is used in embedded devicesDisadvantages:
- Ext2fs is designed for Block devices like ide devices. The logical block size of these devices is a multiple of 512 bytes and 1 K bytes. This is not suitable for flash devices with different slice sizes.
- The ext2 file system does not provide good management of sector-based erasure/write operations. In ext2fs, to erase a single byte in a single sector, the entire sector must be copied to ram, erased, and overwritten. This is not a particularly good method considering the limited lifetime of Flash devices (which can be erased about 100,000 times) that cannot be used afterwards.
- In the case of a power failure, ext2fs does not prevent the crash.
- The ext2 file system does not support loss balancing, thus shortening the slice/flash life. (Wear/tear balancing ensures that different areas of the address range are used in turn for write and/or erase operations to prolong the life of Flash devices .)
- Ext2fs has no perfect sector management, which makes it very difficult to design a block driver.
For these reasons, MTD/jffs2 combination is a better choice in an embedded environment than ext2fs.
Mount ext2fs with ramdisk
By using the ramdisk concept, you can create and mount an ext2 File System (and any file system used for this purpose) on an embedded device ).
Listing 6.Create a simple ext2fs-basedRamdisk
Mke2fs-vm0/dev/Ram 4096
Mount-T ext2/dev/RAM/mnt CD/mnt CP/bin,/sbin,/etc,/dev... files in mnt CD ../ Umount/mnt Dd If =/dev/Ram BS = 1 k count = 4096 of = ext2ramdisk
|
Mke2fs is a utility used to create an ext2 File System on any device-It creates Super blocks, index nodes, and index node tables.
In the above usage,/dev/Ram is the device on which 4096 ext2 file systems are built. Then, mount the device (/dev/Ram) to a temporary directory named/mnt and copy all necessary files. Once these files are copied, the file system will be uninstalled and the contents of the device (/dev/Ram) will be dumped to an ext2ramdisk, it is the required ramdisk (ext2 File System ).
In the above Order, a 4 MB ramdisk is created and filled with the necessary file utility.
Important directories to be included in ramdisk are:
- /Bin-Stores most binary files such as init, busybox, shell, and file management utility.
- /Dev-Contains all device nodes used in the device
- /Etc-Contains all configuration files of the system.
- /Lib-Contains all necessary libraries, such as libc and libdl.
Log FLASH file system, Version 2 (jffs2)
Axis Communications in Sweden developed the initial jffs, which was improved by David Woodhouse of Red Hat. The second version, jffs2, appears as the actual file system of the original flash chip used for micro-embedded devices. The jffs2 file system is log structured, which means that it is basically a long column node. Each node contains part of information about the file, which may be the file name or data. Compared with ext2fs, jffs2 has the followingAdvantagesIn contrast, embedded devices without disks are becoming more and more popular:
- Jffs2 performs flash erasure/Write/read operations on the sector level, which is better than the ext2 file system.
- Jffs2 provides better crash/power loss security protection than ext2fs. When a small amount of data needs to be changed, the ext2 File System copies the entire sector to the memory (Dram), merges new data in the memory, and writes it back to the entire sector. This means that in order to change a single word, a READ/Erase/Write routine must be executed for the entire sector (64 KB)-This is very inefficient. If luck is poor, a power failure or other accident occurs when data is being merged in DRAM, the entire data set will be lost because the flash sector will be erased after the data is read into dram. Jffs2 attaches files instead of overwriting the entire sector, and features crash/power-down security protection.
- This may be the most important point: jffs2 is specially created for embedded devices like flash memory chips, so its entire design provides better flash memory management.
This article focuses on the use of Flash devices, so jffs2 is used in an embedded environment.DisadvantagesFew:
When the file system is full or near full, jffs2 will greatly slow down the running speed. This is because of garbage collection issues (for more information, see references ).
Create a jffs2 File System
In Linux, run the mkfs. jffs2 command to create a jffs2 File System (basically ramdisk of jffs2 ).
Listing 7.Create jffs2File System
Mkdir jffsfile
CD jffsfile
/* Copy all the/bin,/etc,/usr/bin,/sbin/binaries and/dev entries That are needed for the filesystem here */
/* Type the following command under jffsfile directory to create the jffs2 image */
./Mkfs. jffs2-E 0x40000-p-o ../jffs. Image
|
The typical usage of mkfs. jffs2 is shown above. -E option determines the size of the erased sector (usually 64 KB) of the flash memory ). The-P option is used to fill the remaining space of the image with zero padding. -O option is used to output files, usually jffs2 file system image-in this example, jffs. image. Once a jffs2 file system is created, it is mounted to an appropriate location in the flash memory (The Boot Loader informs the kernel to find the address of the file system) so that it can be mounted to the inner nuclear energy.
Tmpfs
When Linux runs on an embedded device, the device becomes a fully functional unit. Many daemon processes run in the background and generate many log messages. In addition, all kernel logging mechanisms, such as Syslogd, dmesg, and klogd, generate many messages in the/var and/tmp directories. Since these processes generate a large amount of data, it is not advisable to allow all these write operations to occur in flash memory. Since these messages do not require persistent storage during reboot, the solution to this problem is to use tmpfs.
Tmpfs is a memory-based file system. It is mainly used to reduce unnecessary flash write operations on the system. Because tmpfs resides in Ram, write/read/erase operations occur in Ram rather than flash. Therefore, log messages are written to ram instead of flash memory and will not be retained during reboot. Tmpfs also uses disk swap space for storage, and uses the virtual memory (VM) subsystem when requesting pages for file storage.
TmpfsAdvantagesIncluding:
- Dynamic file system size-the file system size can be scaled based on the number of copied, created, or deleted files or directories. This makes it ideal to use memory.
Speed-since tmpfs resides in Ram, reading and writing are almost instantaneous. Even if files are stored in the form of exchanges, I/O operations are still very fast.
One of tmpfsDisadvantagesAll data is lost when the system restarts. Therefore, important data cannot be stored on tmpfs.
Install tmpfs
Most other file systems, such as ext2fs and jffs2, reside on the underlying block device, while tmpfs is directly located on the VM. Therefore, it is very easy to install the tmpfs File System:
Listing 8.Install tmpfs
/* Entries in/etc/rc. d/rc. sysinit for creating/using tmpfs */
# Mount-T tmpfs/var-O size = 512 K # Mkdir-P/var/tmp # Mkdir-P/var/log # Ln-S/var/tmp
|
The above command will create tmpfs on/Var and limit the maximum size of tmpfs to 512 K. At the same time, the tmp/and log/directories become part of tmpfs to store log messages in Ram.
If you want to add an item of tmpfs to/etc/fstab, it may look like this:
Tmpfs/var tmpfs size = 32 M 0 0
This will mount a new tmpfs File System on/var.
Gui options
From the user's point of view, the graphical user interface (GUI) is one of the most important aspects of the system: the user interacts with the system through the GUI. Therefore, the GUI should be easy to use and highly reliable. However, it also needs to be memory-aware so that it can be executed seamlessly on memory-limited and micro-embedded devices. Therefore, it should be lightweight and can be quickly loaded.
Another important aspect to consider involves license issues. Some GUI distributions have licenses that allow free use, even in some commercial products. Other licenses require royalty if you want to merge the GUI into your project.
Finally, most developers may choose xfree86, because xfree86 provides them with a familiar environment to use their favorite tools. However, the newer guis on the market, such as century software's Microwindows (nano-x) and trolltech's QT/embedded, are fiercely competitive with X in the embedded Linux arena, this is mainly because they occupy a small amount of resources, execute quickly, and have support for custom window components.
Let's take a look at each of these options.
Xfree86 4.x( x11r6.4 supported with frame buffer)
Xfree86 project, Inc. is a company that produces xfree86. This product is an X Window System that can be repeatedly distributed and open source for free. X Window System (X11) provides resources for applications to display images. It is the most common window system on UNIX and Unix-like machines. It is small but effective. It runs on a large number of hardware and is transparent to the network and well documented. X11 provides powerful functions for window management, event processing, synchronization, and communication between clients-and most developers are familiar with its APIs. It has built-in support for the kernel frame buffer and occupies a very small amount of resources-this is very helpful for devices with relatively small memory. The X Server supports VGA and non-VGA graphics cards. It supports color depth 1, 2, 4, 8, 16, and 32, and provides built-in rendering support. The latest release version is xfree86 4.1.0.
ItsAdvantagesIncluding:
- The use of Frame Buffer Architecture improves performance.
- The occupied resources are relatively small-the size is within the range of 600 KB to 700 KB, which makes it easy to run on small devices.
- Excellent support: There are many documents available online and many mailing lists dedicated to xfree86 development.
- X api is very suitable for expansion.
ItsDisadvantagesIncluding:
- It has poor performance than the recent embedded GUI tools.
- In addition, xfree86 seems to require more memory than the latest development in the GUI, such as nano-X or QT/Embedded-designed specifically for Embedded environments.
Microwindows
Microwindows is an open-source project of century software and is designed for Micro Devices with small display units. It has many functional components for Modern Graphic Windows environments. Like X, there are multiple platforms that support Microsoft Windows.
The Microwindows architecture is client/server-based and hierarchical. The bottom layer is the screen and the input device driver (about the keyboard or mouse) to interact with the actual hardware. In the middle layer, the portable graphics engine supports line drawing, area filling, polygon, cropping, and color models.
At the top layer, Microwindows supports two types of Apis: Win32/wince API implementation, known as Microwindows. The other API is very similar to gdk, which is called Nano-X. Nano-X is used in Linux. It is an API like x used for applications that consume less resources.
Microwindows supports the palletized display of 1, 2, 4, and 8 BPP (number of digits per pixel), as well as true color display of 8, 16, 24, and 32 BPP. Microwindows also supports faster frame buffers. The nano-X Server occupies approximately 100 kb to 150 kb of resources.
The average size of the original nano-x application is 30 K to 60 K. Because nano-X is designed for low-end devices with memory restrictions, it does not support many functions as X does, so it cannot be used as a replacement for Micro X (xfree86 4.1.
You can run flnx on Microsoft Windows. It is a version of the fltk (fast light Toolkit) application development environment for nano-X instead of X. This article describes fltk.
Nano-xAdvantagesIncluding:
- Unlike xlib, nano-X is still running on each client. This means that once a client request packet is sent, the server waits until it provides services to another client, until the entire package arrives. This makes the server code very simple, and the running speed is still very fast.
- Occupies a small amount of resources
Nano-xDisadvantagesIncluding:
- The network components have not been properly adjusted (especially network transparency ).
- There are not many ready-made applications available.
- Compared with X, although nano-X is currently under accelerated development, there are still not so many documentation instructions and there is no good support, but this situation will change.
Fltk API on Microwindows
Fltk is a simple but flexible GUI toolbox that has gained more and more attention in the Linux world. It is especially suitable for environments with few resources. It provides most of the window components you want to obtain from the GUI toolbox, such as buttons, dialog boxes, text boxes, and excellent "value assignment" Selections (the window component used to input values ). It also includes slide, scroll bars, dial, and other components.
The Linux version of fltk for the Microwindows GUI engine is called flnx. Flnx consists of two components: fl_widget and fluid. Fl_widget consists of all basic window component APIs. Fluid (fast light User Interface Designer (fluid) is a graphic editor used to generate fltk source code. In general, flnx is an excellent UI builder that can be used to create applications for Embedded environments.
Fl_widget occupies approximately 40 K to 48 k resources, while fluid (including each window component) occupies approximately 380 K. These very small resource usage make fl_widget and fluid very popular in the embedded development world.
AdvantagesIncluding:
- Anyone who is used to developing Gui-based applications in a better environment like Windows can easily adapt to the fltk environment.
- Its documentation includes a very complete and well-written manual.
- It uses lgpl for distribution, so developers can flexibly issue licenses for their applications.
- Fltk is a C ++ Library (Perl and Python binding are also available ). The choice of object-oriented models is a good choice, because most modern GUI environments are object-oriented, which also makes it easier to transplant written applications to similar APIs.
- The century software environment provides several useful tools, such as screentop and viewml browsers.
ItsDisadvantagesYes:
- Common fltk can work with X and Windows APIs, but flnx cannot. Its incompatibility with X hinders its use in many projects.
QT/embedded
QT/Embedded is a new graphic user interface system developed by trolltech for Embedded Linux. Trolltech initially created Qt as a cross-platform development tool for Linux desktops. It supports various Unix-specific systems and Microsoft Windows. KDE-one of the most popular Linux desktop environments is written using QT.
QT/Embedded is based on the original QT and has made many outstanding adjustments for Embedded environments. Qt embedded interacts directly with Linux I/O facilities through QT APIs. Those who are familiar with and have adapted to object-oriented programming will find it an ideal environment. Moreover, the object-oriented architecture makes code structured, reusable, and fast to run. Compared with other guis, qt gui is very fast and has no layering, making QT/embedded the most compact environment for running QT-based programs.
Trolltech also launched the QT palm machine environment (QT palmtop environment, also known as qpe ). Qpe provides a basic desktop window, and the environment provides an easy-to-use interface for development. Qpe includes a full set of personal information management (PIM) applications, Internet clients, utilities, and so on. However, to integrate QT/embedded or qpe into a product, you need to obtain a commercial license from trolltech. (The original QT version can be obtained based on GPL after version 2.2 .)
ItsAdvantagesIncluding:
- Object-oriented architecture facilitates faster execution
- Occupies a small amount of resources, about 800 K
- Pixel ing between anti-sawtooth text and mixed videos
ItsDisadvantagesYes:
- QT/embedded and qpe can only be used when a commercial license is obtained.
Conclusion
Embedded Linux development is developing rapidly. You must learn and make choices from the various options of the boot loader and distribution to everything in the file system and GUI. But thanks to the freedom of choice and the very active Linux community, embedded development on Linux has reached a new realm, and it is never easier to adjust modules to suit your specifications. This has led to the emergence of many new handheld and micro-devices as open boxes, this is a good thing-the fact is that you don't have to become an expert to choose from these modules to adjust your device to meet your own requirements and needs.
We hope that this introductory introduction to the field of Embedded Linux will stimulate your desire to experiment, and you will enjoy the fun of playing with micro-devices to satisfy your interests. For more information about the technologies that we have outlined here, see the "references" below.
References
·Guide:
- For an excellent explanation of the differences between vmlinux and zimage, write "Kernel configuration: dealing with the unexpected (Linux magazineIn the document "booting your kernel.
- For more information about the kernel, image, and boot processes, see Chapter 13th of the system management text at the Central University of Queensland (Central Queensland University.
- For more information about how the boot process works, see Rolo: A developer's guide, which discusses how to boot Linux without using BIOS (Embedded Linux works, January 1, June 2001 ).
·Small distribution Edition:
- The embedded Linux distributions Quick Reference Guide covers many commercial and open source distribution versions (Linux Devices, January 1, August 2001 ).
- Please refer to another detailed distribution version and a list of useful tools (Linux-embedded.com).
·Tool chain:
- The Wiki toolchain page contains links to all three toolchains mentioned in this article, as well as comments on them.
·Device Driver:
- Memory technology device (MTD) subsystem for Linux aims to simplify the creation of drivers for memory devices (especially flash devices.
- The Linux MTD compiled by Vipin Malik, jffs howto will help you make MTD and jffs2 work together.
- Linux for PowerPC embedded systems howto has a good list of device drivers.
- Understanding Linux Device Drivers helps you understand this introductory article (Penguin magazine).
- To be proficient in Linux Device Drivers, read o'reilly's Linux Device Drivers, version 2nd.
·Useful Tools:
- Check jflash-Linux on lart.
- Binutils, GCC, and glibc can be downloaded from the Free Software Foundation.
- Many useful downloads can be obtained from netwinder.org, a volunteer site dedicated to development on the netwinder platform.
- Read all the information about ramdisk in the article how to use a ramdisk for Linux, which mark Nielsen wrote very well.
- Flnx is based on fltk (quick and lightweight Toolkit.
·File System:
- The homepage of the second extended File System ext2fs is SourceForge.
- Red Hat's British company David Woodhouse outlined a lot of background knowledge about jffs2: log FLASH file systems, version 2nd.
- Vipin Malik's jffs-A Practical Guide also discusses jffs in detail, including the issue of garbage collection (Embedded Linux works, January 1, May 2001 ).
- You can read more about tmpfs in Linux headquarters.
- Flash filesystems for Embedded Linux systems written by Cliff brake and Jeff Sutherland discusses more file systems for flash devices (Embedded Linux Journal).
·Gui:
- Xfree86 is the home page of X development.
- On the Microwindows site, you can find information about Microwindows and nano-X.
- Please refer to a discussion on some shortcomings of Microsoft Windows (the gnome GTK developer's mailing list) (it takes a long time ).
- You will find a variety of Microsoft Windows/nano-x links on the Microwindows project links.
- Find more information about QT/embedded on trolltech.
- The embedded Linux GUI/windowing Quick Reference Guide has a variety of links (Linux Devices, January 1, February 2002 ).
·General references:
- The General Public License or GPL ensures the user's right to copy, distribute, and modify the software.
- ARM Linux is a good site for you to learn about Linux's information for ARM processors. It is maintained by Russell king, creator of arm.
- Penguinppc.org is the home page of Linux for PowerPC series Processors. There is a rich tutorial on creating a tool chain for PPC-based architecture on this site.
- Linux devices is a very comprehensive site that contains various information about Linux and embedded development, such as publishing, quick reference, news, and special reports.
- The silicon penguin list site has a detailed set of Embedded Linux references.
- Armlinux-the book can be obtained from Aleph one. You can order one or read it online.
- The embedded Linux Association (Embedded Linux Consortium) is a non-profit Mutual Assistance Association. It welcomes developers dedicated to the embedded Linux field to become members.
- Visit IBM's home page for Embedded Linux for news, product, and developer references.
- IBM's Linux wristwatch is an example of a micro-embedded device running Linux. Vishal Kulkarni, one of the authors of this article, is also involved in its development. In IBM's Linux watch: The Challenge of miniaturization (PDF), or this article (Freeos.comMarch 2001.
- InDeveloperworksTo view more Linux references.
- InDeveloperworksFor more information about wireless.
About the author Anand K santhanam earned a bachelor's degree in computer science from Madras University in India. He has been working in India for IBM Global Services (software Lab) Since July 1999. He is a member of the IBM Linux team, which focuses on the research and development of arm-Linux, device drivers, and power management in embedded systems. Other areas he is interested in are the nature of o/s and networking. You can contact him through the asanthan@in.ibm.com.
|
Vishal Kulkarni earned a bachelor's degree in electronic engineering from the Shivaji University in Maharashtra, India. He has been working in India for IBM Global Services (software Lab) Since March 1999. Previously, he worked in IBM Austin for more than a year and a half. He is a member of the IBM Linux team, which focuses on ARM-Linux on embedded devices, device drivers, and guis. Other areas he is interested in are the nature of o/s and networking. You can contact him through the kvishal@in.ibm.com. |