Data storage method and device based on flash memory, electric energy meter and storage medium

By identifying the failure risk level of flash memory sectors and adopting differentiated storage strategies, the problems of wasted flash memory storage space and data reliability are solved, achieving high-efficiency data storage security and reliability, and optimizing the overall performance of flash memory data storage.

CN120929014APending Publication Date: 2025-11-11SHIJIAZHUANG KE ELECTRIC
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511026579.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-24
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

In existing technologies, when using flash memory for data storage, the dual backup method leads to wasted storage space, and abnormal backup sectors may cause data read/write errors, storage failures, or even data loss, failing to guarantee the reliability and security of data storage.

Method used

By identifying the failure risk level of flash memory sectors, a differentiated storage strategy is adopted, including direct storage in low-risk sectors, partial backup in medium-risk sectors, and distributed storage in multiple low-risk sectors or adding checksums to avoid high-risk sectors, thereby achieving differentiated data storage based on sector risk.

Benefits of technology

While saving storage space, it improves the security and reliability of data storage, optimizes the overall performance of flash data storage, and reduces the risk of data read/write errors and loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929014A_ABST
    Figure CN120929014A_ABST
Patent Text Reader

Abstract

The invention provides a data storage method and device based on a flash memory, an electric energy meter and a storage medium, and belongs to the field of electric digital data processing. The method comprises the following steps: firstly, receiving a data storage request of target data, and determining a target sector according to the data storage request; determining a failure risk level of the target sector; as the failure risk level represents the possibility of damage of the target sector area, and different failure risk levels indicate that the possibility of damage of the corresponding target sector area is different, the target data is stored based on the failure risk level, differential data storage based on the sector risk can be realized, and the data storage efficiency is improved. And the security and the reliability of data storage are improved while the storage space is saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic digital data processing, and more particularly to a flash memory-based data storage method, apparatus, electricity meter, and storage medium. Background Technology

[0002] Flash memory is a non-volatile storage medium widely used in various industries due to its characteristics such as data retention after power failure, fast read / write speeds, small size, and low power consumption. For example, the power sector often uses flash memory to store smart grid electricity consumption data. Its storage structure typically consists of multiple sectors, each of which acts as a storage unit responsible for data writing, erasing, and reading operations.

[0003] In existing technologies, when using flash memory for data storage, a dual backup method is typically used to store data, and the backup data is used to restore the data after the primary data is damaged.

[0004] However, this approach leads to a waste of storage space, and if the backup sector also malfunctions, it may cause problems such as data read / write errors, storage failures, or even data loss, failing to guarantee the reliability and security of data storage. Summary of the Invention

[0005] This invention provides a flash memory-based data storage method, device, electricity meter, and storage medium to address the problems of poor data storage reliability and security.

[0006] In a first aspect, embodiments of the present invention provide a data storage method based on flash memory, wherein the flash memory includes multiple sectors of a preset size; characterized in that the method includes: Receive a data storage request for the target data, and determine the target sector based on the data storage request; Determine the failure risk level of the target sector; wherein, the failure risk level characterizes the probability of damage to the target sector; The target data is stored based on the failure risk level.

[0007] In one possible implementation, the failure risk level includes a first level, a second level, and a third level; the second level is higher than the first level, and the third level is higher than the second level. Determining the failure risk level of the target sector includes: If the target sector number is not found in the failure warning table, a data erasure operation is performed on the target sector, and the failure risk level of the target sector is determined based on the operation time of the data erasure operation. If the target sector number exists in the failure warning table, the failure risk level of the target sector can be read from the failure warning table; wherein, the failure warning table stores the sector numbers and failure risk levels with failure levels higher than the first level.

[0008] In one possible implementation, determining the failure risk level of the target sector based on the operation duration of the data erasure operation includes: The failure probability of the target sector is determined based on the mapping relationship between the operation duration, the pre-stored operation duration, and the failure probability. The failure risk level of the target sector is determined based on the relationship between the failure probability and the preset probability threshold; wherein the preset probability threshold is set based on data efficiency requirements.

