A data recording system based on FLASH memory

By dividing the storage space of the FLASH memory into multiple logical partitions and using partition cyclic writing method, the bad sector problem caused by frequent writes of FLASH memory sectors is solved, and a higher write life and system reliability are achieved.

CN115525231BActive Publication Date: 2025-05-06GUANGDONG KUANPU TECH CO LTD

Patent Information

Application Number
CN202211226097.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-09
Publication Date
2025-05-06
Estimated Expiration
2042-10-09

AI Technical Summary

Technical Problem

In the prior art, sectors of FLASH memory are prone to bad sectors during frequent erasing and writing, resulting in the reliability and security of the data recording system being affected.

Method used

By dividing the storage space of the FLASH memory into multiple logical partitions and using partition cyclic writing method, the data is avoided from being written to the same physical address every time, thereby rationally using sectors and extending the write life.

Benefits of technology

It effectively improves the write life and service life of FLASH memory, and improves the reliability and security of the data recording system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115525231B_ABST
    Figure CN115525231B_ABST
Patent Text Reader

Abstract

The present invention provides a data recording system based on FLASH memory, which divides the storage space of FLASH memory used for storing statistical records into N logical partitions; the power-on loading method of statistical records is: respectively verifying each logical partition; recording the index number and the write-time counter; obtaining the latest written logical partition by finding the largest write-time counter in the record; loading the index number and data of the latest written logical partition into a cache respectively; the writing method of statistical records is: calculating the data content CRC check and the header information CRC check; finding the next logical partition; erasing the next logical partition, and then writing the logical partition data in the cache. The data recording system uses multiple partition cycles to write data records, makes reasonable and full use of sectors, can improve the writing life and service life of the FLASH memory, and improve reliability and safety.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data recording, and more specifically to a data recording system based on a FLASH memory. Background Art

[0002] In embedded devices, it is often necessary to record the operating status of the device so that the device can be traced back after a failure. The general recording medium is an external non-volatile memory, and the commonly used devices are FLASH and EEPROM memory. The write life of FLASH and EEPROM memory is similar, but because the capacity of FLASH memory is much larger than that of EEPROM memory, FLASH memory is usually selected for data recording and storage.

[0003] Each time data is written to the FLASH memory, the sector where the data is located must be erased first. The erase or write life of each sector is limited, usually 100,000 to 1 million times. Generally, if the number of erase or write times of a sector exceeds the upper limit, the sector becomes a bad sector, but other sectors can continue to be erased and written.

[0004] Usually, the data recording system of the equipment needs to record two types of data. One is statistical records, such as the total number of power-on times of the equipment, the total running time, etc. Statistical records only need to occupy a fixed storage space. The other is incremental records, such as recording the running status of the equipment at a certain time. Incremental records are always increasing.

[0005] At present, the statistical recording of data records, because each update is written to the same physical address, therefore, some sectors of the FLASH memory are frequently erased and written, while other sectors are often idle; the sectors where the data is stored are easily written bad, causing the impact on the operation of the entire data recording system. Therefore, if the sectors of the FLASH memory can be reasonably and fully utilized, it will be beneficial to improve the write life and service life of the FLASH memory. Summary of the invention

[0006] In order to overcome the shortcomings and deficiencies in the prior art, the purpose of the present invention is to provide a data recording system based on FLASH memory; the data recording system uses multiple partition cycles to write data records, avoids writing data to the same physical address each time, and reasonably and fully utilizes the sectors of the FLASH memory, which can increase the write life and service life of the FLASH memory, thereby improving reliability and safety.

[0007] In order to achieve the above object, the present invention is implemented by the following technical scheme: a data recording system based on FLASH memory, using FLASH memory to store data records; the data records include statistical records and incremental records; the characteristics are: a storage space for storing statistical records and a storage space for storing incremental records are separated from the FLASH memory;

[0008] The storage space of the FLASH memory used for storing statistical records is divided into N logical partitions; the data of each logical partition includes header information and data content; wherein the header information includes characteristic characters, a write times counter, a data content CRC check and a header information CRC check;

[0009] The power-on loading method of statistical records is as follows: read each logical partition after power-on: perform CRC check on the data content and header information of each logical partition respectively; if the check is met, record the index number and write count counter of the logical partition; after reading all logical partitions, obtain the latest written logical partition by finding the largest write count counter in the record; load the index number logic_index and data of the latest written logical partition into the cached logical partition index and logical partition space respectively;

[0010] The writing method of statistical records is: for the logical partition space of the current cache, calculate the data content CRC check and the header information CRC check; find the next logical partition according to the index number logic_index in the cache; erase the next logical partition, and then write the logical partition data in the cache.

