Flash data storage method, device and household appliance

By judging the remaining space and strong power state when the Flash memory of smart home appliances is powered on, and data blocks are written only when the strong power is powered off, the problem of limited number of erases is solved, and the data response and storage space are achieved Save and extend the service life of the memory device.

CN114816230BActive Publication Date: 2025-01-07SHENZHEN H&T DATA RESOURCES & CLOUD TECH LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110129314.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-29
Publication Date
2025-01-07
Estimated Expiration
2041-01-29

AI Technical Summary

Technical Problem

In smart home appliances, the number of erased Flash memory is limited, which leads to problems with space size and erased times when storing user data, affecting chip life and space waste.

Method used

When the Flash memory is powered on, read the data block and the remaining storage space to determine whether the remaining space is sufficient. If the power is strong, write the data block in a weak current state to avoid unnecessary erasing, ensure data storage and save storage space.

Benefits of technology

It realizes quick response and save data when a strong power is out, reduces the number of erases, extends the service life of Flash memory, and saves storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114816230B_ABST
    Figure CN114816230B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention relates to a Flash data storage method, device and household appliance, the method comprising: when the Flash memory is powered on, reading the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory; judging whether the remaining storage space is less than the maximum length of the current data block; when the remaining storage space is not less than the maximum length of the current data block, judging whether the strong power of the Flash memory is off; if the strong power of the Flash memory is off, then when the weak power of the Flash memory is off, writing the current data block from the starting address to the remaining storage space. The embodiment of the present invention protects important data during product operation, can quickly respond to power-off events, and saves storage space, thereby effectively extending the service life of the storage device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of smart home appliances, and in particular to a Flash data storage method, device and home appliance. Background Art

[0002] In smart home appliances, the Flash memory can be used to store programs or data in the commonly used MCU (Microcontroller Unit). When Flash stores program code, it is usually erased during production. The number of times an electronic product is burned is usually very small. Before saving data, the data in the storage space needs to be empty (i.e. 0xFF). If the data is not empty, it needs to be erased. The number of erasures is limited and the erasure time is relatively long, so it is necessary to arrange the erasure time and frequency reasonably.

[0003] However, in the prior art, when storing user data, the number of erase and write times is relatively large, and when faced with the problem of space size and the number of erase and write times, the chip life is often affected, or space is wasted. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a Flash data storage method, device and household appliance, which can protect important data during product operation, can quickly respond to power failure events, and save storage space, thereby effectively extending the service life of the storage device.

[0005] In a first aspect, an embodiment of the present invention provides a Flash data storage method, the method comprising:

[0006] When the Flash memory is powered on, the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory are read;

[0007] Determining whether the remaining storage space is less than the maximum length of the current data block;

[0008] When the remaining storage space is not less than the maximum length of the current data block, determining whether the strong power of the Flash memory is off;

[0009] If the strong power of the Flash memory is cut off, then in the weak power-off state of the Flash memory, the current data block is written from the start address into the remaining storage space.

[0010] In some embodiments, when the Flash memory is powered on, reading the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory includes:

[0011] When the Flash memory is powered on, searching the Flash memory for a data header of a stored data block;

[0012] Reading the data length of the stored data block according to the data header of the stored data block;

[0013] Determining the storage address of the next data block according to the data length of the stored data block;

[0014] Determining a data header of the next data block according to a storage address of the next data block;

[0015] Determining whether the next data block is the current data block according to the data header of the next data block;

[0016] When the next data block is the current data block, the pre-stored address of the next data block is set as the starting address of the current data block, and the remaining storage space is determined according to the data length of the stored data blocks and the total storage space of the Flash memory.

[0017] In some embodiments, after determining whether the next data block is the current data block, the method further includes:

[0018] When the next data block is the current data block, verifying data content of the current data block;

[0019] When the data content verification passes, setting the pre-stored address of the next data block as the starting address of the current data block;

[0020] When the data content verification fails, the total storage space is erased to set the pre-stored address of the next data block as the first address of the total storage space.

[0021] In some embodiments, judging whether the next data block is the current data block according to the data header of the next data block includes:

[0022] Determine whether the data header of the next data block is empty;

[0023] If the data header of the next data block is empty, the next data block is determined to be the current data block.

[0024] In some embodiments, after determining whether the remaining storage space is less than the maximum length of the current data block, the method further includes:

