Data storage method and device of Flash memory, equipment and medium
By dividing multiple storage areas in the Flash memory and synchronous recording and data migration when the data to be stored changes, the problem of limited number of erases in the Flash memory is solved, achieving a longer service life and higher data accuracy.
Patent Information
- Application Number
- CN202411871059.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-12-18
AI Technical Summary
The number of erases in Flash memory is limited. The traditional overwrite method will increase the number of erases and shorten the service life of Flash memory.
At least two storage areas are determined in the Flash memory, each area including a memory block and a real-time recording block. By performing instant writing in the first area, changes in the data to be stored are recorded, and the first area is erased after data migration, to reduce the number of erasing times.
It effectively reduces the number of erasing times of Flash memory, extends its service life, and ensures data accuracy.
Smart Images

Figure CN119883111A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of electronic information technology, and specifically relates to a data storage method, device, equipment and medium of a Flash memory. Background Art
[0002] With the rapid development of science and technology, Flash memory is widely used in electronic devices to store non-volatile data. For Flash memory, the number of erase and write operations is limited, generally between 10,000 and 1,000,000 times, which also makes the service life of Flash memory the main limiting factor. Therefore, in high-frequency erase and write operations, the life of Flash memory will be seriously affected. Traditional Flash storage methods usually use simple overwrite writing to store data, which will increase the number of erase and write operations, thereby shortening the service life of Flash memory.
[0003] Therefore, how to achieve efficient data writing and reasonably control the number of erasures is a technical problem that needs to be solved urgently by those skilled in the art. Summary of the invention
[0004] The embodiments of the present application provide a data storage method, device, equipment and medium of a Flash memory, with the purpose of providing a new data storage method that can effectively reduce the number of erase times while ensuring the accuracy of stored data, thereby increasing the service life of the Flash memory.
[0005] In a first aspect, an embodiment of the present application provides a method for storing data in a Flash memory, the method comprising:
[0006] Determine at least two storage areas in the Flash memory, each storage area including a storage block and a real-time recording block;
[0007] The first area is used as an immediate writing area, and when it is recognized that the data to be stored increases, the first value of the corresponding number is written as the second value in the real-time recording block in the first area according to the number of the increased data;
[0008] After all the first values in the real-time recording blocks in the first area are written as second values, the storage blocks in the first area and the data to be stored recorded in the real-time recording blocks are written into the storage blocks in the second area, and the second area is used as an immediate writing area;
[0009] The storage blocks and the real-time recording blocks in the first area are erased.
[0010] Furthermore, the method further comprises:
[0011] When a query request for data to be stored is identified, the value stored in the storage block of the immediate write area is identified, and / or the number of second values written in the real-time record block of the immediate write area is identified to obtain the query result of the data to be stored.
[0012] Further, writing the data to be stored recorded in the storage block and the real-time recording block in the first area into the storage block in the second area includes:
[0013] The data to be stored recorded in the storage blocks and the real-time recording blocks in the first area are written into the storage blocks in the second area in a binary manner.
[0014] Furthermore, writing the data to be stored recorded in the storage blocks and the real-time recording blocks in the first area into the storage blocks in the second area in a binary manner includes:
[0015] Reading the binary value in the storage block in the first area, and reading the number of second values in the real-time recording block in the first area, and adding them together to obtain the recorded data to be stored;
[0016] The data is written into the storage block of the second area in binary form.
[0017] Further, when it is recognized that the data to be stored increases, the first value of the corresponding number is written as the second value in the real-time recording block in the first area according to the number of the increased data, including:
[0018] When it is recognized that the data to be stored increases, the corresponding number of values 1 is written as value 0 in the real-time recording block in the first area according to the number of increased data in a preset order.
[0019] Furthermore, the method further comprises:
[0020] After all first values in the real-time recording block in the second area are written as second values, the storage blocks in the second area and the data to be stored recorded in the real-time recording blocks are written to the storage blocks in the first area, and the first area is used as the immediate writing area.
[0021] Furthermore, the data to be stored is monotonically increasing data.
[0022] In a second aspect, an embodiment of the present application provides a data storage device of a Flash memory, the device comprising:
[0023] A storage area determination module, used to determine at least two storage areas in the Flash memory, each storage area including a storage block and a real-time recording block;
[0024] A data recording module, configured to use the first area as an immediate writing area, and when recognizing that the data to be stored increases, write the first value of the corresponding number as the second value in the real-time recording block in the first area according to the number of the increased data;
[0025] a data migration module, configured to write the storage blocks in the first area and the data to be stored recorded in the real-time recording blocks into the storage blocks in the second area after all the first values in the real-time recording blocks in the first area are written as second values, and use the second area as an immediate writing area;
[0026] The erasing processing module is used to erase the storage blocks and real-time recording blocks in the first area.
[0027] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0028] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0029] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0030] In an embodiment of the present application, at least two storage areas are determined in a Flash memory, each storage area includes a storage block and a real-time recording block; the first area is used as an immediate writing area, and when it is recognized that the data to be stored increases, the first value of the corresponding number is written as the second value in the real-time recording block in the first area according to the number of data increases; after all the first values in the real-time recording block in the first area are written as the second value, the data to be stored recorded by the storage block and the real-time recording block in the first area are written into the storage block in the second area, and the second area is used as the immediate writing area; the storage block and the real-time recording block in the first area are erased. This technical solution uses multiple storage areas for alternating storage, and when the data to be stored changes, the first value is written as the second value for synchronous recording. It can be realized without an erase operation, and after all the data in one area are written as the second value, it can be migrated to another area for recording, and the current area is erased, which can effectively reduce the number of erasures, so as to ensure the accuracy of the stored data while reducing the number of erasures, thereby improving the service life of the Flash memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 It is a flowchart of a data storage method of a Flash memory provided in an embodiment of the present application;
[0032] Figure 2 is a schematic diagram of the first area provided in an embodiment of the present application;
[0033] Figure 3 It is a flowchart of a data storage method of a Flash memory provided in an embodiment of the present application;
[0034] Figure 4 is a schematic diagram of data migration using two storage areas as an example provided in an embodiment of the present application;
[0035] Figure 5 It is a structural schematic diagram of a data storage device of a Flash memory provided in an embodiment of the present application;
[0036] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0038] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0039] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0040] The data storage method, device, equipment and medium of the Flash memory provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0041] Figure 1 FIG. 1 is a flow chart of a data storage method of a Flash memory provided in an embodiment of the present application. Figure 1 As shown, the specific steps include:
[0042] S101, determining at least two storage areas in a Flash memory, each storage area including a storage block and a real-time recording block;
[0043] Flash memory, also known as flash memory, is a commonly used electronic storage device. It uses the floating gate in the storage unit to store charge to represent data 0 or 1. By applying appropriate voltages, these storage units can be programmed (write data), erased, and other operations are performed to store and update data. Currently, NOR Flash is common. Its storage unit is similar to the arrangement of ordinary memory units, supports byte-level random reading, and has a relatively fast reading speed. It is often used to store key information that needs to be read quickly, such as startup code and firmware in embedded systems. However, its integration is relatively low, and its storage capacity is often smaller than that of NAND Flash under the same process. NAND Flash uses a unique serial-parallel structure with high storage density and can achieve large-capacity storage. Large-capacity storage devices such as our common solid-state drives, USB flash drives, and memory cards basically use NAND Flash. However, its reading cannot generally perform byte-level random reading like NOR Flash, but is operated in blocks, and the reading speed is relatively slow. Flash memory is non-volatile. Even if the power is off, the stored data will not be lost, ensuring the long-term preservation of data. For example, the memory card in a digital camera, even if the camera is out of power, the photos in it still exist. Flash memory can repeatedly erase and write data, so it is convenient to update the storage content at any time according to the needs. Currently, Flash memory has a variety of capacity options, ranging from small capacity to meet simple applications to ultra-large capacity to store massive data. For example, there are small flash memories with a capacity of several megabytes for simple embedded devices, and there are also solid-state drives with a larger capacity for data center storage.
[0044] There are at least two storage areas, each of which can be a page or a sector, and each storage area includes a storage block and a real-time recording block; assuming that a storage area includes 4KB bytes, it can include 32768 bits, the first 32 bits can be used as a storage block, and the remaining bits can be used as a real-time recording block. Then, the storage block can record a range of 0-4294967295, and the remaining bits can be, for example, 32768 minus 32 to obtain 32736 bits, and the default value of each bit can be the first value, which can be changed to the second value after writing.
[0045] S102, using the first area as an immediate writing area, when it is recognized that the data to be stored increases, writing the first value of the corresponding number as the second value in the real-time recording block in the first area according to the number of the increased data;
[0046] The immediate write area is the area currently used for synchronous recording of the data to be stored. For example, if the data to be stored increases by 1, the immediate write area will also increase 1 based on the original recorded value, and other areas do not need to participate in the recording of this change.
[0047] In this embodiment, optionally, the data to be stored is monotonically increasing data.
[0048] Among them, monotonically increasing data, such as the number of times a computer is turned on, other counters, etc. The change of its data is monotonically increasing and will not decrease.
[0049] In this solution, if the data to be stored decreases, it may be necessary to rewrite the value 0 to the value 1, which requires erasing and rewriting to achieve. Therefore, this solution can better ensure the storage of data by limiting the data to be stored in the form of monotonically increasing data, and there is no need for excessive erasing operations during the storage process, thereby improving the service life of the Flash memory.
[0050] In one embodiment, optionally, when it is recognized that the data to be stored increases, writing the first value of the corresponding number as the second value in the real-time recording block in the first area according to the number of the increased data includes:
[0051] When it is recognized that the data to be stored increases, the corresponding number of values 1 is written as value 0 in the real-time recording block in the first area according to the number of increased data in a preset order.
[0052] The increase of the data to be stored can be done by adding only one value at a time, such as the number of times the computer is turned on, or by adding multiple values at a time, such as recording the number of applications opened by the user after the current startup. When multiple applications are opened at a time, they can be stored, for example, by adding three values at a time. In this solution, when the increase of the data to be stored is recognized, the corresponding number of 1s in the real-time recording block in the first area will be written as 0s according to the number of data increases. In this way, the data to be stored can be synchronously recorded by the number of 0s in the real-time recording block in the first area. Moreover, the operation of writing 1 to 0 here is performed in a certain order.
[0053] Figure 2 is a schematic diagram of the first region provided in the embodiment of the present application. Figure 2As shown, assuming that the size of the first area is 4KB, it is equivalent to a total of 4096 bytes, 1 byte is 8 bits, that is, a total of 32768 bits. Among them, 0X2000 is a storage block with 32 bits. If the binary counting method is used, the counting range is 0 to 4294967295. 0X2004 to 0X2FFC are real-time recording blocks. 0X2004 has 32 bits, and the initial value of each bit is 1. When the data to be stored increases, the corresponding number of 1s can be rewritten as 0. After 0X2004 is all rewritten as 0, 0X2008 can continue to be rewritten. For example, if the current data to be stored is 14, the last 14 bits of the 32 1s in 0X2004 can be rewritten as 0, that is, from 11111111 1111 1111 1111 1111 to 1111 1111 11111111 1100 0000 00000000.
[0054] Through such a setting, the present solution can accurately record the data to be stored, and no erasing operation is required during the recording process, thereby improving the recording efficiency and increasing the service life of the Flash memory.
[0055] S103, after all the first values in the real-time recording blocks in the first area are written as second values, the storage blocks in the first area and the data to be stored recorded in the real-time recording blocks are written into the storage blocks in the second area, and the second area is used as an immediate writing area;
[0056] In this solution, after all the first values in the real-time recording block in the first area are written as the second values, that is, after all the 1s are rewritten as 0s, the data to be stored recorded in the first area can be written into the storage block of the second area. For example, there is no recorded data in the storage block of the first area at present, and 32736 0s are read out of the real-time recording block, that is, the currently recorded data to be stored is 32736, and written into the storage block of the second area. In this way, the migration of the storage area is realized, and the second area can be used as an immediate writing area, that is, the changes in the data to be stored can continue to be recorded through the real-time recording block of the second area, and the recording method can still be a method of rewriting 1 into 0.
[0057] In one embodiment, optionally, writing the data to be stored recorded in the storage block and the real-time recording block in the first area to the storage block in the second area includes:
[0058] The data to be stored recorded in the storage blocks and the real-time recording blocks in the first area are written into the storage blocks in the second area in a binary manner.
[0059] In this solution, the second area can have the same division method as the first area, divided into storage blocks and real-time recording blocks.
[0060] The process of writing the data to be stored recorded in the first area to the storage block of the second area can be written in binary mode. Since the storage block of the second area also has 32 bits, if the data is recorded in binary mode, the storage block can record a range of 0-4294967295, which has a powerful recording capability.
[0061] Therefore, through such a setting, the present solution can ensure the accuracy of the recorded data to be stored during the storage area migration process, while also having good recording capabilities to ensure the executability of the solution.
[0062] In one embodiment, optionally, writing the data to be stored recorded in the storage block and the real-time recording block in the first area into the storage block in the second area in a binary manner includes:
[0063] Reading the binary value in the storage block in the first area, and reading the number of second values in the real-time recording block in the first area, and adding them together to obtain the recorded data to be stored;
[0064] The data is written into the storage block of the second area in binary form.
[0065] In this solution, there is also a situation where data is also recorded in the storage block in the first area. In this case, since the data is recorded in binary form, the recorded value can be read in binary form and added to the number of 0s read in the real-time recording block to obtain the actual recorded value of the first area.
[0066] For example, after the first area is migrated to the second area, if it is migrated to the first area again, the size of the data to be stored recorded before the migration will be stored in the storage block of the first area in binary form, so that there will be a corresponding value in the storage block.
[0067] Through such a setting, this solution can achieve the purpose of accurately recording the stored data during the migration process, avoiding the omission of data during the migration process, resulting in errors in data records.
[0068] S104, erasing storage blocks and real-time recording blocks in the first area.
[0069] In this solution, due to data migration, the data in the first area has been successfully written into the storage block of the second area, and the second area is used as the immediate write area, so the first area can be erased and used as the target area for the next migration.
[0070] It can be understood that when there are multiple areas, migration can also be performed in a certain order, such as the first area → the second area → the third area → the fourth area → the first area..., etc. As long as there are at least two storage areas, data migration can be achieved, and the previous area is erased after each migration, thereby reducing the number of erase times of the storage area and improving the service life of the Flash memory.
[0071] The technical solution provided in this embodiment is to determine at least two storage areas in the Flash memory, each storage area includes a storage block and a real-time recording block; take the first area as the immediate writing area, when it is recognized that the data to be stored increases, write the first value of the corresponding number as the second value in the real-time recording block in the first area according to the number of data increases; after all the first values in the real-time recording block in the first area are written as the second value, write the data to be stored recorded by the storage block and the real-time recording block in the first area to the storage block in the second area, and take the second area as the immediate writing area; erase the storage block and the real-time recording block in the first area. This technical solution uses multiple storage areas for alternating storage, and when the data to be stored changes, synchronously records by writing the first value as the second value, so that it can be realized without the need for an erase operation, and after all the data in one area are written as the second value, it can be migrated to another area for recording, and the current area can be erased, which can effectively reduce the number of erasures, so as to ensure the accuracy of the stored data while reducing the number of erasures, thereby improving the service life of the Flash memory.
[0072] In one embodiment, optionally, the method further comprises:
[0073] When a query request for data to be stored is identified, the value stored in the storage block of the immediate write area is identified, and / or the number of second values written in the real-time record block of the immediate write area is identified to obtain the query result of the data to be stored.
[0074] Based on the above technical solution, if a query request for data to be stored is identified, the value stored in the storage block of the immediate write area (if any) and the number of second values written in the real-time record block (if any) can be added together as the query result of the data to be stored.
[0075] For example, in the process of recording data in the first area, since no migration operation has occurred, there is no stored value in the storage block in the first area. At this time, only the number of second values written in the real-time recording block can be used as the basis.
[0076] When the first area happens to migrate to the second area, that is, there are values stored in the storage block of the second area, but all the values in the real-time recording block are 1 and no bit has been rewritten to 0, the values stored in the storage block of the second area can be used as the basis.
[0077] In this solution, in order to accurately read the data to be stored, after receiving the query request, the storage block and the real-time recording block in the immediate write area can be read once, and the sum of the read data is used as the query result.
[0078] Through such a setting, this solution can determine different reading methods for different areas and provide accurate data feedback for query requests based on the read results.
[0079] In one embodiment, optionally, the method further comprises:
[0080] After all first values in the real-time recording block in the second area are written as second values, the storage blocks in the second area and the data to be stored recorded in the real-time recording blocks are written to the storage blocks in the first area, and the first area is used as the immediate writing area.
[0081] In this solution, after all the first values in the real-time recording block of the second area are written as the second values, the stored data can be migrated to the storage block of the first area, and the first area can be used as the immediate writing area again, thereby realizing the cyclic migration operation of multiple storage areas, so as to realize the recording of the data to be stored without investing more storage areas, effectively control the number of erasure times of the storage area, and improve the service life of the Flash memory.
[0082] In order to enable those skilled in the art to understand the present technical solution more clearly, the present solution also provides a preferred implementation. Figure 3 FIG. 1 is a flow chart of a data storage method of a Flash memory provided in an embodiment of the present application. Figure 3 As shown, the specific steps include:
[0083] Step 1: Define two or more storage areas in the Flash memory and divide the storage area into several small areas.
[0084] The size of each region may be 4KB, and a certain byte in the region is agreed to be used for the total number of loop inheritance, thereby recording the count of an incremental variable to achieve partitioned loop storage.
[0085] Step 2: Each time the variable increases, the 1s in the bytes are gradually converted to 0s by using the method of converting 1s to 0s in the bytes in the Flash memory, and the increment of the variable value is represented by the number of 0s in the bytes.
[0086] For example, if there are 5 zeros in an address, it means that the value of the variable is "5"; for example: there is a variable 5 in the storage area 0X2000. When the monotonically increasing variable increases from 5 to 6, it is written to the address in an overwriting manner, and the address content changes to: 1110-0000→1100-0000. The embedded device obtains the value of the variable by reading the number of all address 0s. This method does not require erasing the original data.
[0087] Step 3: When the number of 0s in the bytes of one area reaches the set maximum value, the count value in the area is written to the specified position of another area.
[0088] The designated position can be the first four bytes or the last four bytes, and the data in the current area is erased, thereby realizing the periodic storage of data; for example: the address 0x2000 is used as the total size of the statistical variable, 0x2004~0x2FFF is used for counting, the counting area is filled with "0", the total number is written to the address 0x3000 to save the total number, and counting continues from 0x3004~0x3FFF, and 0x2000~0x2FFF is erased.
[0089] Step 4: When the second area also completes counting, the count value is written into the first area again and the second area is erased.
[0090] By analogy, each storage and erasing operation is performed alternately, avoiding frequent erasing of the same area, thereby effectively reducing the number of erasing times of the Flash memory.
[0091] In addition, the storage method of this embodiment is suitable for scenarios where incremental counts need to be recorded, such as the number of times a device is used, the system version number, etc. By writing the number of 0s in different areas to represent the accumulated count value, there is no need to frequently erase the contents of the Flash memory, which further improves the storage efficiency.
[0092] The beneficial effects of this preferred embodiment are that it prolongs the service life of the Flash memory, reduces the number of erase and write times through partitioned circular storage and special statistical methods, greatly reduces the erase and write burden of the Flash memory, and significantly prolongs the service life of the device; improves storage efficiency: by using the number of 0s to represent data values, it can effectively reduce the waste of storage space and improve storage efficiency; is suitable for the storage of monotonically increasing variables: the present invention is suitable for embedded devices, Internet of Things devices, wearable devices, etc. that need to store monotonically increasing data, especially in the storage of data such as counters and device status; simplifies data management: this method simplifies data storage and management by alternating the use of different areas to store counts, and avoids frequent storage area allocation and cleaning.
[0093] The optimization scheme for extending the life of the Flash memory provided by the present invention specifically includes: periodic allocation of storage areas: multiple storage areas of the same size are set in the Flash memory, and when the count value of an area reaches the maximum value, it is switched to the next area for storage. In this way, frequent erase and write operations on the same storage area can be avoided, and the service life of each area can be extended; the representation method of increasing variables: by converting 1 in each byte to 0 to represent the increase of the variable, this method can effectively reduce the number of erase and write times each time data is written, and further improve the durability of the Flash memory.
[0094] The embodiment of the present invention also provides a counter storage method for embedded devices, IoT devices and wearable devices, wherein the counter is used to store monotonically increasing data such as the number of times the device is powered on, the version number, the number of times the device status is changed, etc. The method reduces the frequent erase and write operations on the Flash storage area by using the incremental counting mechanism of the Flash memory, thereby extending the service life of the device. In theory, compared with the traditional storage method, the same size of storage space reduces the number of erase times by 32 times, thereby increasing the service life by 32 times.
[0095] The storage method provided by the embodiment of the present invention can flexibly control the increment of the count within the range of data value variation. For example, after the count reaches a certain threshold, the size of the storage area is increased or the upper limit of the count of 0 is increased to meet the needs of data changes in different application scenarios.
[0096] Figure 4 FIG. 1 is a schematic diagram of data migration using two storage areas as an example provided in an embodiment of the present application. Figure 4As shown: First, the Flash memory is divided into two storage areas, and the two storage areas are used to store the incremented variable values. The first address of the storage area is used to store the total count, using the normal statistical method, and the remaining addresses use the "0" number statistical method of the present invention. When it is necessary to record the increment of the variable, the actual value of the variable is not written directly, but the increment is represented by changing the bit state of the Flash storage unit (1 to 0). For example, when the variable increases by 1, 0 is written in the free cell of the current storage area to represent the current increment of the variable. By recording the number of 0s in the current area, the current value of the variable can be represented. When the number of 0s in the current area reaches the set threshold, for example, the 4KB storage area is all filled with "0", and the count value is transferred to the next storage area. For example, when the storage space of the first storage area is almost full, the total amount of variables recorded in the first storage area is transferred to the first address of the second storage area, and the storage unit of the first storage area is erased and reinitialized to 1 for the next cycle.
[0097] This method gradually transfers data to the next area through partition cycle, realizes the recycling of storage space and reduces the frequency of flash erasing. By writing 0s one by one in each area to indicate the change of incremental data, it can effectively reduce the wear of flash and increase the service life of flash memory.
[0098] In addition, the storage method of this embodiment is suitable for scenarios where incremental counts need to be recorded, such as the number of times a device is used, the system version number, etc. By writing the number of 0s in different areas to represent the accumulated count value, there is no need to frequently erase the contents of the Flash memory, which further improves the storage efficiency.
[0099] The present invention provides an innovative storage method, which can effectively improve the service life of Flash memory. Through an incremental storage method based on representing the size of variables with zero numbers and a partitioned circular storage mechanism, the number of erase and write times of Flash memory is significantly reduced, thereby providing a more efficient and durable data storage solution for various embedded systems, Internet of Things devices, etc.
[0100] Figure 5 is a schematic diagram of the structure of a data storage device of a Flash memory provided in an embodiment of the present application; Figure 5 As shown, the device comprises:
[0101] The storage area determination module 501 is used to determine at least two storage areas in the Flash memory, each storage area including a storage block and a real-time recording block;
[0102] The data recording module 502 is used to use the first area as an immediate writing area, and when it is recognized that the data to be stored increases, write the first value of the corresponding number as the second value in the real-time recording block in the first area according to the number of the increased data;
[0103] The data migration module 503 is used to write the storage blocks in the first area and the data to be stored recorded in the real-time recording blocks into the storage blocks in the second area after all the first values in the real-time recording blocks in the first area are written as second values, and use the second area as an immediate writing area;
[0104] The erasing processing module 504 is used to erase the storage blocks and real-time recording blocks in the first area.
[0105] The technical solution provided in this embodiment is to determine at least two storage areas in the Flash memory, each storage area includes a storage block and a real-time recording block; take the first area as the immediate writing area, when it is recognized that the data to be stored increases, write the first value of the corresponding number as the second value in the real-time recording block in the first area according to the number of data increases; after all the first values in the real-time recording block in the first area are written as the second value, write the data to be stored recorded by the storage block and the real-time recording block in the first area to the storage block in the second area, and take the second area as the immediate writing area; erase the storage block and the real-time recording block in the first area. This technical solution uses multiple storage areas for alternating storage, and when the data to be stored changes, synchronously records by writing the first value as the second value, so that it can be realized without the need for an erase operation, and after all the data in one area are written as the second value, it can be migrated to another area for recording, and the current area can be erased, which can effectively reduce the number of erasures, so as to ensure the accuracy of the stored data while reducing the number of erasures, thereby improving the service life of the Flash memory.
[0106] The data storage device of the Flash memory in the embodiment of the present application can be a device, or a component, an integrated circuit, or a chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0107] The data storage device of the Flash memory in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0108] The data storage device of the Flash memory provided in the embodiment of the present application can implement each process implemented by the above-mentioned method embodiments, and will not be described again here to avoid repetition.
[0109] Figure 6 Schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Figure 6 As shown, an embodiment of the present application also provides an electronic device 600, including a processor 601, a memory 602, and a program or instruction stored in the memory 602 and executable on the processor 601. When the program or instruction is executed by the processor 601, each process of the data storage device embodiment of the above-mentioned Flash memory is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0110] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0111] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the data storage device embodiment of the above-mentioned Flash memory is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0112] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0113] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the data storage device embodiment of the above-mentioned Flash memory, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0114] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0115] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0116] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0117] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0118] The above are only preferred embodiments of the present application and the technical principles used. The present application is not limited to the specific embodiments described herein, and various obvious changes, readjustments and substitutions that can be made by those skilled in the art will not deviate from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.
Claims
1. A data storage method of a Flash memory, characterized in that: The method comprises: Determine at least two storage areas in the Flash memory, each storage area including a storage block and a real-time recording block; The first area is used as an immediate writing area, and when it is recognized that the data to be stored increases, the first value of the corresponding number is written as the second value in the real-time recording block in the first area according to the number of the increased data; After all the first values in the real-time recording blocks in the first area are written as second values, the storage blocks in the first area and the data to be stored recorded in the real-time recording blocks are written into the storage blocks in the second area, and the second area is used as an immediate writing area; The storage blocks and the real-time recording blocks in the first area are erased.
2. The data storage method of the Flash memory according to claim 1, characterized in that: The method further comprises: When a query request for data to be stored is identified, the value stored in the storage block of the immediate write area is identified, and / or the number of second values written in the real-time record block of the immediate write area is identified to obtain the query result of the data to be stored.
3. The data storage method of the Flash memory according to claim 1, characterized in that: Writing the data to be stored recorded in the storage blocks and the real-time recording blocks in the first area into the storage blocks in the second area includes: The data to be stored recorded in the storage blocks and the real-time recording blocks in the first area are written into the storage blocks in the second area in a binary manner.
4. The data storage method of the Flash memory according to claim 3, characterized in that: Writing the data to be stored recorded in the storage blocks and the real-time recording blocks in the first area into the storage blocks in the second area in a binary manner includes: Reading the binary value in the storage block in the first area, and reading the number of second values in the real-time recording block in the first area, and adding them together to obtain the recorded data to be stored; The data is written into the storage block of the second area in binary form.
5. The data storage method of the Flash memory according to claim 1, characterized in that: When it is recognized that the data to be stored increases, writing the first value of the corresponding number as the second value in the real-time recording block in the first area according to the number of the increased data, includes: When it is recognized that the data to be stored increases, the corresponding number of values 1 is written as value 0 in the real-time recording block in the first area according to the number of increased data in a preset order.
6. The data storage method of the Flash memory according to claim 1, characterized in that: The method further comprises: After all first values in the real-time recording block in the second area are written as second values, the storage blocks in the second area and the data to be stored recorded in the real-time recording blocks are written to the storage blocks in the first area, and the first area is used as the immediate writing area.
7. The method for storing data in a Flash memory according to any one of claims 1 to 6, characterized in that: The data to be stored is monotonically increasing data.
8. A data storage device of a Flash memory, characterized in that: The device comprises: A storage area determination module, used to determine at least two storage areas in the Flash memory, each storage area including a storage block and a real-time recording block; A data recording module, configured to use the first area as an immediate writing area, and when recognizing that the data to be stored increases, write the first value of the corresponding number as the second value in the real-time recording block in the first area according to the number of the increased data; a data migration module, configured to write the storage blocks in the first area and the data to be stored recorded in the real-time recording blocks into the storage blocks in the second area after all the first values in the real-time recording blocks in the first area are written as second values, and use the second area as an immediate writing area; The erasing processing module is used to erase the storage blocks and real-time recording blocks in the first area.
9. An electronic device, characterized in that: The method comprises a processor, a memory and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the data storage method of the Flash memory as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by the processor, the steps of the data storage method of the Flash memory according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method for improving using life of storage and hardware device
CN101051522A
Data storage method and read-write equipment
CN112711378A
Flash memory data read-write method and flash memory data read-write device
CN114115700A
Counting value reading method and device, counting method and device, electronic equipment and storage medium
CN114329640A
Data storage method, electronic equipment and storage medium
CN117369735A