[0009] In one possible implementation, before determining the failure probability of the target sector based on the mapping relationship between the operation duration, the pre-stored operation duration, and the failure probability, the method further includes: Construct a first mapping relationship between the number of data erasures in a sector and the operation time of the data erasure operation, and construct a second mapping relationship between the number of data erasures and the failure probability of a sector; Based on the first mapping relationship and the second mapping relationship, the mapping relationship between the operation time and the failure probability is obtained.

[0010] In one possible implementation, the preset probability threshold includes a first preset threshold, a second preset threshold, and a third preset threshold; Determining the failure risk level of the target sector based on the relationship between the failure probability and a preset probability threshold includes: If the failure probability is less than the first preset threshold, then the failure risk level of the target sector is determined to be the first level; If the failure probability is greater than the first preset threshold and less than the second preset threshold, then the failure risk level of the target sector is determined to be the second level. If the failure probability is greater than the second preset threshold, then the failure risk level of the target sector is determined to be the third level.

[0011] In one possible implementation, the failure warning table also stores the numbers of replacement sectors corresponding to sectors with a failure risk level of the third level. The storage of the target data based on the failure risk level includes: If the failure risk level of the target sector is the first level, then the target data is written into the target sector; If the failure risk level of the target sector is the second level, then a write operation to write the target data to the target sector is performed, and the target data is stored according to the number of times the write operation is performed; If the failure risk level of the target sector is the third level, determine the replacement sector corresponding to the target sector and write the target data into the replacement sector corresponding to the target sector; wherein the failure risk level of the replacement sector is lower than that of the target sector.

[0012] In one possible implementation, storing the target data based on the number of times the write operation is performed includes: If the number of executions exceeds the preset number, the failure risk level of the target sector is redefined as the third level, and a replacement sector corresponding to the target sector is determined. The target data is then written into the replacement sector corresponding to the target sector.

[0013] In a first aspect, embodiments of the present invention provide a flash memory-based data storage device, wherein the flash memory includes a plurality of sectors of a preset size; the device includes: The first processing unit is used to receive a data storage request for target data and determine the target sector based on the data storage request; The second processing unit is used to determine the failure risk level of the target sector; wherein the failure risk level characterizes the probability of damage to the target sector; A storage unit is used to store the target data based on the failure risk level.

[0014] Thirdly, embodiments of the present invention provide an electricity meter, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect or any possible implementation of the first aspect.

[0015] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect or any possible implementation thereof.

[0016] This invention provides a flash memory-based data storage method, apparatus, electricity meter, and storage medium. First, a data storage request for target data is received, and a target sector is determined based on the request. Then, the failure risk level of the target sector is determined to identify the likelihood of sector damage in advance. Finally, the target data is stored based on the failure risk level. Since the failure risk level characterizes the probability of damage to the target sector, different failure risk levels indicate different degrees of likelihood of damage to the corresponding target sector. Therefore, this embodiment can achieve differentiated data storage based on sector risk, saving storage space while improving the security and reliability of data storage. In summary, this invention can effectively reduce storage space waste, improve storage space utilization, enhance the reliability and security of data storage, and optimize the overall performance of flash memory data storage. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart illustrating the implementation of the flash memory-based data storage method provided in this embodiment of the invention. Figure 2 This is a flowchart illustrating another flash-based data storage method provided in an embodiment of the present invention. Figure 3 This is a schematic diagram illustrating the relationship between the number of sector erases and the erase duration provided in an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating the relationship between the number of sector erases and the failure probability provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a flash memory-based data storage device provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of the energy meter provided in an embodiment of the present invention. Detailed Implementation

[0019] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.

[0020] Current technologies using flash memory for data storage typically employ a dual-backup approach, restoring data from the backup in case of primary data failure. However, this method leads to wasted storage space, and if the backup sector also fails, it can cause data read / write errors, storage failures, or even data loss, failing to guarantee the reliability and security of data storage.

[0021] In order to improve storage space utilization while enhancing the security and reliability of data storage, the embodiments of this application first receive a data storage request for target data and determine the target sector based on the data storage request; then determine the failure risk level of the target sector; and finally store the target data based on the failure risk level. This can realize differentiated data storage based on sector risk, thereby saving storage space while improving the security and reliability of data storage.

[0022] To make the objectives, technical solutions, and advantages of the present invention clearer, specific embodiments will be described below in conjunction with the accompanying drawings.

