CN111723065A - High-reliability file system design method based on NOR flash - Google Patents
High-reliability file system design method based on NOR flash Download PDFInfo
- Publication number
- CN111723065A CN111723065A CN201911200164.8A CN201911200164A CN111723065A CN 111723065 A CN111723065 A CN 111723065A CN 201911200164 A CN201911200164 A CN 201911200164A CN 111723065 A CN111723065 A CN 111723065A
- Authority
- CN
- China
- Prior art keywords
- sector
- file
- havfs
- sectors
- flash
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 24
- 238000013507 mapping Methods 0.000 claims description 13
- 238000011084 recovery Methods 0.000 claims description 3
- 235000019625 fat content Nutrition 0.000 claims 2
- 230000002159 abnormal effect Effects 0.000 description 6
- 238000005192 partition Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/18—File system types
- G06F16/1847—File system types specifically adapted to static storage, e.g. adapted to flash memory or SSD
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1448—Management of the data involved in backup or backup restore
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
Abstract
The invention provides a high-reliability file system design method based on NOR flash, wherein the NOR flash is a nonvolatile memory, the NOR flash must be erased before writing sector operation, when erasing, if the sector content is not updated, the sector content is lost when sudden power failure occurs, and aiming at the problem, the high-reliability file system is designed. The file system is a design method for important data protection aiming at the characteristic of content updating of NOR flash sectors. The method is characterized in that partial sectors are defined in a NOR flash device to serve as parameter sectors, the parameter sectors adopt a design method that each main sector corresponds to one backup sector, when key data are updated each time, the key data are sequentially written into corresponding main and standby sectors, when the key data are read and written, a file system can automatically compare the main and standby sectors, automatically recover data which are not stored in time, and the problems of high-reliability storage and update of the key data under NOR flash are solved.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a high-reliability file system design method based on NOR flash, which can also be applied to an embedded system.
Background
Flash Memory (Flash Memory) is an electronically erasable Memory that allows for multiple erases or writes during operation, and is a non-volatile Memory, also known as Flash Memory. NOR flash is composed of multiple sectors, providing a complete addressing and data bus, allowing any area on the random access memory. The update principle of NOR flash is that only 1 can be written as 0, but 0 cannot be written as 1, so that before the NOR flash is updated, the corresponding sector must be erased, and the erasing process is a process of writing all bits as 1. NOR flash write operations are slow. For example, a NOR flash requires about 520ms to erase a 128KB sector, and each sector update requires a long erase time. Therefore, when the NORflash carries out writing operation, the situation that the content updating fails can occur. In the process of updating the sector content, due to the occurrence of abnormal conditions such as power failure and the like, the sector content is failed to be updated, the sector content is changed into all 1 s, the sector content is in a content erased state and cannot be recovered, and the abnormal write operation is extremely fatal and can cause the loss of key data.
Disclosure of Invention
The invention provides a high-reliability file system design method based on NOR flash, which can avoid abnormal write operation of NORflash, realize high-reliability update and storage of key files, and prevent the contents of important parameters from being erased abnormally.
The method comprises the following specific steps:
step a 1: generating user-defined FAT information for all key files according to the sector condition of the NOR flash of the target system;
step a 2: generating sector mapping data by using a sector tool together with the FAT and the key file;
step a 3: writing the sector mapping data into the parameter sector;
step a 4: accessing a key file in a target system by using a havfs file interface;
step a 5: determining sector information of the key file through FAT by havfs;
step a 6: when the key file is updated by havfs, updating the content of the corresponding main sector, and then updating the content of the corresponding backup sector;
step a 7: the action of updating the sector content is to erase and then write;
step a 8: when the havfs reads and writes the key file, judging whether the main sector and the standby sector are damaged, and if the main sector and the standby sector are damaged, performing coverage recovery by using the corresponding sectors;
step a 9: the havfs can always ensure that a correct sector is available, thereby realizing high-reliability reading and writing of the key file.
The step a1 adopts a custom FAT, that is, by specifying the size of a sector, attribute information such as the position and size of the sector where each file is located is determined, and the attribute information of each file constitutes the content of a file allocation table.
The sector mapping data in the step a2 includes FAT information and all key file contents, and the FAT table and the key file contents are sequentially stored in the mapping data according to the sequence of the FAT entries, which is convenient for programming the parameter sector.
The step a5 is to find the sector information of the key file by customizing the relevant entries in the FAT table.
Step a6 describes a method for reading and writing the main and standby sectors by using the havfs file system, and when updating the key file, the corresponding sector is found by the FAT table, and then the main sector content is erased, the sector content is updated, and then the backup sector is erased, and the backup sector content is updated. The method specifically comprises the following steps:
step b 1: firstly, copying the content of a main sector to be updated to a memory (with the size of one sector);
step b 2: erasing the main sector;
step b 3: writing the updated data in the memory to the main sector;
step b 4: erasing the backup sector;
step b 5: and writing the updated data in the memory to the backup sector.
The step a8 illustrates a method for recovering an error sector by havfs, which is to determine whether a corresponding sector is good or bad when reading a key file, and if the write operation is found to be abnormal, recover a main sector by a backup sector, and vice versa.
The step a9 illustrates the reliability principle of the reading and writing of the havfs key file, and always ensures that one sector is available and no abnormal writing operation occurs.
The beneficial effects of the invention are as follows:
important contents stored in NOR flash are likely to influence the integrity of the contents once power failure occurs during updating, so that the key information is lost, the havfs file system well solves the problem, the key files can be updated with high reliability, and the abnormal writing operation condition can not occur.
Drawings
Fig. 1 shows the use of havfs primary and standby sectors.
The description of the sectors in fig. 2 havfs.
The FAT table in FIG. 3 has been associated with the key file.
FIG. 4 shows an example of a sector map file in havfs.
Detailed Description
The invention will be described in connection with the drawings and illustrative examples, with the aim of understanding the nature of the technical innovation and the efficiency of its objects achieved.
Firstly, using parameter sectors:
NOR flash sectors used in havfs are called parameter sectors, which must be even and each sector is of uniform size. The Havfs primary and secondary sectors are shown in fig. 1. The main sectors are in the front half, the backup sectors are in the back half, and the main sectors and the backup sectors are in one-to-one correspondence. In the illustration of fig. 1, the contents of the third sector and the first sector are identical, and the contents of the second sector and the fourth sector are identical.
The format of each sector is shown in fig. 2, and the sector format description is divided into a sector header and a sector body. The sector header describes the basic situation of the sector, and the C language structure of the sector header is defined as follows:
struct sector_head
{
unsigned int sector_crc;
unsigned int magic;
int sect_size;
int config_sectors;
int file_num;
int group_size;
int generate_time;
int reserved;
};
wherein, sector _ CRC is the value of CRC32 of sector content, magic is a parameter sector used for identifying a havfs file system, sector _ size indicates the sector size, config _ sectors indicates how many participating sectors of the havfs file system are in total, file _ num indicates how many key files are saved in the current sector, group _ size indicates the file grouping size, general _ time indicates the time information for producing parameter sector mapping files, and reserved is a reserved field.
The C language definition of the parameter sector is as follows:
struct sector_info
{
struct sector_head head;
unsigned char contents[SECTOR_DATA_SIZE];
};
each parameter sector is composed of a sector head and a sector body, and the size of the sector body is the size of the sector minus the length of the sector head.
Second, definition of file allocation table
havfs indexes location information of all key files through a file allocation table. The file partition table stores the header of the sector content of the first parameter sector, and the file partition table and the file correspondence relationship are shown in fig. 3.
The custom FAT table is composed of a plurality of entries, each key file has an entry, and the C language definition of the file allocation entry is as follows:
struct vfs_fat {
unknown char valid// valid
unsigned char which_sector; //where sectors
Configured char needed code, whether it is encrypted or not
unsigned char multi_sectors;
Signaled int real _ size// file length
Signaled int code _ len// occupied space
unsigned int sect_offset ;
unsigned char in_cfg_sect;
unsigned char reserved[3];
char filename[FILE_NAME_LENTH];
};
The valid field identifies whether the file is valid, the while _ sectors field indicates which parameter sector the file is in, the need _ code field indicates whether the file is encrypted, the multi _ sectors field indicates whether the file occupies a plurality of parameter sectors and occupies several sectors, the real _ size field indicates the actual length of the file, the code _ len field indicates the length of the file after encryption, the sec _ offset field indicates the offset of the file in the parameter sector, the in _ cfg _ sec field indicates whether the key file is in the parameter sector, the reserved field is a reserved field, the file field is the name information of the file, and the 8.3 format standard is adopted.
Generation of three, sector mapping file
The file allocation table and the actual contents of the file constitute a havfs file system, which is shown in fig. 3. The file system needs to form a sector mapping file, which is convenient for programming the parameter sector.
The Havfs file system file contents are stored in a space where the parameter sectors are discrete blocks, as shown in FIG. 4. By means of the sector tool, the file system is formed into a sector mapping file, and fig. 4 shows a case where the file system stores 3 main sectors, each sector includes a sector header and a sector body, and the sector body stores the contents of all the file systems, thereby forming a sector mapping file of continuous 3 sectors.
The sector mapping file is programmed into the parameter sector, and then the havfs file system can be directly used. Various applications access the key file contents through the havfs file read-write interface.
Fourthly, reading and writing operation of key files
The read operation of the key file comprises the following steps:
step c 1: finding out sector information corresponding to the key file through the FAT table;
step c 2: judging whether the magic field in the head of the main sector in the corresponding sector is correct or not, and if not, covering the content of the backup sector to the main sector;
step c 3: calculating the CRC32 value of the main sector content, if the CRC32 value is consistent with the sector _ CRC field in the sector header, and if the CRC32 value is not consistent with the sector _ CRC field in the sector header, covering the content of the backup sector to the main sector;
step c 4: judging whether the magic field in the sector head of the corresponding backup sector is correct or not, and if not, covering the content of the main sector to the backup sector;
step c 5: calculating the CRC32 value of the content of the backup sector, if the CRC is consistent with the sector _ CRC field in the header of the main sector, and if the CRC is not consistent with the sector _ CRC field in the header of the main sector, covering the content of the main sector to the backup sector;
step c 6: the contents of the key file are read from the corresponding main sector.
The writing operation of the key file comprises the following steps:
step d 1: finding out sector information corresponding to the key file through the FAT table;
step d 2: copying the content of the whole sector into a memory;
step d 3: updating the content of the key file in the memory;
step d 4: calculating the CRC32 value of the sector body in the memory, and updating the sector _ CRC field of the sector header in the memory;
step d 5: erasing the corresponding main sector;
step d 6: writing the memory content into the main sector;
step d 7: erasing the corresponding backup sector;
step d 8: and writing the memory content into the backup sector.
Claims (7)
1. The method for designing the high-reliability file system based on the NOR flash is characterized by comprising the following steps of:
step a 1: generating user-defined FAT contents for all key files according to the sector condition of the NOR flash of the target system;
step a 2: generating sector mapping data by using a sector tool together with the FAT content and the key file;
step a 3: writing the sector mapping data into the parameter sector;
step a 4: accessing a key file in a target system by using a havfs file interface;
step a 5: determining sector information of the key file through FAT by havfs;
step a 6: when the key file is updated by havfs, updating the content of the corresponding main sector, and then updating the content of the corresponding backup sector;
step a 7: the action of updating the sector content is to erase and then write;
step a 8: when the havfs reads and writes the key file, judging whether the main sector and the standby sector are damaged, and if the main sector and the standby sector are damaged, performing coverage recovery by using the corresponding sectors;
step a 9: the havfs can always ensure that a correct sector is available, thereby realizing high-reliability reading and writing of the key file.
2. The method of claim 1, wherein the step a1 is a file allocation table generation for havfs based on NOR flash sector information.
3. The method of claim 1, wherein said step a2 sector mapping data includes FAT and key file content.
4. The method of claim 1, wherein the step a5 is to find the sector information of the key file by means of a custom FAT table.
5. The method according to claim 1, wherein said step a6 describes a method for reading from and writing to active and standby sectors by havfs.
6. The method of claim 1, wherein the step a8 describes a recovery method for erroneous sectors by havfs.
7. The method according to claim 1, wherein said step a9 describes the reliability principle of reading and writing of the havfs key file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911200164.8A CN111723065A (en) | 2019-11-29 | 2019-11-29 | High-reliability file system design method based on NOR flash |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911200164.8A CN111723065A (en) | 2019-11-29 | 2019-11-29 | High-reliability file system design method based on NOR flash |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111723065A true CN111723065A (en) | 2020-09-29 |
Family
ID=72563951
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911200164.8A Pending CN111723065A (en) | 2019-11-29 | 2019-11-29 | High-reliability file system design method based on NOR flash |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111723065A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113010107A (en) * | 2021-02-26 | 2021-06-22 | 深圳忆联信息系统有限公司 | Data storage management method and device, computer equipment and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101364166A (en) * | 2008-09-23 | 2009-02-11 | 杭州华三通信技术有限公司 | Method and device for simulating Nand flash of 2048 byte page into hard disk |
CN103176859A (en) * | 2011-12-21 | 2013-06-26 | 北京普源精电科技有限公司 | Flash data backup/recovery method, equipment and signal source |
-
2019
- 2019-11-29 CN CN201911200164.8A patent/CN111723065A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101364166A (en) * | 2008-09-23 | 2009-02-11 | 杭州华三通信技术有限公司 | Method and device for simulating Nand flash of 2048 byte page into hard disk |
CN103176859A (en) * | 2011-12-21 | 2013-06-26 | 北京普源精电科技有限公司 | Flash data backup/recovery method, equipment and signal source |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113010107A (en) * | 2021-02-26 | 2021-06-22 | 深圳忆联信息系统有限公司 | Data storage management method and device, computer equipment and storage medium |
CN113010107B (en) * | 2021-02-26 | 2023-08-29 | 深圳忆联信息系统有限公司 | Data storage management method, device, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10347349B2 (en) | Method and device for fail-safe erase of flash memory | |
US7911840B2 (en) | Logged-based flash memory system and logged-based method for recovering a flash memory system | |
JP5675954B2 (en) | Detection of irregular parity distribution via metadata tag | |
US8527730B2 (en) | Data updating method, memory system and memory device | |
US8954647B2 (en) | Systems and methods for redundantly storing metadata for non-volatile memory | |
US8255616B2 (en) | Non-volatile memory device and method therefor | |
US10613943B2 (en) | Method and system for improving open block data reliability | |
TWI442230B (en) | Data writing method, memory controller and memory storage apparatus | |
US8271719B2 (en) | Non-volatile memory controller device and method therefor | |
KR20090091101A (en) | Power management block for use in a non-volatile memory system | |
TWI490871B (en) | Method for preventing read-disturb, memory control circuit unit and memory storage apparatus | |
US20080104361A1 (en) | Storage Device, Memory Managing Apparatus, Memory Managing Method, and Program | |
US9563553B2 (en) | Data storing method and embedded system | |
US10635527B2 (en) | Method for processing data stored in a memory device and a data storage device utilizing the same | |
CN112289360A (en) | Read retry threshold voltage selection | |
US10509697B2 (en) | Data storage device and operating method therefor | |
US10642731B2 (en) | Memory management method and storage controller | |
US20070136510A1 (en) | Storage device, memory managing device, memory managing method, and program | |
TWI509615B (en) | Data storing method, and memory controller and memory storage apparatus using the same | |
US9990152B1 (en) | Data writing method and storage controller | |
CN111723065A (en) | High-reliability file system design method based on NOR flash | |
US10459836B2 (en) | Memory device and associated control method | |
CN101470666B (en) | Data memory method | |
CN111258498B (en) | FLASH memory management method | |
CN115981560A (en) | High-reliability file system design method based on NAND flash |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |