CN-115543189-B - Data storage method and device of flash memory, terminal equipment and storage medium
Abstract
The invention discloses a data storage method, a device, a terminal device and a storage medium of a flash memory, wherein the data storage method of the flash memory comprises the following steps of calculating respective first error bit number and basic error bit number of each storage block in the initialized flash memory; the method comprises the steps of adding a basic error bit number and a first error bit number to a wear table of a flash memory, determining a target storage block in each storage block according to the wear table, wherein the sum of the second error bit number and the basic error bit number of the target storage block is minimum in the wear table, the second error bit number is the product of the first error bit number and the number of times of erasure, and storing data of the flash memory according to the target storage block. The invention realizes the purpose of avoiding the slow reading of data caused by excessive error bit numbers and erasure times in the data of the storage block.
Inventors
- DENG WEICHAO
- WU DAWEI
- LI XIAOQIANG
Assignees
- 深圳市硅格半导体有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20220913
Claims (9)
- 1. A data storage method of a flash memory, the data storage method of the flash memory comprising the steps of: calculating the respective first error bit number and basic error bit number of each storage block in the initialized flash memory; adding the basic error bit number and the first error bit number to a wear table of the flash memory, wherein the wear table comprises respective erasure times of each storage block; Determining a target storage block in each storage block according to the wear table, wherein the sum of the second error bit number and the basic error bit number of the target storage block is the smallest in the wear table, and the second error bit number is the product of the first error bit number and the erasing times; performing data storage of the flash memory according to the target storage block; the step of calculating the respective first error bit number and basic error bit number of each storage block in the initialized flash memory comprises the following steps: erasing data on each storage block in the initialized flash memory and rewriting data on the storage block; reading the rewritten data from each storage block to obtain the respective basic error bit number of each storage block; After repeatedly performing a preset number of erasing operations on each storage block, rewriting data on each storage block, and respectively reading the rewritten data from each storage block to obtain a respective third error bit number of each storage block; And for each storage block, calculating a difference value between the basic error bit number and the third error bit number, dividing the absolute value of the difference value by the preset number to obtain the average error bit number of the storage block, and calculating the error bit number in every 2KB data by using the average error bit number.
- 2. The data storage method of a flash memory according to claim 1, wherein after the step of storing data of the flash memory according to the target storage block, the data storage method of the flash memory further comprises: Updating the wear table according to each storage block in the flash memory, so as to determine a target storage block in each storage block according to the updated wear table.
- 3. The method for storing data in a flash memory according to claim 2, wherein the method for storing data in a flash memory further comprises: monitoring the use time of the flash memory; The step of updating the wear table according to each storage block in the flash memory includes: For each storage block, when the monitored use time length is equal to a preset time length, after the first erasing operation is performed on the storage block, wherein the use time length is equal to the preset time length, calculating the fourth error bit number of the storage block; and updating the wear table by using the fourth error bit number.
- 4. The method for storing data in a flash memory according to claim 2, wherein the step of updating the wear table according to each of the memory blocks in the flash memory comprises: When determining that the abrasion blocks with the same erasing times as the preset times exist in each storage block of the flash memory, after performing first erasing operation on the abrasion blocks with the same erasing times as the preset times, calculating the fifth error bit number of the abrasion blocks; And updating the wear table by using the fifth error bit number.
- 5. The method for storing data in a flash memory according to claim 4, wherein before the step of calculating the fifth number of erroneous bits of the worn block, the method for storing data in a flash memory further comprises: performing data exchange on the abrasion blocks in the storage blocks of the flash memory; the step of calculating the fifth error bit number of the wear block includes: and calculating the fifth error bit number of the abrasion block after data exchange.
- 6. The method for storing data in a flash memory according to claim 2, wherein the method for storing data in a flash memory further comprises: determining the data storage amount of the flash memory; The step of updating the wear table according to each storage block in the flash memory includes: For each storage block, when the data storage amount of the flash memory reaches a preset storage amount threshold, after performing a first erasing operation on the storage block after the data storage amount reaches the storage amount threshold, calculating the sixth error bit number of each storage block; and updating the wear table by using each sixth error bit number.
- 7. A data storage device of a flash memory, the data storage device of the flash memory comprising: the computing module is used for computing the respective first error bit number and the basic error bit number of each storage block in the initialized flash memory; the adding module is used for adding the basic error bit number and the first error bit number to a wear table of the flash memory, wherein the wear table comprises respective erasing times of each storage block; the determining module is used for determining a target storage block in each storage block according to the abrasion table, wherein the sum of the second error bit number and the basic error bit number of the target storage block is the minimum value in the abrasion table, and the second error bit number is the product of the first error bit number and the erasing times; The determining module is further used for storing data of the flash memory according to the target storage block; The computing module is further used for erasing data on each storage block in the initialized flash memory and rewriting data on the storage block, reading the rewritten data from each storage block to obtain the respective basic error bit number of each storage block, repeatedly performing a preset number of erasing operations on each storage block, then rewriting data on each storage block, and respectively reading the rewritten data from each storage block to obtain the respective third error bit number of each storage block, and for each storage block, calculating the difference between the basic error bit number and the third error bit number, dividing the absolute value of the difference by the preset number to obtain the average error bit number of the storage block, and calculating the error bit number in each 2KB data by using the average error bit number.
- 8. A terminal device, characterized in that it comprises a memory, a processor and a data storage program of a flash memory stored on the memory and executable on the processor, the data storage program of the flash memory, when executed by the processor, implementing the steps of the data storage method of the flash memory according to any one of claims 1 to 6.
- 9. A computer storage medium, characterized in that it has stored thereon a computer program which, when executed by a processor, implements the steps of the data storage method of a flash memory according to any of claims 1 to 6.
Description
Data storage method and device of flash memory, terminal equipment and storage medium Technical Field The present invention relates to the field of memory technologies, and in particular, to a data storage method and apparatus for a flash memory, a terminal device, and a computer storage medium. Background Error correction can be performed on error bits in data stored in the flash memory in a hard solution or soft solution mode. When the number of error bits in the data stored in the flash memory is small, hard solution can be adopted for error correction, but when the number of error bits in the data stored in the flash memory exceeds a certain number, soft solution is adopted for error correction. The soft solution needs to match with the hard solution module for multiple times, so that when the number of error bits in data stored in a block in the flash memory is too large, the reading speed is slow. When data in a flash memory needs to be erased, all data in a block where the data is located often needs to be erased. The number of erasures per block is limited, repeated erasures of the same block may lead to excessive wear of the block, thereby increasing the number of erroneous bits in the data of the block, and also to a slower reading speed due to excessive wear of the block. The foregoing is provided merely for the purpose of facilitating understanding of the technical solutions of the present invention and is not intended to represent an admission that the foregoing is prior art. Disclosure of Invention The invention mainly aims to provide a data storage method, a data storage device, terminal equipment and a computer storage medium of a flash memory, and aims to solve the technical problems of excessive block wear of the flash memory and slow reading speed caused by excessive number of error bits in data stored on the block. In order to achieve the above object, the present invention provides a data storage method of a flash memory, the data storage of the flash memory comprising the steps of: calculating the respective first error bit number and basic error bit number of each storage block in the initialized flash memory; adding the basic error bit number and the first error bit number to a wear table of the flash memory, wherein the wear table comprises respective erasure times of each storage block; Determining a target storage block in each storage block according to the wear table, wherein the sum of the second error bit number and the basic error bit number of the target storage block is the smallest in the wear table, and the second error bit number is the product of the first error bit number and the erasing times; and storing data of the flash memory according to the target storage block. Optionally, the first number of error bits is the number of error bits existing in each 2KB data on the memory block, and the step of calculating the respective first number of error bits of each memory block in the initialized flash memory includes: erasing data on each storage block in the initialized flash memory and rewriting data on the storage block; reading the rewritten data from each storage block to obtain the respective basic error bit number of each storage block; After repeatedly performing a preset number of erasing operations on each storage block, rewriting data on each storage block, and respectively reading the rewritten data from each storage block to obtain a respective third error bit number of each storage block; And for each storage block, calculating a difference value between the basic error bit number and the third error bit number, dividing the absolute value of the difference value by the preset number to obtain the average error bit number of the storage block, and calculating the error bit number in every 2KB data by using the average error bit number. Optionally, after the step of storing data of the flash memory according to the target storage block, the data storage method of the flash memory further includes: Updating the wear table according to each storage block in the flash memory, so as to determine a target storage block in each storage block according to the updated wear table. Optionally, the data storage method of the flash memory further includes: monitoring the use time of the flash memory; The step of updating the wear table according to each storage block in the flash memory includes: For each storage block, when the monitored use time length is equal to a preset time length, after the first erasing operation is performed on the storage block, wherein the use time length is equal to the preset time length, calculating the fourth error bit number of the storage block; and updating the wear table by using the fourth error bit number. Optionally, the step of updating the wear table according to each storage block in the flash memory includes: When determining that the abrasion blocks with the same erasing times as the preset times exist in each storage block of