[0023] Figure 1 The flowchart illustrates the implementation of a flash memory-based data storage method according to an embodiment of the present invention. The flash memory includes multiple sectors of a preset size; details are as follows: Step 101: Receive the data storage request for the target data, and determine the target sector based on the data storage request.

[0024] The target data can include real-time electricity metering data from smart meters (such as current / voltage / power values ​​every 15 minutes), daily total electricity consumption statistics, meter device status data (such as battery level and communication module signal strength), and abnormal electricity event records (such as short circuit alarms and overload alerts).

[0025] Data storage requests can include information such as the content of the target data, data identifier, storage priority, and required storage space size.

[0026] For example, in this embodiment, the target sector is determined based on information such as the content of the target data, data identifier, storage priority, and required storage space size in the data storage request.

[0027] In one example, this embodiment first parses the core parameters contained in the data storage request, such as: target data type, data size, storage priority (e.g., abnormal event records are high priority and need to be stored permanently; real-time data is medium priority and can be retained for 30 days), and read / write frequency requirements (e.g., real-time data needs to be written frequently, and historical data needs to be read frequently). Then, it combines the status database of each sector of the flash memory to perform multi-dimensional matching, including space matching: filtering free sectors with remaining storage space greater than the target data size; performance matching: prioritizing the allocation of sectors with fast read / write response speeds for high-frequency read / write data, etc., to determine the target sector. Step 102: Determine the failure risk level of the target sector; whereby the failure risk level characterizes the likelihood of damage to the target sector.

[0028] Among them, the failure risk level is a quantitative or qualitative description of the probability that a sector will be damaged in the future (such as being unable to read or write, data errors, physical damage, etc.), and can include three levels: high risk, medium risk, and low risk, or other sub-levels. For example, this embodiment determines the risk level by collecting historical operating data and current status parameters of the target sector and combining them with a pre-built risk assessment model or risk assessment rules.

[0029] Historical operating data and current status parameters may include one or more of the following: sector write / erase count, erase duration, historical fault records, current voltage stability, and storage environment temperature.

[0030] For example, if the target sector meets two or more of the following conditions: the number of write-erase cycles exceeds 80% of the rated lifespan, the erase duration exceeds the preset duration, and there is slight delay in the last three read-write operations, it can be judged as a high-risk level; if any of the above conditions are met, it is judged as a medium-risk level; if none of the above conditions are met, it is judged as a low-risk level. Step 103: Store the target data based on the failure risk level.

[0031] This embodiment adopts a differentiated storage strategy based on the failure risk level of the target sector, ensuring the security and reliability of data storage while reducing storage space waste.

[0032] Among them, differentiated storage strategies based on risk levels may include: If the target sector is of low risk, the target data can be stored directly in that sector without additional backup, saving storage space. If the target sector is of medium risk, only critical data segments can be partially backed up, or another low-risk sector can be selected for storage. If the target sector is of high risk, targeted protection measures should be adopted, such as distributing the data across multiple low-risk sectors, or adding checksums and redundancy information to improve data recovery capabilities. In summary, the embodiments of the present invention can effectively reduce storage space waste, improve storage space utilization, enhance the reliability and security of data storage, optimize the overall performance of flash memory data storage, and effectively ensure the stable storage and reading / writing of data in flash memory.

[0033] Figure 2 The following is a flowchart illustrating another flash memory-based data storage method provided in an embodiment of the present invention. The flash memory includes multiple sectors of a preset size, as detailed below: Step 201: Receive the data storage request for the target data and determine the target sector based on the data storage request.

[0034] For example, see this step. Figure 1 The relevant descriptions in the embodiments will not be repeated here.

[0035] Step 202: If the target sector number is not found in the failure warning table, perform a data erasure operation on the target sector, and determine the failure probability of the target sector based on the operation time of the data erasure operation, the mapping relationship between the pre-stored operation time and the failure probability.

[0036] In one feasible implementation, before step 202, the method further includes: constructing a first mapping relationship between the number of data erasures of a sector and the operation duration of the data erasure operation, and constructing a second mapping relationship between the number of data erasures and the failure probability of a sector; and obtaining a mapping relationship between the operation duration and the failure probability based on the first mapping relationship and the second mapping relationship.

