Data storage method and system and electronic equipment
By dividing multiple second -storage areas in the flash storage equipment and circulating writing storage, the problem of low use of the flash storage equipment in frequent use of the service life is solved. Essence
Patent Information
- Application Number
- CN202411367608.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-01-24
AI Technical Summary
In the prior art, the service life of the flash memory device is low under frequent rewritten storage operations, and it is difficult to effectively extend its service life.
By dividing a plurality of second storage areas in the first storage area of the flash memory storage device, and performing cyclic erasing and writing storage of data between these areas, the same erasing and writing lifespan is used to increase the number of erasing and writing areas, so as to increase the overall size. The erase life of the area.
Effectively improve the overall area of the glitter storage equipment, and extend the service life of the equipment, especially in the scenario that requires scattered storage data.
Smart Images

Figure CN119356598A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of data storage, and in particular relates to a data storage method, system and electronic device. Background Art
[0002] Flash memory devices (FLASH) are generally erased and written in blocks, and single-byte operations are not allowed. They generally have large capacities, but their erase and write lifespan is relatively low. In many application scenarios of embedded products, FLASH is often used as a storage device. For data that needs to be stored in a scattered manner, the erase and write storage actions are relatively frequent, which inevitably affects the service life of FLASH. Summary of the invention
[0003] Purpose of the invention: The present application develops a data storage method, system and electronic device, aiming to solve the technical problem in the prior art that FLASH has a low service life under frequent erase and write storage operations.
[0004] Technical solution: In a first aspect, the present application provides a data storage method, which is applied to a flash memory storage device, wherein the flash memory storage device includes a first storage area, and the first storage area includes a plurality of second storage areas; the data storage method includes:
[0005] Writing the data to be stored into the second storage area capable of performing read and write operations;
[0006] In response to the second storage area that can perform read and write operations being full, the most recently written data to be stored corresponding to the virtual address in the second storage area that can perform read and write operations is written into the next second storage area that can perform read and write operations, and the read and write operations are continued in the next second storage area that can perform read and write operations.
[0007] In some embodiments, it also includes:
[0008] Determine the unit erase and write life of the second storage area;
[0009] Determining the target erase lifespan;
[0010] The number of the second storage areas is determined based on the target erase / write lifespan and the unit erase / write lifespan.
[0011] In some embodiments, the characterization formula for determining the number of the second storage area based on the target erase life and the unit erase life includes:
[0012] n*m≥a;
[0013] Wherein, n is the unit erase / write life; m is the number of the second storage areas; and a is the target erase / write life.
[0014] In some embodiments, the second storage area includes:
[0015] an identification area, the identification area including an area occupied by the first K bytes of the second storage area; the data in the identification area is used to characterize the state of the second storage area, and K is a positive integer;
[0016] A storage area, the storage area includes an area in the second storage area connected to the identification area, and the storage area is used to store the written data to be stored.
[0017] In some embodiments, the storage area includes:
[0018] A data area, the data area is used to store the data to be stored;
[0019] A virtual address area, wherein the virtual address area is used to store the virtual address of the data to be stored;
[0020] A check area is used to store the check code of the data to be stored and the check code of the virtual address.
[0021] In some embodiments, the state of the second storage area includes a legal state, a full state, a receiving state, an illegal state and an erase state, wherein the legal state is used to indicate that the area can be read and written, the full state is used to indicate that the storage space of the area is full of data, the receiving state is used to indicate that the area is receiving data from another area, the illegal state is used to indicate that the area needs to clear data, and the erase state is used to indicate that all data in the area has been cleared: the method for determining the second storage area that can be read and written includes
[0022] If the second storage area is in the legal state, it is determined that the second storage area can be read and written.
[0023] In some embodiments, the data storage method further comprises:
[0024] If the flash memory storage device is powered on again, a power-on initialization operation is performed on the flash memory storage device, and the power-on initialization operation includes:
[0025] If the current second storage area is in a receiving state and the previous second storage area is in a full state, the newly written data to be stored corresponding to the virtual address in the previous second storage area is written into the current second storage area, and the current second storage area is set to a legal state;
[0026] If the current second storage area is in a legal state, and there is a second storage area in a legal state before the current second storage area, clearing the data in the current second storage area;
[0027] If the second storage area is currently full and there is a second storage area in a legal state, the data in the second storage area is cleared, or the most recently written data to be stored corresponding to the virtual address in the second storage area is written into the next second storage area.
[0028] In some embodiments, the data storage method further comprises:
[0029] configuring an address storage area, the address storage area being used to store the storage address of the latest data to be written corresponding to the virtual address in the second storage area;
[0030] Configuring a global variable, wherein the global variable is used to store a storage address of the latest data to be written in the second storage area;
[0031] When reading data, if the second storage area where the storage address in the address storage area is located is in a legal state, then reading the data in the storage address in the address storage area;
[0032] When writing data, if the second storage area where the storage address in the global variable is located is in a legal state and the storage address in the global variable is in an erased state, data is written to the storage address in the global variable.
[0033] In a second aspect, an embodiment of the present application further provides a data storage system, which is applied to a flash memory storage device, wherein the flash memory storage device includes a first storage area, the first storage area includes a plurality of second storage areas, and the data storage system includes:
[0034] A data writing module, the data writing module is used to write the data to be stored into the second storage area capable of performing read and write operations;
[0035] A data transfer module, wherein the data transfer module is used to write the most recently written data to be stored corresponding to the virtual address in the second storage area that can perform read and write operations into the next second storage area that can perform read and write operations in response to the second storage area that can perform read and write operations being full, and continue to perform read and write operations in the next second storage area that can perform read and write operations.
[0036] In a third aspect, an embodiment of the present application further provides an electronic device, including:
[0037] A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the data storage method as described in any one of the first aspects by executing the computer instructions.
[0038] Beneficial effect: Compared with the prior art, a data storage method provided by an embodiment of the present application is applied to a flash memory storage device. The data storage method of the present application first determines a first storage area for storing data in a flash memory storage device, and then divides a plurality of partial storage spaces in the first storage area to determine a plurality of second storage areas; finds a second storage area that can perform read and write operations in the plurality of second storage areas, and performs read and write operations in the second storage area that can perform read and write operations; when the space of the second storage area that can perform read and write operations is full of data, the newly written data to be stored corresponding to the virtual address in the second storage area that can perform read and write operations is written into the next second storage area that can perform read and write operations, and after the writing is completed, the read and write operations are continued in the next second storage area that can perform read and write operations. The present application divides a plurality of second storage areas in the first storage area, performs cyclic erasing and writing storage of data between the plurality of second storage areas, divides a large storage area into a plurality of small storage areas, and based on the same erasing and writing life of the large and small areas, the data that needs to be scatteredly stored is cyclically erased and written by increasing the number of erasing and writing areas in the same storage area, which can effectively improve the erasing and writing life of the overall large area. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0040] Figure 1 A flowchart of the steps of the data storage method provided in the embodiment of the present application;
[0041] Figure 2 A specific flow chart for determining the number of second storage areas in the data storage method provided in an embodiment of the present application;
[0042] Figure 3 A module connection diagram of a data storage system provided in an embodiment of the present application;
[0043] Figure 4 A simplified structural diagram of an electronic device provided in an embodiment of the present application;
[0044] Figure 5 A state distinction table of the second storage area in the data storage method provided in an embodiment of the present application;
[0045] Figure 6 A state table when multiple second storage areas are not initialized in the data storage method provided in an embodiment of the present application;
[0046] Figure 7 A state table of a second storage area code-named BLOCK0 in a plurality of second storage areas in the data storage method provided in an embodiment of the present application when the second storage area is initialized in a legal state and other second storage areas are not initialized;
[0047] Figure 8 A state table for setting and writing the first group of data in a second storage area coded as BLOCK0 in a plurality of second storage areas in the data storage method provided in an embodiment of the present application;
[0048] Fig. 9 A state table for writing a second group of data into a second storage area coded as BLOCK0 in a plurality of second storage areas in the data storage method provided in an embodiment of the present application;
[0049] Fig.10 A status table showing that a second storage area coded as BLOCK0 in a plurality of second storage areas is full of data in the data storage method provided in an embodiment of the present application;
[0050] Fig.11 A status table showing that a second storage area coded as BLOCK0 in a plurality of second storage areas is full of data and a second storage area coded as BLOCK2 receives three sets of data in the data storage method provided in an embodiment of the present application;
[0051] Fig.12 A status table showing that a second storage area coded as BLOCK0 in a plurality of second storage areas is full of data and a second storage area coded as BLOCK2 is set to a legal area in the data storage method provided in an embodiment of the present application;
[0052] Fig.13 A status table showing that a second storage area coded as BLOCK0 in a plurality of second storage areas is full of data and a second storage area coded as BLOCK2 is written with a fourth group of data in the data storage method provided in an embodiment of the present application;
[0053] Figure numerals: 10, data writing module; 20, data switching module; 100, memory; 200, processor. DETAILED DESCRIPTION
[0054] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0055] FLASH flash memory storage devices are generally erased and written in blocks, and single-byte operations are not allowed. The capacity is generally large, but the lifespan is relatively low, with an erase and write lifespan of only ten thousand to one hundred thousand times. EEPROM (Electrically Erasable Programmable Read-Only Memory) can read and write single bytes, and the capacity is generally small, but the lifespan is relatively long, with an erase and write lifespan of millions of times.
[0056] In many application scenarios of embedded products, some key data needs to be stored for a long time or frequently changed. Generally, large blocks of data that do not change frequently are stored in FLASH, and frequently changed data are stored in EEPROM. In some scenarios, due to the size of storage data capacity or cost considerations, only FLASH is set up without using EEPROM. For those data that need to be stored in a scattered manner, they need to be stored frequently while considering the life of FLASH. At this time, it is necessary to extend the service life of FLASH.
[0057] In view of this, an embodiment of the present application provides a data storage method, which is applied in a flash memory storage device. The data storage method of the present application first determines a first storage area for storing data in the flash memory storage device, and then divides a plurality of partial storage spaces in the first storage area to determine a plurality of second storage areas; finds a second storage area that can perform read and write operations in the plurality of second storage areas, and performs read and write operations in the second storage area that can perform read and write operations; when the space of the second storage area that can perform read and write operations is full of data, the newly written data to be stored corresponding to the virtual address in the second storage area that can perform read and write operations is written into the next second storage area that can perform read and write operations, and after the writing is completed, the read and write operations are continued in the next second storage area that can perform read and write operations. The present application divides a plurality of second storage areas in the first storage area, performs cyclic erasing and writing storage of data between the plurality of second storage areas, divides a large storage area into a plurality of small storage areas, and based on the same erasing and writing life of the large and small areas, the data that needs to be scatteredly stored is cyclically erased and written by increasing the number of erasing and writing areas in the same storage area, which can effectively improve the erasing and writing life of the overall large area.
[0058] In some embodiments, the data storage method provided in the embodiments of the present application is applied to a flash memory, and the flash memory includes a first storage area; it can be understood that when a FLASH storage device is needed to simulate an EEPROM storage device to improve the erase and write life of the FLASH storage device, a FLASH area, namely the first storage area, is divided in the FLASH storage device for use in simulating the EEPROM storage device.
[0059] In some embodiments, taking into account the erasing life and the read / write speed, the FLASH area divided in step 100 is divided into a plurality of independent small areas with a plurality of basic erasing units as a small area, i.e., the second storage area, to obtain a plurality of second storage areas. Specifically, the number of basic erasing units in the second storage area can be 1, 2, 3, 4, etc., which is specifically set according to the read / write speed, the amount of stored data, and the erasing life requirements.
[0060] In some embodiments, the basic erasing unit of the second storage area is a page.
[0061] In some embodiments, the second storage area includes an identification area and a storage area. When traversing from front to back, the identification area includes the area occupied by the first K bytes of the second storage area, where K is a positive integer, and the data in the identification area is used to characterize the state of the second storage area. When traversing from front to back, the storage area includes an area in the second storage area connected to the identification area, and the storage area is used to store the written data to be stored.
[0062] Specifically, the area occupied by the first 16 bytes of the second storage area is the identification area, and the state of the corresponding second storage area is determined by the representation form of the 16 bytes in the identification area.
[0063] In some embodiments, see Figure 5 , Figure 5 This is a state distinction table of regions in the data storage method provided in the embodiment of the present application, and the states of the regions include:
[0064] Legal state: The legal state is used to indicate that the area can be read and written. Specifically, in hexadecimal notation, the first 16 bytes of data in the identification area of the second storage area in the legal state are:
[0065] 5555AAAA 5555AAAA FFFFFFFF FFFFFFFF;
[0066] Full state: The full state is used to indicate that the storage space of the area is full of data. Specifically, in hexadecimal notation, the first 16 bytes of data in the identification area of the second storage area when the full state is in effect are:
[0067] 5555AAAA 5555AAAA 5555AAAA FFFFFFFF;
[0068] Receiving state: The receiving state is used to indicate that the area is receiving data from another area. Specifically, in hexadecimal notation, the first 16 bytes of data in the identification area of the second storage area in the receiving state are:
[0069] 5555AAAA FFFFFFFF FFFFFFFF FFFFFFFF;
[0070] Illegal state: The illegal state is used to indicate that the area needs to clear data. Specifically, in hexadecimal notation, the first 16 bytes of data in the identification area of the second storage area in the illegal state are:
[0071] 5555AAAA 5555AAAA 5555AAAA 5555AAAA;
[0072] The erase state is used to indicate that all data in the area has been cleared. Specifically, in hexadecimal notation, the first 16 bytes of data in the identification area of the second storage area in the erase state are:
[0073] FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF.
[0074] In some embodiments, the storage area includes a data area, a virtual address area, and a check area, the data area is used to store the data to be stored; the virtual address area is used to store the virtual address of the data to be stored; the check area is used to store the check code of the data to be stored and the check code of the virtual address. Specifically, the storage area is stored in the form of four bytes, the data area is allocated with a 16-bit unsigned integer data space, that is, two bytes of storage space; the virtual address area is allocated with an 8-bit unsigned integer address space, that is, one byte of storage space; the check area is allocated with an 8-bit CRC (Cycl ic Redundancy Check) check code space, that is, one byte of storage space.
[0075] In some embodiments, see Figure 2 , Figure 2 A specific flow chart for determining the number of second storage areas in the data storage method provided in an embodiment of the present application. When determining the number of second storage areas, steps a to c are specifically implemented:
[0076] Step a: determining the unit erase and write life of the second storage area;
[0077] Step b: Determine the target erase life;
[0078] Step c: determining the number of the second storage areas based on the target erase / write lifespan and the unit erase / write lifespan.
[0079] Specifically, the characterization formula for determining the number of the second storage area includes:
[0080] n*m≥a;
[0081] Wherein, n is the unit erase life; m is the number of the second storage area; a is the target erase life. It can be understood that when a FLASH flash memory storage device is used to simulate an EEPROM storage device, the erase life of the FLASH flash memory storage device is ten thousand times, that is, corresponding to the unit erase life of the second storage area, and the erase life of the EEPROM storage device is one million times, that is, corresponding to the target erase life.
[0082] In some embodiments, see Figure 1 , Figure 1 This is a step flow chart of the data storage method provided in the embodiment of the present application. The data storage method provided in the embodiment of the present application is specifically implemented through steps 100 to 200:
[0083] Step 100: writing the data to be stored into a second storage area capable of performing read and write operations.
[0084] Specifically, the method for determining the second storage area capable of performing read and write operations includes:
[0085] By traversing from front to back and searching the identification area of each second storage area, if the second storage area is in a legal state, it is determined that the second storage area can be read and written.
[0086] In some embodiments, the data storage method provided by the embodiments of the present application is also configured with a global variable for storing the storage address of the latest data to be written in the second storage area, that is, when the latest data to be written is written, the storage address recorded in the global variable is first found, and then it is determined whether the storage address is in an erased state. If the storage address is in an erased state, the data is written to the storage address without traversal search, and the location to be written can be found directly through the storage address, which can effectively improve the data writing efficiency; otherwise, when writing data, the storage area that has not been written is searched from front to back in multiple storage areas of the second storage area where read and write operations can be performed, that is, the storage area where the first 4 consecutive bytes are all 0xFF, and the data is written.
[0087] In some embodiments, the data storage method provided by the embodiment of the present application is further configured with an address storage area for storing the storage address of the latest data to be written corresponding to the virtual address in the second storage area, that is, an address storage area is set for each virtual address, and the storage address of the latest data to be written corresponding to each virtual address is placed in the corresponding storage area. It can be understood that when reading data, the storage address in each storage area is first obtained, and then the state of the second storage area where the storage address is located is determined. If it is in a legal state, it means that the read and write operation is currently being performed in the second storage area, and the data in the storage address can be directly read without traversing and searching. The latest data written to the corresponding virtual address can be directly found through the storage address for reading, which can effectively improve the data reading efficiency; otherwise, the identification area of each second storage area is searched, and the second storage area in a legal state is found to be the second storage area that can perform read and write operations. The data corresponding to the virtual address is searched from back to front in the second storage area that can perform read and write operations. If it cannot be found, it means that the data corresponding to the virtual address has not been written. If it is found, it can be read.
[0088] In some embodiments, when the data storage method provided by the embodiment of the present application is implemented, the update time of the latest data corresponding to each virtual address can be monitored in real time, and a time threshold can be set. When the update time of the latest data corresponding to the virtual address is greater than the time threshold, the next second storage area is set to a receiving state, and the latest data of the virtual address is stored in the next second storage area. At the same time, the virtual address is continuously monitored to see if there is new data to be written in the future. If there is still no new data written to the virtual address when the second storage area currently in a legal state is full, the data of the virtual address does not need to be considered when the data is transferred, so as to reduce the amount of data retrieval during data transfer and improve the efficiency of data transfer; if there is new data written to the virtual address before the second storage area currently in a legal state is full, the latest data is directly written to the next second storage area in a receiving state to avoid missing data and improve the reliability of data transfer.
[0089] Step 200: In response to the second storage area capable of performing read and write operations being full, the most recently written data to be stored corresponding to the virtual address in the second storage area capable of performing read and write operations is written into the next second storage area capable of performing read and write operations, and the read and write operations are continued in the next second storage area capable of performing read and write operations.
[0090] Specifically, if the space in the second storage area that can currently perform read and write operations is full of data, erase the next second storage area, set the next second storage area to a receiving state, and at the same time set the second storage area that can currently perform read and write operations to a full state, and write the latest written data to be stored corresponding to the virtual address in the second storage area that can currently perform read and write operations into the next second storage area, and after writing is completed, set the next second storage area to a legal state, and continue to perform read and write operations in the next second storage area.
[0091] In some embodiments, in the data storage method provided by the embodiments of the present application, if the flash memory storage device is powered on again, a power-on initialization operation is performed on the flash memory storage device, and the power-on initialization operation includes: traversing the identification areas of each second storage area from front to back, if the current state of the second storage area is a receiving state, and the state of the previous second storage area is a full state, then completing the data transfer of the second storage area in the previous full state to the data of the second storage area in the current receiving state, and continuing to write the latest written data to be stored corresponding to the virtual address in the previous second storage area to the current second storage area, and after the writing is completed, the second storage area in the current receiving state is set to a legal state; if the current second storage area is a legal state, if there is a second storage area in a legal state before, erase the data in the current second storage area; if the current second storage area is a full state, when there are second storage areas in other legal states, erase the current second storage area, otherwise store the latest written data corresponding to all virtual addresses in the current second storage area to the next second storage area, and write the latest written data to be stored corresponding to the virtual address in the current second storage area to the next second storage area.
[0092] For example, see Figures 6 to 13 , Figure 6 A state table when multiple second storage areas are not initialized in the data storage method provided in the embodiment of the present application, Figure 7 The table is a state table of the second storage area code BLOCK0 in the plurality of second storage areas in the data storage method provided in the embodiment of the present application when the second storage area is initialized in a legal state and other second storage areas are not initialized. Figure 8 A state table for setting and writing the first group of data in a second storage area coded BLOCK0 in a plurality of second storage areas in the data storage method provided in an embodiment of the present application, Fig. 9 A state table for writing a second group of data into a second storage area coded as BLOCK0 in a plurality of second storage areas in the data storage method provided in an embodiment of the present application, Fig.10 A status table showing that a second storage area coded as BLOCK0 in a plurality of second storage areas is full of data in the data storage method provided in an embodiment of the present application. Fig.11A state table showing that a second storage area coded as BLOCK0 in a plurality of second storage areas is full of data and a second storage area coded as BLOCK2 receives three sets of data in the data storage method provided in an embodiment of the present application. Fig.12 A status table showing that a second storage area coded as BLOCK0 in a plurality of second storage areas is full of data and a second storage area coded as BLOCK2 is set to a legal area in the data storage method provided in an embodiment of the present application, Fig.13 A state table showing that a second storage area coded as BLOCK0 is full of data and a second storage area coded as BLOCK2 is written with a fourth set of data in a data storage method provided in an embodiment of the present application. Wherein BLOCK is a second storage area, and 0, 1, ... n are multiple different second storage areas. It can be understood that Figures 6 to 13 The present invention is a process diagram of a method for traversing storage from front to back in multiple second storage areas, showing a process in which the first second storage area is changed from an uninitialized state to an initialized legal state, and after the legal state is filled with data, all virtual addresses corresponding to the most recently written data are stored in the next second storage area, and then subsequent read and write operations are performed in the next second storage area.
[0093] It can be understood that the embodiment of the present application provides a data storage method, which is applied in a flash memory storage device. The data storage method of the present application first determines a first storage area for storing data in the flash memory storage device, and then divides a plurality of partial storage spaces in the first storage area to determine a plurality of second storage areas; finds a second storage area that can perform read and write operations in the plurality of second storage areas, and performs read and write operations in the second storage area that can perform read and write operations; when the space of the second storage area that can perform read and write operations is full of data, the newly written data to be stored corresponding to the virtual address in the second storage area that can perform read and write operations is written into the next second storage area that can perform read and write operations, and after the writing is completed, the read and write operations are continued in the next second storage area that can perform read and write operations. The present application divides a plurality of second storage areas in the first storage area, performs cyclic erasing and writing storage of data between the plurality of second storage areas, divides a large storage area into a plurality of small storage areas, and based on the same erasing and writing life of the large and small areas, the data that needs to be scatteredly stored is cyclically erased and written by increasing the number of erasing and writing areas in the same storage area, which can effectively improve the erasing and writing life of the overall large area.
[0094] Accordingly, the embodiment of the present application also provides a data storage system, see Figure 3 , Figure 3 A module connection diagram of a data storage system provided in an embodiment of the present application, wherein the flash memory storage device includes a first storage area, the first storage area includes a plurality of second storage areas, and the data storage system provided in an embodiment of the present application includes:
[0095] A data writing module 10, the data writing module 10 is used to write the data to be stored into the second storage area capable of performing read and write operations;
[0096] The data transfer module 20 is used to write the latest written data to be stored corresponding to the virtual address in the second storage area that can perform read and write operations into the next second storage area that can perform read and write operations in response to the second storage area that can perform read and write operations being full, and continue to perform read and write operations in the next second storage area that can perform read and write operations.
[0097] In some embodiments, the data storage system provided in the embodiments of the present application is specifically used for:
[0098] Determine the unit erase and write life of the second storage area;
[0099] Determine the target erase and write lifespan;
[0100] The number of the second storage areas is determined based on the target erase / write lifespan and the unit erase / write lifespan.
[0101] In some embodiments, the state of the second storage area includes a legal state, a full state, a receiving state, an illegal state and an erase state, the legal state is used to indicate that the area can be read and written, the full state is used to indicate that the storage space of the area is full of data, the receiving state is used to indicate that the area is receiving data from another area, the illegal state is used to indicate that the area needs to clear data, and the erase state is used to indicate that all data in the area has been cleared; the data transfer module 20 is specifically used to:
[0102] If the second storage area is in a legal state, it is determined that the second storage area can be read and written.
[0103] In some embodiments, the data storage system provided in the embodiments of the present application is specifically used for:
[0104] If the flash memory storage device is powered on again, a power-on initialization operation is performed on the flash memory storage device, and the power-on initialization operation includes:
[0105] If the current second storage area is in a receiving state and the previous second storage area is in a full state, the latest written data to be stored corresponding to the virtual address in the previous second storage area is written into the current second storage area, and the current second storage area is set to a legal state;
[0106] If the current second storage area is in a legal state, and there is a second storage area in a legal state before the current second storage area, clearing the data in the current second storage area;
[0107] If the current second storage area is full and there is a second storage area in a legal state, the data in the current second storage area is cleared, or the latest written data to be stored corresponding to the virtual address in the current second storage area is written into the next second storage area.
[0108] In some embodiments, the data storage system provided in the embodiments of the present application is specifically used for:
[0109] Configure an address storage area, the address storage area is used to store the storage address of the latest data to be written corresponding to the virtual address in the second storage area;
[0110] Configure a global variable, where the global variable is used to store the storage address of the latest data to be written in the second storage area;
[0111] When reading data, if the second storage area where the storage address in the address storage area is located is in a legal state, then the data in the storage address in the address storage area is read;
[0112] When writing data, if the second storage area where the storage address in the global variable is located is in a legal state, and the storage address in the global variable is in an erased state, then the data is written to the storage address in the global variable.
[0113] Accordingly, an embodiment of the present application further provides an electronic device, see Figure 4 , Figure 4 This is a simplified structural diagram of an electronic device provided in an embodiment of the present application. The electronic device provided in an embodiment of the present application includes:
[0114] The memory 100 and the processor 200 are connected to each other in communication, the memory 100 stores computer instructions, and the processor 200 executes the data storage method provided in the embodiment of the present application by executing the computer instructions. Specifically, the memory 100 and the processor 200 are connected via a communication bus.
[0115] In some embodiments, the processor 200 may be a central processing unit (CPU). The processor 200 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0116] In some embodiments, the memory 100 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions / modules corresponding to the methods in the method embodiments of the present application. The processor 200 executes various functional applications and data processing of the processor 200 by running the non-transitory software programs, instructions and modules stored in the memory 100, that is, implementing the methods in the above method embodiments.
[0117] In some embodiments, the memory 100 may include a program storage area and a data storage area, wherein the program storage area may store an application required for operating the device or at least one function; the data storage area may store data created by the processor 200, etc. In addition, the memory 100 may include a high-speed random access memory 100, and may also include a non-volatile memory 100, such as at least one disk memory 100, a flash memory device, or other non-volatile solid-state memory 100. In some embodiments, the memory 100 may optionally include a memory 100 remotely arranged relative to the processor 200, and these remote memories 100 may be connected to the processor 200 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.
[0118] In some embodiments, one or more modules are stored in the memory 100 and when executed by the processor 200, the methods in the above method embodiments are performed.
[0119] In some embodiments, the specific details of the above-mentioned electronic device can be understood by referring to the corresponding related descriptions and effects in the above-mentioned method embodiments, and will not be repeated here.
[0120] The present application has described in detail a data storage method, system and electronic device provided by the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data storage method, characterized in that: Applied to a flash memory storage device, the flash memory storage device includes a first storage area, the first storage area includes a plurality of second storage areas; the data storage method includes: Writing the data to be stored into the second storage area capable of performing read and write operations; In response to the second storage area that can perform read and write operations being full, the most recently written data to be stored corresponding to the virtual address in the second storage area that can perform read and write operations is written into the next second storage area that can perform read and write operations, and the read and write operations are continued in the next second storage area that can perform read and write operations.
2. The data storage method according to claim 1, characterized in that: Also includes: Determine the unit erase and write life of the second storage area; Determine the target erase and write lifespan; The number of the second storage areas is determined based on the target erase / write lifespan and the unit erase / write lifespan.
3. The data storage method according to claim 2, characterized in that: The characterization formula for determining the number of the second storage area based on the target erase life and the unit erase life includes: n*m≥a; Wherein, n is the unit erase / write life; m is the number of the second storage areas; and a is the target erase / write life.
4. The data storage method according to claim 1, characterized in that: The second storage area includes: an identification area, the identification area including an area occupied by the first K bytes of the second storage area; the data in the identification area is used to characterize the state of the second storage area, and K is a positive integer; A storage area, the storage area includes an area in the second storage area connected to the identification area, and the storage area is used to store the written data to be stored.
5. The data storage method according to claim 4, characterized in that: The storage area includes: A data area, wherein the data area is used to store the data to be stored; A virtual address area, wherein the virtual address area is used to store the virtual address of the data to be stored; A check area is used to store the check code of the data to be stored and the check code of the virtual address.
6. The data storage method according to claim 4, characterized in that: The state of the area includes a legal state, a full state, a receiving state, an illegal state and an erase state, wherein the legal state is used to indicate that the area can be read and written, the full state is used to indicate that the storage space of the area is full of data, the receiving state is used to indicate that the area is receiving data from another area, the illegal state is used to indicate that the area needs to clear data, and the erase state is used to indicate that all data in the area has been cleared: the method for determining the second storage area that can be read and written includes If the second storage area is in the legal state, it is determined that the second storage area can be read and written.
7. The data storage method according to claim 6, characterized in that: The data storage method further comprises: If the flash memory storage device is powered on again, a power-on initialization operation is performed on the flash memory storage device, and the power-on initialization operation includes: If the current second storage area is in a receiving state and the previous second storage area is in a full state, the newly written data to be stored corresponding to the virtual address in the previous second storage area is written into the current second storage area, and the current second storage area is set to a legal state; If the current second storage area is in a legal state, and there is a second storage area in a legal state before the current second storage area, clearing the data in the current second storage area; If the second storage area is currently full and there is a second storage area in a legal state, the data in the second storage area is cleared, or the most recently written data to be stored corresponding to the virtual address in the second storage area is written into the next second storage area.
8. The data storage method according to claim 6, characterized in that: The data storage method further comprises: configuring an address storage area, the address storage area being used to store the storage address of the latest data to be written corresponding to the virtual address in the second storage area; Configuring a global variable, wherein the global variable is used to store a storage address of the latest data to be written in the second storage area; When reading data, if the second storage area where the storage address in the address storage area is located is in a legal state, then reading the data in the storage address in the address storage area; When writing data, if the second storage area where the storage address in the global variable is located is in a legal state and the storage address in the global variable is in an erased state, data is written to the storage address in the global variable.
9. A data storage system, characterized in that: Applied to a flash memory storage device, the flash memory storage device includes a first storage area, the first storage area includes a plurality of second storage areas, and the data storage system includes: A data writing module (10), the data writing module (10) being used to write data to be stored into a second storage area capable of performing read and write operations; A data transfer module (20), the data transfer module (20) is used to write the most recently written data to be stored corresponding to the virtual address in the second storage area that can perform read and write operations into the next second storage area that can perform read and write operations in response to the second storage area that can perform read and write operations being full, and continue to perform read and write operations in the next second storage area that can perform read and write operations.
10. An electronic device, characterized in that: include: A memory (100) and a processor (200), wherein the memory (100) and the processor (200) are communicatively connected to each other, the memory (100) stores computer instructions, and the processor (200) executes the data storage method according to any one of claims 1 to 8 by executing the computer instructions.