[0025] When the remaining storage space is smaller than the maximum length of the current data block, the total storage space is erased so that the remaining storage space is not smaller than the maximum length of the current data block.

[0026] In some embodiments, the determining whether the strong power of the Flash memory is off includes:

[0027] According to the power-off sensing circuit, determining whether the strong electric pulse signal received by the Flash memory has timed out;

[0028] If the Flash memory receives the high-voltage pulse signal for a timeout, determining that the high-voltage power of the Flash memory is turned off;

[0029] If the timing data corresponding to the strong power pulse signal received by the Flash memory increases, it is determined that the strong power of the Flash memory is not cut off.

[0030] In some embodiments, if the strong power of the Flash memory is cut off, in the weak power-off state of the Flash memory, writing the current data block from the starting address to the remaining storage space includes:

[0031] If the strong power of the Flash memory is cut off, according to the power-off sensing circuit, the Flash memory enters a weak power-off state;

[0032] Obtaining the starting address of the current data block;

[0033] Before the weak power-off state of the Flash memory ends, the current data block is written into the remaining storage space from the start address.

[0034] In some embodiments, the power-off sensing circuit includes a first resistor, an optocoupler, a first capacitor, a second capacitor, a second resistor and a third resistor. The first input end of the optocoupler is connected to one end of an external power supply through the first resistor, and the second input end of the optocoupler is strongly connected to the other end of the external power supply; the first output end of the optocoupler is respectively connected to one end of the second resistor, one end of the third resistor and one end of the second capacitor, and the second output end of the optocoupler is connected to the other end of the second capacitor and the ground end; the other end of the third resistor is connected to the main control module of the household appliance, and the first capacitor is connected to the weak current power supply module and the ground end of the main control module.

[0035] In a second aspect, an embodiment of the present invention provides a Flash data storage device, the device comprising:

[0036] A power-on reading module, used to read the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory when the Flash memory is powered on;

[0037] A remaining storage space determination module, used to determine whether the remaining storage space is less than the maximum length of the current data block;

[0038] A high-power power failure judgment module, used for judging whether the high-power of the Flash memory is powered off when the remaining storage space is not less than the maximum length of the current data block;

[0039] The writing module is used for writing the current data block from the starting address into the remaining storage space in a weak power-off state of the Flash memory if the strong power of the Flash memory is off.

[0040] In a third aspect, an embodiment of the present invention provides a household appliance, wherein the household appliance includes:

[0041] at least one processor, and

[0042] A memory, wherein the memory is communicatively connected to the at least one processor, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the above method.

[0043] In a fourth aspect, an embodiment of the present invention provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by a household appliance, the household appliance executes the method described above.

[0044] The Flash data storage method, device and household appliance of the embodiment of the present invention read the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory when the Flash memory is powered on, and judge whether the remaining storage space is less than the maximum length of the current data block. When the remaining storage space is not less than the maximum length of the current data block, it means that the remaining storage space when the strong power is powered on is sufficient to store the current data block. At this time, if the strong power of the Flash memory is powered off, then in the weak power-off state of the Flash memory, the current data block is written from the starting address to the remaining storage space, that is, data block storage is performed only when the strong power is off, and the strong power off event is quickly responded to, so as to realize the preservation of the current data block when the strong power is off. The Flash memory does not need to store user data regularly, which effectively saves the storage space of the Flash memory. Since the data does not need to be erased when the remaining storage space is not less than the maximum length of the current data block, the number of erasures is reduced, thereby effectively extending the device service life of the Flash memory. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0046] Figure 1 It is a flow chart of an embodiment of the Flash data storage method of the present invention;

[0047] Figure 2 It is a data block schematic diagram of an embodiment of the Flash data storage method of the present invention;

[0048] Figure 3 It is a Flash space structure diagram of three consecutive pages of unstored data blocks and stored data blocks in one embodiment of the Flash data storage method of the present invention;

[0049] Figure 4 It is a power-off sensing circuit diagram of an embodiment of the Flash data storage method of the present invention;

[0050] Figure 5 It is a timing diagram of a power-off sensing circuit of an embodiment of the Flash data storage method of the present invention;

[0051] Figure 6 It is a structural schematic diagram of an embodiment of a Flash data storage device of the present invention;

