Embedded system applications are frequently upgraded, which requires a reasonable division of flash. In general, the basic partitions of Flash are as follows:
1. uboot Partition
2. kernel Partition
3. rootfs partitioning
These three parts are the most basic and generally have.
If this is the only way to partition, and then put the application and the file system together, this will cause the application to be difficult to upgrade, because the application and the file system are put together, the file system must be re-erased and written during each upgrade. This process wastes time and is highly risky. If a sudden power failure occurs when Flash is erased or image files are being written, the device cannot be started (the file system is damaged )! In this way, you must re-download the file system from uboot, which brings a lot of trouble to the upgrade.
During the design of the embedded system, the file system is usually separated from frequently updated applications and placed in different flash partitions, in this way, you only need to erase the application partition and re-run it. In this way, even if the power is interrupted during the upgrade process, the file system will not be damaged and the system can still be started. You can put the Upgrade Program together with the file system so that the device can be upgraded after the device is restarted.
Another way is to upgrade uboot, which cannot avoid problems caused by power outages. In fact, the most important thing is not to put applications together with the file system.
Another person made a "safe mode" partition in flash. if the system is damaged, the device cannot be started normally. In this case, the system can be started in safe mode. The safe mode only provides the most basic functions, for example, upgrades, networks, and other basic functions can help you rebuild the system.
This is also similar to Windows's win PE.
In short, updating applications by upgrading the entire file system is the most undesirable method.
The following describes some common file system formats of embedded systems:
In fact, we all know the formats of embedded root file systems. Common formats include jffs2, cramfs, ramdisk, and yaffs,
Their respective features are not described in detail. Baidu and Google are very detailed.
Here are some of my questions and questions.
1. Flash partition format
At the beginning, I always thought that the flash partition should correspond to a format. I am confused about this. What format does someone ask me about your root file system?
I don't know how to answer this question. Later I found that there is no specific format for this flash partition. What format is the file system you downloaded, it is not in the FAT32 format or NTFS format like drive C and drive D in windows. In windows, these formats are also formatted, the formatting process is equivalent to installing a basic File System in the disk.
2. File System Format
The file system format here refers to the jffs2 and cramfs mentioned above. These file system formats require Kernel support. Generally, you can configure the kernel for support and select related options in the kernel.
A Brief Introduction to the production and use methods.
After the file system is stable, prepare to release the product. When the system and application are officially launched, the file system is generally made into ramdisk, the purpose of this operation is to prevent the system from being started due to file system damage caused by poor external conditions during the operation of the embedded device. Ramdisk reads the file system image from flash and decompress it To the memory after the system is started. Therefore, changes made to the file system during device running will be restored after the device is restarted. Cramfs is a read-only file system. Why does cramfs not be selected as the root file system format of the device? Compared with ramdisk, The cramfs file system also has its advantages: it does not extract all files to the memory, but how much files are used to decompress most files. For embedded devices, it saves a lot of memory, but this will also cause the device to run without ramdisk fast; the disadvantage is that cramfs cannot create any files, and the program is running normally, it is inevitable that some temporary files will be rebuilt (for example, Unix domain socket, a file will be created under the specified directory), so I feel better to use ramdisk.
The cramfs format is not totally negative. It is a good choice to make the application into the cramfs format. we generally do not want to change the cramfs format when the application is running, it is read-only and will not cause damage to it.
In addition, we will create a parameter partition in our system, which is used to save some basic parameters (configuration files). This partition must be readable and writable, now we can consider the jffs2 file system. jffs2 is a readable and writable file system designed specifically for embedded systems.
A well-developed embedded system must at least partition the file system, applications, and parameters. The format is described above. This facilitates future upgrades and maintenance.
Original article: http://wuquan-1230.blog.163.com/blog/static/2981115320128169