[0037] Because repeated FLASH erasures lead to a reduction in the thickness of the floating gate oxide layer (TDDB effect), the electron tunneling efficiency decreases, and the trap charge generated during the erasure process increases, requiring a longer time to release the charge, thus increasing the FLASH erasure time.

[0038] In one example, this embodiment uses 100 flash memory chips, each containing 1024 sectors, equivalent to 102,400 sector samples. Full-capacity cyclic erasure and write operations are performed under constant temperature. After every 2000 erase / write cycles, the average erase time per sector is calculated, and the number of bad blocks is detected. The experiment initially showed that erasing one sector took 50 milliseconds (ms). The erasure time increased continuously with the number of erase cycles until the sector was damaged, resulting in the following curve: Figure 3 As shown, Figure 3 This is a schematic diagram showing the relationship between the number of sector erasures and the erasure duration provided in an embodiment of the present invention.

[0039] Furthermore, this embodiment also conducted experiments on sectors with a total sample size of 102,400, and obtained the relationship between the number of sector erasures and the probability of sector damage as shown in Table 1 below.

[0040] Table 1. Relationship between sector erase count and sector damage probability

[0041] Since the failure of FLASH memory is essentially due to wear and tear caused by the number of erase cycles, the cumulative damage from these erase cycles conforms to the Weibull distribution's property that "the failure probability monotonically increases with the number of erase cycles." The experimentally obtained failure probability curve matches the Weibull failure probability function.

[0042] Where F represents the failure probability, N is the number of erasures; λ is the scale parameter, i.e., the number of times a complete failure is required, and in this experiment, λ for FLASH is 1,000,000 times; k is the failure mode coefficient, with a value of 3.2.

[0043] Based on the above experiments, the relationship between the number of data erases in a sector and the probability of sector failure was established, as follows: Figure 4 As shown, Figure 4 This is a schematic diagram illustrating the relationship between the number of sector erases and the failure probability provided in an embodiment of the present invention.

[0044] This embodiment maps the relationship between operation duration and failure probability based on the first mapping relationship between sector data erasure time and erasure count, and the second mapping relationship between failure probability and erasure count.

[0045] This embodiment also pre-constructs a failure warning table, which updates in real time the numbers and corresponding risk level information of sectors that are determined to have a failure risk level higher than the first level. Here, the first level can be understood as a low-risk level, the second risk level as a medium-risk level, and the third risk level as a high-risk level.

[0046] For example, if the failure warning table does not include the target sector number, the risk level of the target sector may be low risk, or the risk level of the target sector may not have been determined in the past. Therefore, this embodiment performs the determination of the risk level of the target sector, including: performing a data erasure operation on the target sector, and determining the failure probability of the target sector based on the operation time of the data erasure operation, the mapping relationship between the pre-stored operation time and the failure probability.

[0047] In this embodiment, when erasing the target sector, a pre-set timer is used to count the real-time erasure time of this sector, that is, the operation duration of the data erasure operation. Based on the mapping relationship between the operation duration and the failure probability, the failure probability of the target sector is determined.

[0048] This embodiment constructs a mapping relationship through experimental data to quantify the probability of sector failure, enabling accurate assessment of the probability of sector failure. This provides objective data for risk level determination and improves the scientific nature of risk identification.

[0049] Furthermore, this embodiment determines the failure probability by the data erasure time, which is simple, efficient, and can effectively improve the efficiency of sector risk assessment.

[0050] Step 203: Determine the failure risk level of the target sector based on the relationship between the failure probability and the preset probability threshold; wherein, the preset probability threshold is set based on the data efficiency requirements.

[0051] The failure risk level characterizes the likelihood of damage to the target sector. Failure risk levels are categorized into three levels: Level 1, Level 2, and Level 3; Level 2 is higher than Level 1, and Level 3 is higher than Level 2.

[0052] In one example, the preset probability thresholds include a first preset threshold, a second preset threshold, and a third preset threshold; step 203 includes: If the failure probability is less than the first preset threshold, the failure risk level of the target sector is determined to be Level 1; if the failure probability is greater than the first preset threshold and less than the second preset threshold, the failure risk level of the target sector is determined to be Level 2; if the failure probability is greater than the second preset threshold, the failure risk level of the target sector is determined to be Level 3.