[0052] Figure 7 It is a structural schematic diagram of an embodiment of a Flash data storage device of the present invention;

[0053] Figure 8 It is a schematic diagram of the hardware structure of a controller in one embodiment of the household appliance of the present invention. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0055] The Flash data storage method and device provided in the embodiment of the present invention can be applied to household appliances, wherein the household appliances can be intelligent terminal devices, such as intelligent refrigerators, air conditioners and other terminal devices.

[0056] It is understandable that a controller is provided in the home appliance as the main control center to protect important data during product operation, to respond quickly to power failure events, and to save storage space, thereby effectively extending the service life of the storage device.

[0057] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of a Flash data storage method provided by an embodiment of the present invention. The method can be executed by a controller 13 in a home appliance. Figure 1 As shown, the method is applied to household electrical appliances, and the method includes:

[0058] 101: When the Flash memory is powered on, the stored data blocks, the start address of the current data block and the remaining storage space in the Flash memory are read.

[0059] When the smart home appliance is powered on, for example, when it is connected to a 220V AC mains, the Flash memory of the smart home appliance is powered on, and at this time, the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory are read.

[0060] The data block consists of three parts: data header, data body and checksum. Figure 2 As shown in the figure, the data block header is the data header, which is also divided into two parts. One part is the header identifier, which occupies one byte, such as 0xA5, and the other part is the data body length. The data body length can be designed according to requirements, such as 8 bits, 16 bits, etc. Figure 2 In the data length, 8 bits are used to occupy one byte.

[0061] The data body is parameter data related to user functions. For example, if the user sets the air conditioner temperature to 23°C, the data body is parameter data reflecting the air conditioner temperature of 23°C. Due to different user parameters, for example, in addition to temperature settings, timing parameters can also be set. Therefore, the data body is a variable byte and can become longer or shorter, which is determined by the data body length of the data header.

[0062] The checksum is located after the data body and occupies one byte. It is from the data header identifier to the last byte of the data body and is used to ensure the accuracy of the verification data.

[0063] The variable byte feature of the data body makes the amount of data saved variable, and data can be saved as needed. For example, the first save is 24 bytes, the second save can be 64 bytes, and the third save can be 16 bytes. Compared with the existing solution of fixed data size, such as fixed 32 bytes, the saved data varies from 24, 16, and 32 bytes. If only 24 bytes are needed, then saving it in 32 bytes will cause 8 bytes of space waste.

[0064] like Figure 3 As shown, Figure 3 The figure is a Flash space structure diagram of three consecutive pages of unstored data blocks and stored data blocks. When no data blocks are stored, the contents of the Flash are all hexadecimal FFs. When data blocks are stored, there are data blocks of different sizes. For example, in the Flash space of page 0 where data blocks are stored, the length of data block 0 is less than the length of data block 1, and the length of data block 1 is greater than the length of data block 2.

[0065] In some embodiments, when the Flash memory is powered on, reading the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory may include:

[0066] When the Flash memory is powered on, searching the Flash memory for a data header of a stored data block;

[0067] Reading the data length of the stored data block according to the data header of the stored data block;

[0068] Determining the storage address of the next data block according to the data length of the stored data block;

[0069] Determining a data header of the next data block according to a storage address of the next data block;

[0070] Determining whether the next data block is the current data block according to the data header of the next data block;

[0071] When the next data block is the current data block, the pre-stored address of the next data block is set as the starting address of the current data block, and the remaining storage space is determined according to the data length of the stored data blocks and the total storage space of the Flash memory.

[0072] Specifically, the stored data block is user data saved before the last power failure. According to the components of the data block, when the Flash memory is powered on, the data header of the stored data block is searched in the Flash memory, and the data length of the stored data block can be read according to the data header of the stored data block. For example, the set data storage starting page and total number of pages are loaded first, and the starting page header address is set as the search address. For example, if the starting page is page 0, the search address is data block 0 of page 0, and the header identifier 0xA5 in the data header of the stored data block is found. Then, because another byte in the data header represents the data body length Therefore, according to the data header of the stored data block Dn, the data length of the stored data block Dn can be read; after obtaining the data length of the stored data block Dn, since it is known that the stored data block Dn is located in which page and which data block, the storage address of the next data block can be determined. For example, if the stored data block Dn is data block 1 of page 0, then, since the data length of data block 1 is known, according to the data block storage order of page 0, the storage address of the next data block Dn+1 can be determined to be the storage address of data block 2, that is, the starting address of the next data block Dn+1 is the ending address of data block 1+1. In addition, since the data blocks are arranged in sequence, the data header of the next data block Dn+1 can be determined according to the storage address of the next data block Dn+1.

