A power failure storage medium failure processing and service life extension method and system
By designing a fault-tolerant judgment mechanism and a reasonable data structure, the problem of inconsistent service life of storage media after power failure is solved, its service life is extended and the reliability of the product is improved.
Patent Information
- Application Number
- CN202411893933.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-12-20
AI Technical Summary
The number of erase and write cycles and service life of existing power-off storage media cannot be standardized, resulting in functional failure, affecting product quality and causing customer complaints.
By designing a reasonable fault-tolerant judgment mechanism, increasing the number of write times of power-off storage media, and adopting reasonable data structure and control algorithm, its service life can be extended.
It extends the service life of power-off storage media, improves product reliability and stability, and reduces customer complaints caused by premature failure.
Smart Images

Figure CN119832964B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of storage technology, and in particular relates to a method and system for handling failures of a power-off storage medium and extending its service life. Background Art
[0002] In many electronic devices, power-off storage media plays an indispensable role in preserving critical data.
[0003] However, the key parameters and user data of most smart home appliances need to be memorized when the power is off. Commonly used power-off storage media for home appliances include flash, eeprom, etc. These storage media have a certain number of erase and write cycles and service life, but the differences between these storage media cannot be unified, which will cause severe deviations in the important indicators of the power-off storage media, and make the number of erase and write cycles and service life of a single write area lower than the nominal value, and even lead to functional failure, resulting in reduced product quality and serious customer complaints or customer returns.
[0004] Therefore, the present invention provides a method and system for handling power-off storage medium failure and extending service life to solve the above technical problems. Summary of the Invention
[0005] In response to the above problems, the purpose of the present invention is to provide a method and system for fault handling and service life extension of a power-off storage medium, which has reasonable fault tolerance judgment, increases the number of times the power-off storage medium is repeatedly written during the use cycle, and thus can extend the rated service life of the power-off medium.
[0006] The present invention provides a method for handling power-off storage medium faults and extending service life, which includes:
[0007] S1, after the user turns on the appliance, the program is started and the arithmetic logic data structure is initialized. The arithmetic logic data structure includes the current write sector number, the current ID number, the page write address, the number of write failures, and the ID identification code. The arithmetic logic data structure is configured as follows: the lower address bits of a single sector are used as the data area to store multiple data frames, the upper address bits of a single sector are used as the ID area, and the storage location of a single frame of data corresponds one-to-one with the ID area;
[0008] S2, reading the content of the ID area with the set starting address, reading out the entire ID area and querying the ID identification code from the end;
[0009] S3, based on the queried ID identification code, reading the single frame data stored in the corresponding data area and performing data verification. If the verification is successful, the working parameters are assigned, and the ID areas of all sectors of the power-off storage medium are sequentially polled to locate the sectors used before the power off;
[0010] S4, setting the data area as a working parameter data area, a parameter backup area, and a comparison area. When there is a difference between the data in the working parameter data area and the data in the comparison area, a write process is triggered, and the ID area number to be written next is recalculated. The write operation is cyclically performed within a single sector until the erase and write life of the single sector reaches a preset judgment condition and then the next sector is switched to use;
[0011] S5, write and read verification covers the data area read and write verification and the ID area read and write verification. If the ID area verification is successful, the write is determined to be successful, and the backup area read and write verification is performed according to the same logic. At the same time, a rewrite number threshold is set, and data reading and writing are performed after a single sector is written; if the data area read and write fails, switch to the next ID area for re-reading and writing. After a certain number of rewrite failures, enter the voltage detection judgment, measure the voltage deviation degree based on the voltage variance, if the voltage threshold and voltage deviation are too large, it is determined to be an external influence, and rewrite the sector after the system stabilizes. If the number of rewrites exceeds the set number, it is determined that this sector is faulty and switch to writing to the next sector.
[0012] Preferably, the writing process in S4 includes: S41, recalculating the next write ID number according to the current ID number, and calculating the corresponding data area address according to the next write ID number; S42, writing the data into the working parameter data area corresponding to the data area address, reading it out, and performing verification. If the verification is successful, the data is written into the corresponding ID number area, read out and verified again, and if the verification is successful again, it is deemed to be successfully written; S43, after successfully writing the working parameter data area, write the same data into the parameter backup area according to the same logic, and synchronously record the current power supply average voltage and voltage variance.
[0013] Preferably, a preset incremental algorithm or a specific coding rule conversion algorithm is used to recalculate the next written ID number based on the current ID number.
[0014] Preferably, the calculation method of the single-sector maximum frame Max described in S1-S5 is specifically: Max<=PAGE_BYTE_NUM / (FRAME_LENGTH+1), wherein PAGE_BYTE_NUM is the maximum number of bytes of a single sector, and FRAME_LENGTH is the data length of a single frame of data.
[0015] Preferably, the relationship between the starting address of the data area and the ID area is: StartAddr=(sector starting address+current ID number×single frame data length).
[0016] The present invention also provides a system for handling faults and extending the service life of a power-off storage medium, comprising an MCU control unit and a power-off storage medium and a voltage detection unit simultaneously connected to the MCU control unit. The power-off storage medium is controlled by the MCU control unit to implement a control algorithm according to a preset erasing logic to execute the method for handling faults and extending the service life of the power-off storage medium; the power-off storage medium can be selected from at least one of an independent EEPROM, a flash memory, and an MCU internal storage medium, and the power-off storage medium is used to store an operation logic data structure.
[0017] Compared with the related art, the present invention provides a method for troubleshooting and extending the service life of a power-off storage medium, comprising: S1, after the user powers on the appliance, starting the program and initializing the arithmetic logic data structure; S2, reading the content of the ID area with a set starting address, reading out the entire ID area and querying the ID identification code from the end; S3, reading the single frame data stored in the corresponding data area based on the queried ID identification code, and performing data verification. If the verification is successful, the working parameters are assigned, and the ID areas of all sectors of the power-off storage medium are polled in sequence to locate the sectors used before the power off; S4, setting the data area as the working parameter data area, the parameter backup area and the comparison area. When there is a difference between the data in the working parameter data area and the comparison area, the write process is triggered and the data is rewritten. Calculate the ID area number to be written next, loop the write operation in a single sector, and switch to the next sector after the single sector erase and write life reaches the preset judgment condition; S5, write and read verification includes the data area read and write verification and the ID area read and write verification. If the ID area verification is successful, the write is determined to be successful, and the backup area read and write verification is performed according to the same logic. At the same time, a rewrite number threshold is set, and data reading and writing are performed after the single sector is written; if the data area read and write fails, switch to the next ID area to read and write again. After a certain number of rewrite failures, enter the voltage detection judgment, measure the voltage deviation degree according to the voltage variance, and if the voltage threshold and voltage deviation are too large, it is determined to be an external influence. After the system stabilizes, rewrite the sector. If the number of rewrites exceeds the set number, it is determined that the sector is faulty and switch to writing to the next sector. In the above method, by adding the write period to calculate the voltage variance to take external factors into account, a reasonable and efficient data structure and control algorithm are designed to provide reasonable fault tolerance judgment for fault judgment, increase the number of repeated writes of the power-off storage medium during the use cycle, and thus extend the rated service life of the power-off medium. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A schematic flow chart of a method for troubleshooting and extending the service life of a power-off storage medium according to the present invention;
[0019] Figure 2 Schematic diagram of the writing process in the present invention;
[0020] Figure 3 Fig. 1 is a structural schematic diagram of a power-off storage medium fault processing and service life extension system according to the present application. DETAILED DESCRIPTION
[0021] The present application provides a power-off storage medium fault processing and service life extension method, aiming to solve the problem that the differences of existing power-off storage media cannot be unified, resulting in a service life lower than the nominal value.
[0022] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.
[0023] Please refer to Fig. 1, which shows that the present application provides a power-off storage medium fault processing and service life extension method: Figure 1-2
[0024] S1, after the user powers on the electrical appliance, the program is started and the operation logic data structure is initialized, the operation logic data structure includes the current writing sector number, the current ID number, the page writing address, the writing fault number and the ID identification code; the operation logic data structure is set as follows: the low address bits in a single sector are used to store a plurality of data frames in the data area, the high address bits in a single sector are used as the ID area, and the single frame data storage position corresponds to the ID area one by one.
[0025] In the embodiment, the calculation method of the maximum frame Max of a single sector is specifically: Max<=PAGE_BYTE_NUM / (FRAME_LENGTH+1), wherein PAGE_BYTE_NUM is the maximum byte number of a single sector, and FRAME_LENGTH is the data length of a single frame data; the relationship between the start address of the data area and the ID area is: StartAddr=(sector start address+current ID number×single frame data length).
[0026] S2, the ID area content of the set start address is read out, and the entire ID area is read out and the ID identification code is queried from the tail.
[0027] S3, based on the ID identification code queried, the single frame data stored in the data area corresponding to the ID identification code is read, and data verification is performed; if the verification is successful, the working parameters are assigned, and the ID areas of all sectors of the power-off storage medium are sequentially polled to locate the used sector before power-off.
[0028] In this embodiment, S3 polls all sector ID areas in the power-off storage medium to query the sectors used before the power outage. Because the ID area contains less data than the data area, the reading range is reduced, and the number of ID area identification code bytes is small, which is faster. Compared with the traditional polling method for verifying the data area, the query algorithm directly influenced by this data structure can initialize the control system more quickly.
[0029] S4, setting the data area as the working parameter data area, the parameter backup area and the comparison area. When there is a difference between the data in the working parameter data area and the comparison area, the write process is triggered, the ID area number to be written next is recalculated, and the write operation is cyclically performed within a single sector until the erase and write life of the single sector reaches the preset judgment condition and then the next sector is switched to use.
[0030] In this embodiment, the write process in S4 includes: S41, recalculating the next write ID number based on the current ID number, and calculating the corresponding data area address based on the next write ID number; S42, writing the data into the working parameter data area corresponding to the data area address, reading it out, and performing verification. If the verification is successful, the data is written into the corresponding ID number area, read out and verified again, and if the verification is successful again, it is deemed to be successfully written; S43, after successfully writing the working parameter data area, write the same data into the parameter backup area according to the same logic, and synchronously record the current power supply average voltage and voltage variance.
[0031] Specifically, the next written ID number is recalculated according to the current ID number using a preset incremental algorithm or a specific encoding rule conversion algorithm.
[0032] It should be noted that if the sector erase and write life is N, compared with writing at a fixed position in a single sector, the erase and write life described in this step is: the maximum number of frames of a single sector × the total number of sectors × N, which greatly extends the rated service life of the dielectric.
[0033] S5, write and read verification covers the data area read and write verification and the ID area read and write verification. If the ID area verification is successful, the write is determined to be successful, and the backup area read and write verification is performed according to the same logic. At the same time, a rewrite number threshold is set, and data reading and writing are performed after a single sector is written; if the data area read and write fails, switch to the next ID area for re-reading and writing. After a certain number of rewrite failures, enter the voltage detection judgment, measure the voltage deviation degree based on the voltage variance, if the voltage threshold and voltage deviation are too large, it is determined to be an external influence, and rewrite the sector after the system stabilizes. If the number of rewrites exceeds the set number, it is determined that this sector is faulty and switch to writing to the next sector.
[0034] In the above method, by adding the write period to calculate the voltage variance to take external factors into account, a reasonable and efficient data structure and control algorithm are designed to provide reasonable fault tolerance judgment for fault judgment, increase the number of repeated writes to the power-off storage medium during the use cycle, and thus extend the rated service life of the power-off medium.
[0035] Please see the attached Figure 3 As shown, the present invention provides a system for fault handling and service life extension of a power-off storage medium, comprising an MCU control unit 1 and a power-off storage medium 2 and a voltage detection unit 3 connected to the MCU control unit 1 at the same time. The power-off storage medium 2 is controlled by the MCU control unit 1 to implement a control algorithm according to a preset erase and write logic to execute a method for fault handling and service life extension of the power-off storage medium 2; the power-off storage medium 2 can be selected from at least one of an independent EEPROM, a flash memory, and an MCU internal storage medium, and the power-off storage medium 2 is used to store an operation logic data structure.
[0036] Compared with the related art, the present invention provides a method for troubleshooting and extending the service life of a power-off storage medium, comprising: S1, after the user powers on the appliance, starting the program and initializing the arithmetic logic data structure; S2, reading the content of the ID area with a set starting address, reading out the entire ID area and querying the ID identification code from the end; S3, reading the single frame data stored in the corresponding data area based on the queried ID identification code, and performing data verification. If the verification is successful, the working parameters are assigned, and the ID areas of all sectors of the power-off storage medium are polled in sequence to locate the sectors used before the power off; S4, setting the data area as the working parameter data area, the parameter backup area and the comparison area. When there is a difference between the data in the working parameter data area and the comparison area, the write process is triggered and the data is rewritten. Calculate the ID area number to be written next, loop the write operation in a single sector, and switch to the next sector after the single sector erase and write life reaches the preset judgment condition; S5, write and read verification includes the data area read and write verification and the ID area read and write verification. If the ID area verification is successful, the write is determined to be successful, and the backup area read and write verification is performed according to the same logic. At the same time, a rewrite number threshold is set, and data reading and writing are performed after the single sector is written; if the data area read and write fails, switch to the next ID area to read and write again. After a certain number of rewrite failures, enter the voltage detection judgment, measure the voltage deviation degree according to the voltage variance, and if the voltage threshold and voltage deviation are too large, it is determined to be an external influence. After the system stabilizes, rewrite the sector. If the number of rewrites exceeds the set number, it is determined that the sector is faulty and switch to writing to the next sector. In the above method, by adding the write period to calculate the voltage variance to take external factors into account, a reasonable and efficient data structure and control algorithm are designed to provide reasonable fault tolerance judgment for fault judgment, increase the number of repeated writes of the power-off storage medium during the use cycle, and thus extend the rated service life of the power-off medium.
[0037] The embodiments described above are to be understood as illustrative rather than limiting the scope of the present invention, which is to be determined by the claims. It will be apparent to those skilled in the art that non-essential improvements and adjustments to the present invention, without departing from the spirit and scope of the present invention, still fall within the scope of the present invention.
Claims
1. A method for handling power-off storage medium failure and extending its service life, characterized in that: The method for handling power-off storage medium failure and extending service life includes: S1: After the user powers on the appliance, the program is started and the arithmetic logic data structure is initialized. The arithmetic logic data structure includes the current write sector number, the current ID number, the page write address, the number of write failures, and the ID identification code. The arithmetic logic data structure is configured as follows: the lower address bits of a single sector are used as a data area to store multiple data frames, the upper address bits of a single sector are used as an ID area, and the storage location of a single frame of data corresponds one-to-one with the ID area. S2, reading the content of the ID area of the set starting address, reading out the entire ID area and querying the ID identification code from the end; S3, reading a single frame of data stored in the corresponding data area based on the queried ID identification code, and performing data verification. If the verification is successful, the working parameters are assigned, and the ID areas of all sectors of the power-off storage medium are sequentially polled to locate the sectors used before the power off; S4, setting the data area as a working parameter data area, a parameter backup area, and a comparison area. When there is a difference between the data in the working parameter data area and the data in the comparison area, a write process is triggered, and the ID area number to be written next is recalculated. The write operation is cyclically performed within a single sector until the erase and write life of the single sector reaches a preset judgment condition, and then the next sector is switched to use; S5, write and read verification covers the data area read and write verification and the ID area read and write verification. If the ID area read and write verification is successful, the write is determined to be successful, and the backup area read and write verification is performed according to the same logic. At the same time, a rewrite number threshold is set, and data reading and writing are performed after a single sector is written. If the data area read and write fails, switch to the next ID area for re-reading and writing. After a certain number of rewrite failures, enter the voltage detection judgment, measure the voltage deviation degree according to the voltage variance, if the voltage threshold and voltage deviation are too large, it is determined to be an external influence, and rewrite to the sector after the system stabilizes. If the number of rewrites exceeds the set number, it is determined that this sector is faulty and switch to writing to the next sector.
2. The method for handling power-off storage medium faults and extending service life according to claim 1, characterized in that: The writing process in S4 includes: S41, recalculating the next write ID number according to the current ID number, and calculating the corresponding data area address according to the next write ID number; S42, writing the data into the working parameter data area corresponding to the data area address, then reading it out and performing verification. If the verification is successful, writing the data into the corresponding ID number area, reading it out again and performing verification. If the verification is successful again, the data is deemed to be successfully written; S43, after successfully writing the working parameter data area, writing the same data into the parameter backup area according to the same logic, and synchronously recording the current power supply average voltage and voltage variance.
3. The method for handling power-off storage medium failure and extending service life according to claim 2, characterized in that: The next written ID number is recalculated based on the current ID number using a preset incrementing algorithm or a specific encoding rule conversion algorithm.
4. The method for handling power-off storage medium failure and extending service life according to claim 1, characterized in that: The calculation method of the single-sector maximum frame Max described in S1 is specifically as follows: Max <= PAGE_BYTE_NUM / (FRAME_LENGTH + 1), where PAGE_BYTE_NUM is the maximum number of bytes in a single sector, and FRAME_LENGTH is the data length of a single frame of data.
5. The method for handling power-off storage medium faults and extending service life according to claim 1, characterized in that: The relationship between the starting address of the data area and the ID area is: StartAddr = (sector starting address + current ID number × single frame data length).
6. A system for handling power-off storage medium faults and extending service life, characterized in that: The system includes an MCU control unit and a power-off storage medium and a voltage detection unit connected to the MCU control unit at the same time. The power-off storage medium is controlled by the MCU control unit according to a preset erase logic to implement a control algorithm to execute the fault handling and service life extension method of the power-off storage medium according to any one of claims 1 to 5; the power-off storage medium is at least one of an independent EEPROM, a flash memory, and an MCU internal storage medium, and the power-off storage medium is used to store an operation logic data structure.
Citation Information
Patent Citations
Data processing method and terminal equipment
CN110209349A
Data storage device and system having adaptive brownout detection
US20150025821A1