[0053] For example, in this embodiment, a preset probability threshold is determined based on the product characteristics of FLASH or the efficiency requirements for data storage. The higher the efficiency requirements for data storage, the smaller the value of the preset probability threshold.

[0054] This embodiment achieves quantitative classification of risk levels by matching probability thresholds with data efficiency requirements, making risk assessment more in line with actual data scenario needs.

[0055] The first preset threshold, the second preset threshold, and the third preset threshold increase sequentially, and the failure risk levels of the first, second, and third levels increase sequentially.

[0056] After obtaining the risk level of the target sector, if the risk level is higher than the first level, the target sector number and the corresponding risk level are updated and recorded in the failure warning table in real time.

[0057] In one feasible implementation, if the risk level of a sector is level three, a replacement sector for the target sector is determined, and the number of the replacement sector is recorded in the failure warning table. The risk level of the replacement sector is lower than that of the target sector.

[0058] Step 204: If the target sector number exists in the failure warning table, the failure risk level of the target sector is read from the failure warning table; wherein, the failure warning table stores the sector number and failure risk level of the sector with a failure level higher than the first level.

[0059] For example, after step 201, if the target sector number exists in the failure warning table, it means that the risk level of the target sector has been determined in the past, and the failure risk level of the target sector can be directly read from the failure warning table.

[0060] This embodiment improves the overall efficiency of the storage process by reusing the failure warning table to avoid repeated evaluation of risky sectors.

[0061] Step 205: Store the target data based on the failure risk level.

[0062] If the failure risk level of the target sector is Level 1, then the target data is written to the target sector; if the failure risk level of the target sector is Level 2, then a write operation is performed to write the target data to the target sector, and the target data is stored according to the number of times the write operation is performed; if the failure risk level of the target sector is Level 3, then the replacement sector corresponding to the target sector is determined, and the target data is written to the replacement sector corresponding to the target sector; wherein, the failure risk level of the replacement sector is lower than that of the target sector.

[0063] If the number of executions exceeds the preset number, the failure risk level of the target sector is redefined as Level 3, and a replacement sector corresponding to the target sector is determined. The target data is then written into the replacement sector corresponding to the target sector.

[0064] The failure warning table also stores the numbers of replacement sectors corresponding to sectors with a failure risk level of level three.

[0065] For example, in this embodiment, if the risk level of the target sector is the first level, such as the low risk level, the target data can be directly stored in the sector.

[0066] If the target sector is at level two, such as medium risk, a write operation to write the target data to the target sector can be performed. In this embodiment, a preset limit for the number of write operations corresponding to medium risk sector is set, such as 3 times. If the write operation fails after 3 attempts, the risk level of the target sector is determined to be upgraded to level three, i.e., high risk. At this time, a replacement sector corresponding to the target sector is determined. The risk level of the replacement sector is lower than level three. The target data is written to the replacement sector, and the risk level of the target sector is updated to level three in the failure warning table. The number of the corresponding replacement sector is also updated in the failure warning table. If the target data is successfully written to the target sector within the preset number of attempts, the risk level of the target sector remains at level two.

[0067] If the target sector is at level three, such as high-risk level, then the target data is stored in the replacement sector according to the replacement sector number recorded in the failure warning table.

[0068] Alternatively, determine the replacement sector corresponding to the target sector, store the target data in the replacement sector, and store the number of the replacement sector in the corresponding column of the target sector in the failure warning table. This embodiment uses a high-risk sector replacement mechanism to proactively avoid the potential risks of data storage in high-risk areas, reducing the risk of data read / write errors and loss, and enhancing data storage security.

[0069] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0070] The following are device embodiments of the present invention. For details not described in detail, please refer to the corresponding method embodiments described above.

[0071] Figure 5 A schematic diagram of a flash memory-based data storage device provided in an embodiment of the present invention is shown. The flash memory includes multiple sectors of a preset size. For ease of explanation, only the parts relevant to the embodiments of the present invention are shown, and are described in detail below: like Figure 5 As shown, the flash-based data storage device includes: The first processing unit 51 is used to receive a data storage request for the target data and determine the target sector based on the data storage request.

[0072] The second processing unit 52 is used to determine the failure risk level of the target sector; wherein, the failure risk level characterizes the possibility of damage to the target sector.

[0073] Storage unit 53 is used to store target data based on the failure risk level.