[0011] Preferably, the power-on loading method of the statistical record comprises the following steps:

[0012] X1. Initialize the maximum write count counter max_counter, the maximum index number max_index, and the current logical partition index number to zero respectively;

[0013] X2. Compare the current logical partition index number with the maximum index number max_index:

[0014] X21. If the current logical partition index number is ≥ the maximum index number max_index, then according to the current logical partition index number, load the current logical partition data into the cached logical partition space; perform a CRC check on the data content of the current logical partition and a CRC check on the header information:

[0015] If the check fails, the current logical partition is discarded and the index number of the current logical partition is increased by 1. Then X2 is executed again.

[0016] If the check is met, determine whether the current logical partition write count counter is greater than the maximum write count counter max_counter: if so, set the value of the maximum write count counter max_counter to the write count counter of the current logical partition, set the maximum index number max_index to the current logical partition index number, and then add 1 to the current logical partition index number; otherwise, directly add 1 to the current logical partition index number; then re-execute X2;

[0017] X22. If the current logical partition index number is less than the maximum index number max_index, determine the size of the maximum write count counter max_counter:

[0018] If the maximum index number max_index=0, all logical partition data are cleared and the write count counter in the cached logical partition space is set to 1;

[0019] If the maximum index number max_index≠0, the logical partition with the index number max_index is determined to be the most recently written logical partition; the index number logic_index and data of the most recently written logical partition are loaded into the cached logical partition index and logical partition space respectively.

[0020] Preferably, in X21, checking the data content CRC check and the header information CRC check of the current logical partition means: there are two check conditions, namely, whether the header information CRC check of the current logical partition is correct, and whether the data content CRC check is the same as the header information CRC check;

[0021] If the CRC checksum of the header information of the current logical partition is correct, and the CRC checksum of the data content is the same as the CRC checksum of the header information, then it is determined to meet the checksum; otherwise, it does not meet the checksum.

[0022] Preferably, the method for writing statistical records comprises the following steps:

[0023] Y1. Calculate the data content CRC checksum and header information CRC checksum for the currently cached logical partition space, and add 1 to the write count counter;

[0024] Y2. According to the index number logic_index of the currently cached logical partition index and the number of logical partitions N, the next logical partition index number logic_index' is calculated as:

[0025] logic_index'=(logic_index+1)%N; wherein % is the remainder operator;

[0026] Y3. Erase the logical partition with index number logic_index', and then write the data in the cached logical partition space.

[0027] Each logical partition contains more than one FLASH memory physical sector.

[0028] Preferably, the writing method of the incremental record is: dividing the storage space of the FLASH memory used for storing the incremental record into L intervals with a length of M; and cyclically writing the incremental record using the L intervals.

[0029] Preferably, the length M ≥ the maximum length of the incremental record.

[0030] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0031] The data recording system of the present invention utilizes multiple partition cycles to record and write data, thereby avoiding writing data to the same physical address each time, making reasonable and full use of the sectors of the FLASH memory, and improving the writing life and service life of the FLASH memory, thereby improving the reliability and security of the data recording system. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 It is a flow chart of a power-on loading method of a statistical record of a data recording system of the present invention;

[0033] Figure 2 It is a flow chart of a method for writing statistical records in a data recording system of the present invention. DETAILED DESCRIPTION

[0034] The present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0035] Example

[0036] This embodiment is a data recording system based on a FLASH memory, which uses a FLASH memory to store data records; the data records include statistical records and incremental records. A storage space for storing statistical records and a storage space for storing incremental records are separated from the FLASH memory. In this embodiment, the front part of the FLASH memory storage space is used to store statistical records, and the remaining space is used to store incremental records.

[0037] The present invention utilizes the principle of cyclic writing of multiple partitions to avoid writing data to the same physical address each time, thereby improving the writing life of the FLASH memory. The storage space of the FLASH memory used to store statistical records is divided into N logical partitions; each logical partition contains more than one FLASH memory physical sector. Assuming that the size of each logical partition is A bytes, the storage layout of the statistical records of the data recording system is shown in Table 1.

[0038] Physical Address Logical partitions 0-(A-1) Logical Partition 0 A-(2A-1) Logical Partition 1 2A-(3A-1) Logical Partition 2 … … (N-1)*A-(N*A-1) Logical partition N-1

[0039] Table 1 Statistical data storage layout

[0040] The data of each logical partition includes header information and data content, as shown in Table 2; wherein the header information includes characteristic characters, a write times counter, a data content CRC check and a header information CRC check, as shown in Table 3.

[0041] Header Information Data content

[0042] Table 2 Data structure of logical partition

[0043] Characteristic characters Write count counter Data content CRC check Header information CRC check