[0073] In some embodiments, judging whether the next data block Dn+1 is the current data block according to the data header of the next data block Dn+1 may include:

[0074] Determine whether the data header of the next data block is empty;

[0075] If the data header of the next data block is empty, the next data block is determined to be the current data block.

[0076] Specifically, the current data block is the user data block that the user needs to save in the end. For example, if the user adjusts the air conditioner temperature to 23°C, then if the air conditioner suddenly loses power, the temperature parameter of the air conditioner temperature of 23°C needs to be saved so that it can run at 23°C when a call comes in. Furthermore, when determining whether the next data block Dn+1 is the current data block, determine whether the data header of the next data block Dn+1 is empty. If the data header of the next data block is empty, for example, the stored data block is data block 11 of the first page, and the next data block is an empty hexadecimal FF, it is obvious that the user has not updated the data block, so data block 11 is used as the current data block; correspondingly, if the stored data block Dn is data block 9, it is obvious that there is still a next data block, which means that new user data has been updated. At this time, it is necessary to increase the query address and return to the data header query until a data block with an empty data header is found to determine the current data block.

[0077] In some embodiments, after determining whether the next data block is the current data block, the following steps are included:

[0078] When the next data block is the current data block, verifying data content of the current data block;

[0079] When the data content verification passes, setting the pre-stored address of the next data block as the starting address of the current data block;

[0080] When the data content verification fails, the total storage space is erased to set the pre-stored address of the next data block as the first address of the total storage space.

[0081] Specifically, when the next data block is the current data block, the data content of the current data block needs to be verified. According to the components of the data block, the data content can be verified by the checksum of the current data block to ensure the accuracy of the verification data.

[0082] When the data content verification passes, it means that the data content is normal, and the MCU of the home appliance can take out the data block saved at the last power failure for use, and set the pre-stored address of the next data block Dn+1 as the starting address of the current data block.

[0083] Correspondingly, when the data content verification fails, it means that the data content is incorrect. Then, the parameters set by the user are modified to the default. For example, the lowest temperature of the air conditioner is 16°C. When the air-conditioning temperature is 16°C, the user continues to press the downward temperature adjustment button. Then, the parameter corresponding to the downward temperature adjustment is the data content that failed the verification. At this time, the total storage space is erased to set the pre-stored address of the next data block as the first address of the total storage space.

[0084] Furthermore, when the next data block Dn+1 is the current data block, the pre-stored address of the next data block is set as the starting address of the current data block Dn+1, and the remaining storage space can be determined according to the data length of the stored data block Dn and the total storage space of the Flash memory, thereby reading the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory.

[0085] 102: Determine whether the remaining storage space is smaller than the maximum length of the current data block.

[0086] Correspondingly, when the data content verification of the current data block Dn+1 passes, it means that the data content is normal. The MCU of the household appliance can take out the data block saved at the last power off for use, and set the pre-stored address of the next data block Dn+1 as the starting address of the current data block, and then determine whether the remaining storage space is less than the maximum length of the current data block.

[0087] By detecting the remaining storage space, it is determined whether the remaining storage space is sufficient to store the current data block. If not, the total storage space of the Flash memory is erased in time so that the remaining storage space is sufficient to store the current data block. In addition, the judgment and erasure are performed before power failure to avoid the problem of insufficient space when the current data block needs to be saved due to insufficient space due to power failure.

[0088] 103: When the remaining storage space is not less than the maximum length of the current data block, determine whether the high power of the Flash memory is off.

[0089] When the remaining storage space is not less than the maximum length of the current data block, it means that the remaining storage space is sufficient to store the current data block. At this time, it can be determined whether the high power of the Flash memory is off.