[0074] In one possible implementation, the failure risk levels include a first level, a second level, and a third level; the second level is higher than the first level, and the third level is higher than the second level; the second processing unit 52 is specifically used for: If the target sector number is not found in the failure warning table, a data erasure operation is performed on the target sector, and the failure risk level of the target sector is determined based on the operation time of the data erasure operation; if the target sector number is found in the failure warning table, the failure risk level of the target sector is read from the failure warning table; the failure warning table stores the numbers and failure risk levels of sectors with failure levels higher than the first level.

[0075] In one possible implementation, the second processing unit 52 is specifically used for: The failure probability of the target sector is determined based on the mapping relationship between operation time, pre-stored operation time and failure probability; the failure risk level of the target sector is determined based on the relationship between failure probability and preset probability threshold; wherein, the preset probability threshold is set based on data efficiency requirements.

[0076] In one possible implementation, before the second processing unit 52, the device further includes a construction unit, specifically configured to: construct a first mapping relationship between the number of data erasures of a sector and the operation duration of the data erasure operation, and construct a second mapping relationship between the number of data erasures and the failure probability of a sector; and obtain a mapping relationship between the operation duration and the failure probability based on the first and second mapping relationships.

[0077] In one possible implementation, the preset probability threshold includes a first preset threshold, a second preset threshold, and a third preset threshold; the second processing unit 52 is further configured to: If the failure probability is less than the first preset threshold, the failure risk level of the target sector is determined to be Level 1; if the failure probability is greater than the first preset threshold and less than the second preset threshold, the failure risk level of the target sector is determined to be Level 2; if the failure probability is greater than the second preset threshold, the failure risk level of the target sector is determined to be Level 3.

[0078] In one possible implementation, the failure warning table also stores the numbers of replacement sectors corresponding to sectors with a failure risk level of level three; storage unit 53 is specifically used for: If the failure risk level of the target sector is Level 1, then the target data is written to the target sector; if the failure risk level of the target sector is Level 2, then a write operation is performed to write the target data to the target sector, and the target data is stored according to the number of times the write operation is performed; if the failure risk level of the target sector is Level 3, then the replacement sector corresponding to the target sector is determined, and the target data is written to the replacement sector corresponding to the target sector; wherein, the failure risk level of the replacement sector is lower than that of the target sector.

[0079] In one possible implementation, storage unit 53 is further used for: If the number of executions exceeds the preset number, the failure risk level of the target sector is redefined as Level 3, and the replacement sector corresponding to the target sector is determined. The target data is then written into the replacement sector corresponding to the target sector.

[0080] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0081] Figure 6 This is a schematic diagram of an electricity meter provided in an embodiment of the present invention. Figure 6 As shown, the electricity meter in this embodiment includes a processor 60 and a flash memory 61. The flash memory 61 includes a plurality of sectors of a preset size. The processor 60 executes the steps in the various method embodiments described above. Alternatively, the processor 60 implements the functions of each unit in the various device embodiments described above.

[0082] The electricity meter may include, but is not limited to, a processor 60 and flash memory 61. Those skilled in the art will understand that... Figure 6 This is merely an example of an electricity meter and does not constitute a limitation on electricity meters. It may include more or fewer components than shown in the illustration, or combine certain components, or different components. For example, an electricity meter may also include input / output devices, network access devices, buses, etc.

[0083] The processor 60 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0084] Flash memory 61 can be an internal storage unit of the electricity meter. Flash memory 61 can also be an external storage device of the electricity meter. Flash memory 61 can be used to store data that the electricity meter has already output or will output.

[0085] For the sake of simplicity and clarity, only the above-described functional modules / units are used as examples. In practical applications, the functions described above can be assigned to different functional modules / units as needed. These modules / units can be implemented in hardware, software, or a combination of both.

[0086] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the methods described in the above-described method embodiments.

[0087] This invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the methods described in the above-described method embodiments.

[0088] Computer programs include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. Computer-readable media can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.

[0089] In the above embodiments, the descriptions of each embodiment have their own emphasis. Parts not detailed or described in a particular embodiment can be referred to in the relevant descriptions of other embodiments. Unless otherwise specified or in conflict with logic, the terminology and / or descriptions between different embodiments are consistent and can be referenced interchangeably. Technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships.