[0044] Table 3 Logical partition header information data structure

[0045] The power-on loading method for statistical records is: read in each logical partition after power-on: check the data content CRC check and header information CRC check of each logical partition respectively; if the check is met, record the index number and write count counter of the logical partition; after reading in all logical partitions, obtain the most recently written logical partition by finding the largest write count counter in the record; load the index number logic_index and data of the most recently written logical partition into the cached logical partition index and logical partition space respectively.

[0046] The data content CRC checksum and the header information CRC checksum can be calculated by existing algorithms respectively: the data content CRC checksum is calculated based on the data content of the logical partition, and then the header information CRC checksum is calculated by the characteristic characters, the write times counter, and all bytes of the data content CRC checksum. The purpose of the header information CRC checksum is to first confirm whether the header information of the logical partition is correct, and then use the data content CRC checksum to confirm whether the data content is correct. When reading the logical partition, it is necessary to check whether the header information CRC checksum is correct, and then check whether the data content CRC checksum is correct. If both are correct, the data of this logical partition is considered valid.

[0047] The cache data structure is shown in Table 4.

[0048] Logical partition space Logical partition first address Logical partition index Change the logo

[0049] Table 4 System cache data structure

[0050] Specifically, the power-on loading method of statistical records, such as Figure 1 As shown, the following steps are included:

[0051] X1. Initialize the maximum write count counter max_counter, the maximum index number max_index, and the current logical partition index number to zero respectively;

[0052] X2. Compare the current logical partition index number with the maximum index number max_index:

[0053] X21. If the current logical partition index number is ≥ the maximum index number max_index, then according to the current logical partition index number, load the current logical partition data into the cached logical partition space; perform a CRC check on the data content of the current logical partition and a CRC check on the header information;

[0054] Checking the data content CRC checksum and the header information CRC checksum of the current logical partition means: there are two check conditions, namely, whether the header information CRC checksum of the current logical partition is correct, and whether the data content CRC checksum is the same as the header information CRC checksum; if the header information CRC checksum of the current logical partition is correct, and the data content CRC checksum is the same as the header information CRC checksum, then it is determined that the checksum meets the requirements; otherwise, the checksum does not meet the requirements;

[0055] If the check fails, the current logical partition is discarded and the index number of the current logical partition is increased by 1. Then X2 is executed again.

[0056] If the check is met, determine whether the current logical partition write count counter is greater than the maximum write count counter max_counter: if so, set the value of the maximum write count counter max_counter to the write count counter of the current logical partition, set the maximum index number max_index to the current logical partition index number, and then add 1 to the current logical partition index number; otherwise, directly add 1 to the current logical partition index number; then re-execute X2;

[0057] X22. If the current logical partition index number is less than the maximum index number max_index, determine the size of the maximum write count counter max_counter:

[0058] If the maximum index number max_index=0, it is determined that no data has been written to all logical partitions, all logical partition data is cleared, and the write count counter in the cached logical partition space is set to 1;

[0059] If the maximum index number max_index≠0, the logical partition with the index number max_index is determined to be the most recently written logical partition; the index number logic_index and data of the most recently written logical partition are loaded into the cached logical partition index and logical partition space respectively.

[0060] As the device runs, the write count counter of the logical partition space in the cache continues to increase.

[0061] When statistical records need to be recorded, they are written into the FLASH memory. The writing method of statistical records is: for the logical partition space of the current cache, calculate the data content CRC check and the header information CRC check; find the next logical partition according to the index number logic_index in the cache; erase the next logical partition, and then write the logical partition data in the cache.

[0062] Specifically, the method of writing statistical records, such as Figure 2 As shown, the following steps are included:

[0063] Y1. For the logical partition space of the current cache, calculate the data content CRC checksum and the header information CRC checksum, and add 1 to the write times counter; first calculate the data content CRC checksum according to the data content, and then calculate the header information CRC checksum. The data content CRC checksum and the header information CRC checksum can be calculated by the existing algorithm;

[0064] Y2. According to the index number logic_index of the currently cached logical partition index and the number of logical partitions N, the next logical partition index number logic_index' is calculated as:

[0065] logic_index'=(logic_index+1)%N; wherein % is the remainder operator;

[0066] Y3. Erase the logical partition with index number logic_index', and then write the data in the cached logical partition space.

[0067] The incremental record uses a data type with a fixed size space for each record. The writing method of the incremental record is: the storage space of the FLASH memory used to store the incremental record is divided into L intervals with a length of M; the length M ≥ the maximum length of the incremental record. The incremental record is written cyclically using L intervals.