[0090] In some embodiments, such as Figure 4 As shown, Figure 4The invention is a power-off sensing circuit of a Flash memory. According to the power-off sensing circuit, it is determined whether the strong power of the Flash memory is powered off. Specifically, the power-off sensing circuit includes a first resistor R1, an optical coupler U1, a first capacitor C1, a second capacitor C2, a second resistor R2 and a third resistor R3. The first input end of the optical coupler U1 is connected to one end of an external power supply through the first resistor R1, and the second input end of the optical coupler U1 is connected to the other end of the external power supply; the first output end of the optical coupler U1 is respectively connected to one end of the second resistor R2, one end of the third resistor R3 and one end of the second capacitor C2, and the second output end of the optical coupler U1 is connected to the other end of the second capacitor C2 and the ground end, the other end of the third resistor R3 is connected to the main control module MCU of the household appliance, and the first capacitor C1 is connected to the weak power supply module 3.3V of the main control module MCU and the ground end. The MCU power supply module and the optical coupler U1 are connected to the same 220V AC power, and the 3.3V power supply of the main control module MCU of the household appliance is provided by the MCU power supply module.

[0091] Specifically, when connected to an external power supply of 220V AC, the Flash memory is powered on, and the first resistor R1 can be 470kΩ. Through the first resistor R1, the optocoupler U1 is prevented from burning out under 220V AC, and the light-controlled transistor in the optocoupler U1 is lit, and the second output terminal of the optocoupler U1 is grounded. Through the optocoupler U1, the AC sine wave signal of the 220V AC is converted into a square wave signal. The up and down transition edge signals of the square wave signal allow the MCU to generate a program interrupt to clear the power-off timeout count, and the second capacitor C2 can filter other interference signals. Taking 220V AC as an example, the frequency of the obtained square wave signal is 50Hz, so the obtained one-cycle transition edge signal is 20ms, and the strong power failure is confirmed by the continuous loss of two cycles of transition edge signals (i.e. 40ms).

[0092] Therefore, in some embodiments, determining whether the strong power of the Flash memory is off includes:

[0093] According to the power-off sensing circuit, determining whether the strong electric pulse signal received by the Flash memory has timed out;

[0094] If the Flash memory receives the high-voltage pulse signal for a timeout, determining that the high-voltage power of the Flash memory is turned off;

[0095] If the timing data corresponding to the strong power pulse signal received by the Flash memory increases, it is determined that the strong power of the Flash memory is not cut off.

[0096] Specifically, according to the power-off sensing circuit, it can be judged whether the high-electricity pulse signal received by the Flash memory has timed out, for example, whether two cycles of transition edge signals are received continuously. If not, then it can be determined that the Flash memory has timed out from receiving the high-electricity pulse signal, and the high-electricity of the Flash memory is determined to be powered off; if two cycles of transition edge signals are received continuously, the timing data corresponding to the high-electricity pulse signal received increases, that is, the number of high-electricity pulse signals received continues to increase, then it means that the high-electricity of the Flash memory is not powered off.

[0097] 104: If the strong power of the Flash memory is cut off, then in the weak power-off state of the Flash memory, write the current data block from the start address into the remaining storage space.

[0098] When a strong power failure of the Flash memory is detected, a weak power failure state is entered according to the power failure sensing circuit. In the weak power failure state of the Flash memory, the current data block is written from the start address to the remaining storage space.

[0099] In some embodiments, if the strong power of the Flash memory is off, writing the current data block from the starting address to the remaining storage space in a weak power-off state of the Flash memory includes:

[0100] If the strong power of the Flash memory is cut off, according to the power-off sensing circuit, the Flash memory enters a weak power-off state;

[0101] Obtaining the starting address of the current data block;

[0102] Before the weak power-off state of the Flash memory ends, the current data block is written into the remaining storage space from the starting address.

[0103] Specifically, Figure 5 As shown, Figure 5 It is a timing diagram of the power-off sensing circuit. When the strong power is off, due to the discharge of the MCU power module and the first capacitor C1, 3.3V will not disappear within a certain time range. At this time, relying on the weak power-off state of 3.3V power supply, as the data preservation time, the starting address of the current data block is obtained, and before the weak power-off state of the Flash memory ends, the current data block is written from the starting address to the remaining storage space.

[0104] Since it is determined that there is remaining storage space when writing, there is no need to erase the space. Therefore, only writing takes time, and the weak power-off state can just provide writing time, thereby effectively ensuring the writing time of the current data block.