[0090] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A flash memory-based data storage method, characterized in that, The flash memory includes multiple sectors of a preset size; the method includes: Receive a data storage request for the target data, and determine the target sector based on the data storage request; Determine the failure risk level of the target sector; wherein, the failure risk level characterizes the probability of damage to the target sector; The target data is stored based on the failure risk level.

2. The flash memory-based data storage method according to claim 1, characterized in that, The failure risk levels include a first level, a second level, and a third level; the second level is higher than the first level, and the third level is higher than the second level. Determining the failure risk level of the target sector includes: If the target sector number is not found in the failure warning table, a data erasure operation is performed on the target sector, and the failure risk level of the target sector is determined based on the operation time of the data erasure operation. If the target sector number exists in the failure warning table, the failure risk level of the target sector can be read from the failure warning table; wherein, the failure warning table stores the sector numbers and failure risk levels with failure levels higher than the first level.

3. The flash memory-based data storage method according to claim 2, characterized in that, Determining the failure risk level of the target sector based on the operation duration of the data erasure operation includes: The failure probability of the target sector is determined based on the mapping relationship between the operation duration, the pre-stored operation duration, and the failure probability. The failure risk level of the target sector is determined based on the relationship between the failure probability and the preset probability threshold; wherein the preset probability threshold is set based on data efficiency requirements.

4. The flash memory-based data storage method according to claim 3, characterized in that, Before determining the failure probability of the target sector based on the mapping relationship between the operation duration, the pre-stored operation duration, and the failure probability, the method further includes: Construct a first mapping relationship between the number of data erasures in a sector and the operation time of the data erasure operation, and construct a second mapping relationship between the number of data erasures and the failure probability of a sector; Based on the first mapping relationship and the second mapping relationship, the mapping relationship between the operation time and the failure probability is obtained.

5. The flash memory-based data storage method according to claim 3, characterized in that, The preset probability thresholds include a first preset threshold, a second preset threshold, and a third preset threshold; The step of determining the failure risk level of the target sector based on the relationship between the failure probability and a preset probability threshold includes: If the failure probability is less than the first preset threshold, then the failure risk level of the target sector is determined to be the first level; If the failure probability is greater than the first preset threshold and less than the second preset threshold, then the failure risk level of the target sector is determined to be the second level. If the failure probability is greater than the second preset threshold, then the failure risk level of the target sector is determined to be the third level.

6. The flash memory-based data storage method according to any one of claims 2-5, characterized in that, The failure warning table also stores the numbers of the replacement sectors corresponding to the sectors with a failure risk level of the third level. The storage of the target data based on the failure risk level includes: If the failure risk level of the target sector is the first level, then the target data is written into the target sector; If the failure risk level of the target sector is the second level, then a write operation to write the target data to the target sector is performed, and the target data is stored according to the number of times the write operation is performed; If the failure risk level of the target sector is the third level, determine the replacement sector corresponding to the target sector and write the target data into the replacement sector corresponding to the target sector; wherein the failure risk level of the replacement sector is lower than that of the target sector.

7. The flash memory-based data storage method according to claim 6, characterized in that, The step of storing the target data based on the number of times the write operation is performed includes: If the number of executions exceeds the preset number, the failure risk level of the target sector is redefined as the third level, and a replacement sector corresponding to the target sector is determined. The target data is then written into the replacement sector corresponding to the target sector.

8. A flash memory-based data storage device, characterized in that, The flash memory includes multiple sectors of a preset size; the device includes: The first processing unit is used to receive a data storage request for target data and determine the target sector based on the data storage request; The second processing unit is used to determine the failure risk level of the target sector; wherein the failure risk level characterizes the probability of damage to the target sector; A storage unit is used to store the target data based on the failure risk level.

9. An electricity meter, characterized in that, The device includes flash memory and a processor, the flash memory comprising a plurality of sectors of a preset size, and the processor being configured to execute the flash memory-based data storage method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the flash-based data storage method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for using flash memory

    CN101441891A

  • Systems and methods of estimating and managing storage device degradation

    CN110321067A

  • Electric energy meter detection method, electric energy meter and computer readable storage medium

    CN113948149A

  • Data reading method and device, computer equipment and storage medium

    CN120066417A