[0068] Assume that the storage space of the FLASH memory used to store incremental records can accommodate a total of L incremental records. After L incremental records are written, the next incremental record is written cyclically from the address where the first incremental record is located. Since L is a large number, the incremental records are written cyclically in L intervals. Even if they are written frequently, the write life is L times the erase and write life of a FLASH memory sector.

[0069] Assuming that the starting address of the incremental record is B, the storage layout of the incremental record is shown in Table 5.

[0070] Physical Address Data record index B–(B+M-1) Record 1 (B+M)–(B+2M-1) Record 2 B+2M–(B+3M-1) Record 3 … … B+(L-1)*M–(B+L*M-1) Record N

[0071] Table 5 Storage layout of incremental records

[0072] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.

Claims

1. A data recording system based on FLASH memory, using FLASH memory to store data records; data records include statistical records and incremental records; characterized in that: Separate a storage space for storing statistical records and a storage space for storing incremental records from the FLASH memory; The storage space of the FLASH memory used for storing statistical records is divided into N logical partitions; the data of each logical partition includes header information and data content; wherein the header information includes characteristic characters, a write times counter, a data content CRC check and a header information CRC check; The power-on loading method of statistical records is as follows: read each logical partition after power-on: perform CRC check on the data content and header information of each logical partition respectively; if the check is met, record the index number and write count counter of the logical partition; after reading all logical partitions, obtain the latest written logical partition by finding the largest write count counter in the record; load the index number logic_index and data of the latest written logical partition into the cached logical partition index and logical partition space respectively; The writing method of statistical records is: for the logical partition space of the current cache, calculate the data content CRC check and the header information CRC check; find the next logical partition according to the index number logic_index in the cache; erase the next logical partition, and then write the logical partition data in the cache; The power-on loading method of the statistical record comprises the following steps: X1. Initialize the maximum write count counter max_counter, the maximum index number max_index, and the current logical partition index number to zero respectively; X2. Compare the current logical partition index number with the maximum index number max_index: X21. If the current logical partition index number is ≥ the maximum index number max_index, then according to the current logical partition index number, load the current logical partition data into the cached logical partition space; perform a CRC check on the data content of the current logical partition and a CRC check on the header information: If the check fails, the current logical partition is discarded and the index number of the current logical partition is increased by 1. Then X2 is executed again. If the check is met, determine whether the current logical partition write count counter is greater than the maximum write count counter max_counter: if so, set the value of the maximum write count counter max_counter to the write count counter of the current logical partition, set the maximum index number max_index to the current logical partition index number, and then add 1 to the current logical partition index number; otherwise, directly add 1 to the current logical partition index number; then re-execute X2; X22. If the current logical partition index number is less than the maximum index number max_index, determine the size of the maximum write count counter max_counter: If the maximum index number max_index=0, all logical partition data will be cleared and the write count counter in the cached logical partition space will be set to 1; If the maximum index number max_index≠0, the logical partition with the index number max_index is determined to be the most recently written logical partition; the index number logic_index and the data of the most recently written logical partition are loaded into the cached logical partition index and logical partition space respectively; The method for writing statistical records comprises the following steps: Y1. Calculate the data content CRC checksum and header information CRC checksum for the currently cached logical partition space, and add 1 to the write count counter; Y2. According to the index number logic_index of the currently cached logical partition index and the number of logical partitions N, the next logical partition index number logic_index' is calculated as: logic_index'=(logic_index+1)%N; where % is the remainder operator; Y3. Erase the logical partition with index number logic_index', and then write the data in the cached logical partition space.

2. The data recording system based on FLASH memory according to claim 1, characterized in that: In the X21, the data content CRC check and the header information CRC check of the current logical partition are checked: there are two check conditions, namely, whether the header information CRC check of the current logical partition is correct, and whether the data content CRC check and the header information CRC check are the same; If the CRC checksum of the header information of the current logical partition is correct, and the CRC checksum of the data content is the same as the CRC checksum of the header information, then it is determined to meet the checksum; otherwise, it does not meet the checksum.

3. The data recording system based on FLASH memory according to claim 1, characterized in that: Each logical partition contains more than one FLASH memory physical sector.

4. The data recording system based on FLASH memory according to claim 1, characterized in that: The writing method of the incremental record is: dividing the storage space of the FLASH memory used for storing the incremental record into L intervals with a length of M; and cyclically writing the incremental record using the L intervals.

5. The data recording system based on FLASH memory according to claim 4 is characterized in that: The length M is ≥ the maximum length of the incremental record.

Citation Information

Patent Citations

  • Dynamic storage method of Flash memory

    CN101446921A

  • General high-efficient reliable Nor Flash data memory management method

    CN103425546A

Cited By

  • A flash-based data recording method applied to a radar system

    CN122777061A