[0105] Compared with the two data storage methods in the prior art, one is fixed address timed storage, and the fixed address stores the data at a fixed address each time, and the original data is erased and then saved when the timed storage is reached; the other is non-fixed address but fixed data amount storage, the address will be read once when power is turned on, and the data will be saved when the save time is scheduled during operation, and the address is fixed again to increase a data block space unit, thereby increasing the number of save times.

[0106] Moreover, in conventional electrical application products, power-off data generally records a certain parameter, a certain switch state, and power-off protection data will not be too large, generally within a few dozen bytes, and this data is refreshed instead of accumulated when it changes. For example, 32 bytes of data will be refreshed after changing the state, instead of being accumulated to 64 bytes. In the MCU system of conventional electrical appliances, the saving operation of 1024 bytes will consume about 5 milliseconds, and it will take from tens of milliseconds to several seconds from strong power to weak power (falling below the effective voltage). Therefore, the current data block can be saved in the weak power state in this time. When re-erasing space in different MCUs, it will take tens of milliseconds or even seconds, so the erasing action is placed on power-on.

[0107] In addition, it is generally not necessary to save the data block during the period from power-on to power-off, and the data block will not disappear in the MCU memory unless power is off. If storage is required, if the user has set the manual save function, a storage action can be executed, and then the address variable to be saved can be increased according to the size of the data block to be saved.

[0108] In an embodiment of the present application, when the Flash memory is powered on, the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory are read, and it is determined whether the remaining storage space is less than the maximum length of the current data block. When the remaining storage space is not less than the maximum length of the current data block, it means that the remaining storage space when the strong power is powered on is sufficient to store the current data block. At this time, if the strong power of the Flash memory is powered off, then, in the weak power-off state of the Flash memory, the current data block is written from the starting address to the remaining storage space, that is, data block storage is performed only when the strong power is off, and the strong power off event is responded to quickly, thereby realizing the preservation of the current data block when the strong power is off. The Flash memory does not need to store user data regularly, which effectively saves the storage space of the Flash memory. Since the data does not need to be erased when the remaining storage space is not less than the maximum length of the current data block, the number of erasures is reduced, thereby effectively extending the device service life of the Flash memory.

[0109] Correspondingly, such as Figure 6 As shown, the embodiment of the present invention further provides a Flash data storage device, which can be used in home appliances. The Flash data storage device 700 includes:

[0110] The power-on reading module 701 is used to read the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory when the Flash memory is powered on;

[0111] The remaining storage space determination module 702 is used to determine whether the remaining storage space is less than the maximum length of the current data block;

[0112] A high-power power failure judgment module 703 is used to judge whether the high-power of the Flash memory is powered off when the remaining storage space is not less than the maximum length of the current data block;

[0113] The writing module 704 is configured to write the current data block from the starting address into the remaining storage space when the strong power of the Flash memory is turned off and the weak power of the Flash memory is turned off.

[0114] According to the embodiment of the present invention, when the Flash memory is powered on, the stored data blocks, the starting address of the current data block and the remaining storage space in the Flash memory are read, and it is determined whether the remaining storage space is less than the maximum length of the current data block. When the remaining storage space is not less than the maximum length of the current data block, it indicates that the remaining storage space when the strong power is powered on is sufficient to store the current data block. At this time, if the strong power of the Flash memory is powered off, then in the weak power-off state of the Flash memory, the current data block is written from the starting address to the remaining storage space, that is, data block storage is performed only when the strong power is off, and the strong power off event is quickly responded to, thereby realizing the preservation of the current data block when the strong power is off. The Flash memory does not need to store user data regularly, which effectively saves the storage space of the Flash memory. Since the data does not need to be erased when the remaining storage space is not less than the maximum length of the current data block, the number of erasures is reduced, thereby effectively extending the device service life of the Flash memory.

[0115] In other embodiments, the power-on reading module 701 is further used for:

[0116] When the Flash memory is powered on, searching the Flash memory for a data header of a stored data block;

[0117] Reading the data length of the stored data block according to the data header of the stored data block;

[0118] Determining the storage address of the next data block according to the data length of the stored data block;

[0119] Determining a data header of the next data block according to a storage address of the next data block;

[0120] Determining whether the next data block is the current data block according to the data header of the next data block;

[0121] When the next data block is the current data block, the pre-stored address of the next data block is set as the starting address of the current data block, and the remaining storage space is determined according to the data length of the stored data blocks and the total storage space of the Flash memory.

[0122] In other embodiments, the power-on reading module 701 is further used for:

[0123] When the next data block is the current data block, verifying data content of the current data block;

[0124] When the data content verification passes, setting the pre-stored address of the next data block as the starting address of the current data block;

[0125] When the data content verification fails, the total storage space is erased to set the pre-stored address of the next data block as the first address of the total storage space.

[0126] In other embodiments, the power-on reading module 701 is further used for:

[0127] Determine whether the data header of the next data block is empty;

[0128] If the data header of the next data block is empty, the next data block is determined to be the current data block.

[0129] In some embodiments, after the remaining storage space determination module 702 determines whether the remaining storage space is less than the maximum length of the current data block, the Flash data storage device 700 further includes:

[0130] The erasing module 705 is used for:

[0131] When the remaining storage space is smaller than the maximum length of the current data block, the total storage space is erased so that the remaining storage space is not smaller than the maximum length of the current data block.

[0132] In some embodiments, the high-voltage power failure determination module 703 is further used to:

[0133] According to the power-off sensing circuit, determining whether the strong electric pulse signal received by the Flash memory has timed out;

[0134] If the Flash memory receives the high-voltage pulse signal for a timeout, determining that the high-voltage power of the Flash memory is turned off;

[0135] If the timing data corresponding to the strong power pulse signal received by the Flash memory increases, it is determined that the strong power of the Flash memory is not cut off.

[0136] In some embodiments, the writing module 704 is further configured to:

[0137] If the strong power of the Flash memory is cut off, according to the power-off sensing circuit, the Flash memory enters a weak power-off state;

[0138] Obtaining the starting address of the current data block;

[0139] Before the weak power-off state of the Flash memory ends, the current data block is written into the remaining storage space from the start address.

[0140] In some embodiments, the power-off sensing circuit includes a first resistor, an optocoupler, a first capacitor, a second capacitor, a second resistor and a third resistor. The first input end of the optocoupler is connected to one end of an external power supply through the first resistor, and the second input end of the optocoupler is strongly connected to the other end of the external power supply; the first output end of the optocoupler is respectively connected to one end of the second resistor, one end of the third resistor and one end of the second capacitor, and the second output end of the optocoupler is connected to the other end of the second capacitor and the ground end; the other end of the third resistor is connected to the main control module of the household appliance, and the first capacitor is connected to the weak current power supply module and the ground end of the main control module.

[0141] It should be noted that the above device can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in the device embodiment, please refer to the method provided in the embodiment of the present application.

[0142] Figure 8 FIG. 1 is a schematic diagram of the hardware structure of a controller in an embodiment of a household appliance. Figure 8 As shown, the controller 13 includes:

[0143] One or more processors 131 and memory 132 . Figure 8 In the figure, a processor 131 and a memory 132 are taken as an example.

[0144] The processor 131 and the memory 132 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.

[0145] The memory 132 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the Flash data storage method in the embodiment of the present application (for example, the attached Figure 6-7 The processor 131 executes various functional applications and data processing of the controller by running the non-volatile software programs, instructions and modules stored in the memory 132, that is, the Flash data storage method of the above method embodiment is implemented.

[0146] The memory 132 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created according to the use of a Flash data storage device, etc. In addition, the memory 132 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 132 may optionally include a memory remotely arranged relative to the processor 131, and these remote memories may be connected to the home appliance via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0147] The one or more modules are stored in the memory 132, and when executed by the one or more processors 131, the Flash data storage method in any of the above method embodiments is executed, for example, the above described Figure 1 Steps 101 to 104 of the method; implementing Figure 6 Modules 701-704 in Figure 7 The functions of modules 701-705.

[0148] The above-mentioned product can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of the present application.

[0149] The embodiment of the present application provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors, such as Figure 8 A processor 131 in the embodiment may enable the one or more processors to execute the Flash data storage method in any of the above method embodiments, for example, to execute the above described Figure 1 Steps 101 to 104 of the method; implementing Figure 6 Modules 701-704 in Figure 7 The functions of modules 701-705.

[0150] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0151] Through the description of the above embodiments, a person of ordinary skill in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, or of course by hardware. A person of ordinary skill in the art can understand that all or part of the processes in the above embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Under the concept of the present invention, the technical features in the above embodiments or different embodiments may also be combined, the steps may be implemented in any order, and there are many other changes in different aspects of the present invention as described above, which are not provided in detail for the sake of simplicity. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A Flash data storage method, characterized in that: The method comprises: When the Flash memory is powered on, searching the Flash memory for a data header of a stored data block; Reading the data length of the stored data block according to the data header of the stored data block; Determine the storage address of the next data block according to the data length of the stored data block, wherein the next data block is an adjacent data block of the stored data block and is located after the stored data block; Determining a data header of the next data block according to a storage address of the next data block; Determine whether the data header of the next data block is empty; If the data header of the next data block is empty, the pre-stored address of the next data block is set to the starting address of the user data block that the user needs to save, and the remaining storage space is determined according to the data length of the stored data block and the total storage space of the Flash memory; Determining whether the remaining storage space is less than the maximum length of the user data block; When the remaining storage space is not less than the maximum length of the user data block, determining whether the strong power of the Flash memory is off; If the strong power of the Flash memory is cut off, the user data block is written from the starting address to the remaining storage space before the weak power-off state of the Flash memory ends, wherein the weak power-off state refers to a state in which the power supply voltage of the Flash memory is maintained without disappearing within a time range due to the discharge effect of the capacitor.

2. The method according to claim 1, characterized in that Also includes: When the data header of the next data block is empty, verifying the data content of the user data block; When the data content verification passes, setting the pre-stored address of the next data block as the starting address of the user data block; When the data content verification fails, the total storage space is erased to set the pre-stored address of the next data block as the first address of the total storage space.

3. The method according to claim 1, characterized in that After determining whether the remaining storage space is less than the maximum length of the user data block, the method further comprises: When the remaining storage space is smaller than the maximum length of the user data block, the total storage space is erased so that the remaining storage space is not smaller than the maximum length of the user data block.

4. The method according to claim 1, characterized in that The step of determining whether the strong power of the Flash memory is off includes: According to the power-off sensing circuit, determining whether the strong electric pulse signal received by the Flash memory has timed out; If the Flash memory receives the high-voltage pulse signal for a timeout, determining that the high-voltage power of the Flash memory is turned off; If the timing data corresponding to the strong power pulse signal received by the Flash memory increases, it is determined that the strong power of the Flash memory is not cut off.

5. The method according to claim 1, characterized in that If the strong power of the Flash memory is cut off, before the weak power-off state of the Flash memory ends, writing the user data block from the starting address to the remaining storage space comprises: If the strong power of the Flash memory is cut off, the Flash memory enters a weak power-off state according to the power-off sensing circuit; Obtaining the starting address of the user data block; Before the weak power-off state of the Flash memory ends, the user data block is written into the remaining storage space from the start address.

6. A Flash data storage device, characterized in that: The device comprises: A power-on reading module, used for searching the data header of a stored data block in the Flash memory when the Flash memory is powered on, reading the data length of the stored data block according to the data header of the stored data block, determining the storage address of the next data block according to the data length of the stored data block, determining the data header of the next data block according to the storage address of the next data block, judging whether the data header of the next data block is empty, if the data header of the next data block is empty, setting the pre-stored address of the next data block to the starting address of the user data block that the user needs to save, and determining the remaining storage space according to the data length of the stored data block and the total storage space of the Flash memory, wherein the next data block is an adjacent data block of the stored data block and is located after the stored data block; A remaining storage space determination module, used to determine whether the remaining storage space is less than the maximum length of the user data block; A high-power power-off judgment module, used for judging whether the high-power of the Flash memory is off when the remaining storage space is not less than the maximum length of the user data block; A writing module is used for writing the user data block from the starting address to the remaining storage space before the weak power-off state of the Flash memory ends if the strong power of the Flash memory is powered off, wherein the weak power-off state refers to a state in which the power supply voltage of the Flash memory is maintained without disappearing within a time range due to the discharge effect of the capacitor.

7. A household appliance, characterized in that: The household electrical appliances include: at least one processor, and A memory, wherein the memory is communicatively connected to the processor, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in any one of claims 1 to 5.

8. A non-volatile computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a home appliance, the home appliance executes the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data caching method and data caching device

    CN104850507A

  • Storage system online data compression method, device and equipment

    CN109683825A