Storage management method, memory, electronic equipment and storage medium
By setting a flag storage area in the Flash memory and determining the target data block based on the status flag, the instability problem caused by emergencies during the erasure process is solved, the operation efficiency and memory reliability are improved, and the service life is extended.
Patent Information
- Application Number
- CN202510615007.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-05-13
AI Technical Summary
During the erase process, the unstable state of Flash memory is caused by unexpected situations such as power failure or restart, resulting in uncertainty in data writing and shortening of memory life.
A flag storage area is set in each data block, the target data block to be operated is determined through the status flag, and corresponding operations are performed according to the target data state in the data storage area, including updating the status flag and positioning the index value of the data block.
Improves the operating efficiency of the memory, reduces the time and resources wasted due to inaccurate positioning, ensures data integrity and accuracy, and extends the service life of the memory.
Smart Images

Figure CN120540588A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data storage technology, and in particular to a storage management method, a memory, an electronic device, and a storage medium. Background Art
[0002] Flash memory, as a non-volatile storage medium, is widely used in various electronic devices. Before writing new data to Flash memory, the storage cells must be erased. However, during the erase process, unexpected events such as a power outage or device restart may cause the erase operation to be incomplete, leaving the storage cells in an unstable state and causing uncertainty when writing data. Summary of the Invention
[0003] Embodiments of the present application provide a storage management method, a memory, an electronic device, and a storage medium to solve the above-mentioned problems.
[0004] To achieve the above-mentioned objectives, according to a first aspect of the present application, a storage management method is provided, which is applied to a memory, wherein storage space of the memory is used to store multiple log information, each log information corresponding to multiple data blocks, each data block including a data storage area for storing at least one piece of data and a flag storage area for storing a status flag; the status flag of each data block is used to indicate the data write status of the data block and the erase status of the next data block of the data block, the method comprising:
[0005] In response to an operation instruction for the memory, determining a target data block to be operated from the data blocks according to a status flag of each data block;
[0006] determining a state of the target data block based on the target data last written into the data storage area of the target data block;
[0007] Based on the status of the target data block, an update operation is performed on the status flag of the target data block or an operation is performed on the data storage area of the target data block in response to the operation instruction.
[0008] Optionally, the status flag includes a first status flag bit indicating an erase status of a data block next to the data block and a second status flag bit indicating a data write status of the data block;
[0009] The step of determining a target data block to be operated from the data blocks according to the status flag of each data block includes:
[0010] Using the first data block where the first status flag is not a preset flag and the second status flag is a preset flag as the target data block; and / or
[0011] In the absence of the first data block, a target data block is determined based on the second data block; wherein the second data block refers to a data block in which the first status flag and the second status flag are both preset flags, and the first status flag and the second status flag of the next data block of the second data block are not preset flags.
[0012] Optionally, determining the state of the target data block based on the target data last written into the data storage area of the target data block includes:
[0013] If the target data is not the first data piece or the last data piece, determining that there is no abnormality in the status flag of the target data block;
[0014] If the target data is the first piece of data or the last piece of data, the status of the target data block is determined based on a status flag.
[0015] Optionally, performing an update operation on a status flag of the target data block based on the status of the target data block or operating a data storage area of the target data block in response to the operation instruction includes:
[0016] In a case where the state of the target data block is not abnormal, responding to the operation instruction, performing a read and write operation on the data storage area of the target data block based on the target data last written in the data storage area;
[0017] When the state of the target data block is abnormal, performing an update operation on the state flag of the target data block includes:
[0018] If the target data of the target data block is the last piece of data, performing an erasing operation on the next data block, and after the erasing operation is completed, writing a first status flag bit into the flag storage area of the target data block;
[0019] If the target data of the target data block is the first piece of data, a second status flag is written into the flag storage area of the target data block.
[0020] Optionally, the flag storage area further includes a third status flag, and the third status flag indicates the storage progress of writing data to the data block. The method further includes:
[0021] determining a target storage schedule for the target data block based on the target data;
[0022] When the target storage progress reaches different preset progress thresholds, the third status flag bit of the target data block flag storage area is updated.
[0023] Optionally, the method further includes:
[0024] Determining a target index interval of the target data block based on a third status flag of the target data block;
[0025] Based on the target index range, a target index value is obtained by a preset search method to determine the target data corresponding to the target index value.
[0026] Optionally, in response to the operation instruction, operating the data storage area of the target data block includes:
[0027] Get write operation instructions;
[0028] A first index value is determined based on the target data, a write operation is performed on a storage address corresponding to the first index value based on the data to be written in the write operation instruction, and a status flag of the target data block is updated.
[0029] Optionally, in response to the operation instruction, operating the data storage area of the target data block includes:
[0030] Based on the second index value in the read operation instruction, read the storage data from the storage address corresponding to the second index value;
[0031] When the preset index value in the stored data is the same as the second index value, the data bits in the stored data are verified, and based on the verification result, the stored data corresponding to the next index value of the second index value is read.
[0032] Optionally, the method further includes:
[0033] When the verification result is failure, the preset index value in the stored data is set as a preset mark value, and the preset mark value is used to indicate that the data bit of the stored data is erroneous data.
[0034] Optionally, the memory is a Flash memory, and the memory is used to store high-frequency log information with a small amount of data.
[0035] According to the second aspect of the present application, an embodiment of the present application also provides a memory, the storage space of the memory is used to store multiple log information, one log information corresponds to multiple data blocks, each data block includes a data storage area for storing at least one piece of data and a flag storage area for storing a status flag.
[0036] According to a third aspect of the present application, an embodiment of the present application further provides an electronic device, including:
[0037] a memory having a computer program stored thereon;
[0038] A processor is used to execute the computer program in the memory to implement the steps of any one of the methods provided in the embodiments of the present application.
[0039] According to the fourth aspect of the present application, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the methods provided in the embodiments of the present application are implemented.
[0040] Some embodiments of the present specification include at least the following beneficial effects: by setting a flag storage area in each data block to store a status flag and determining the target data block to be operated on based on the status flag, this overcomes the technical problem of traditional memories being unable to quickly and accurately locate the target data block during data operations, resulting in low operational efficiency. Furthermore, by quickly and accurately determining the target data block to be operated on in this manner, the operational efficiency of the memory can be improved, reducing time and resources wasted due to inaccurate positioning. Furthermore, by determining the status of the target data block based on the last target data written to the data storage area of the target data block and performing corresponding operations accordingly, abnormal situations can be promptly detected and handled, avoiding data loss or damage, further improving the reliability and stability of the memory, and ensuring the integrity and accuracy of the data.
[0041] Other features and advantages of the present application will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] To more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present application. Those skilled in the art can also derive other drawings based on these drawings without inventive effort.
[0043] In order to more completely understand the present application and its beneficial effects, the following description will be given in conjunction with the accompanying drawings, wherein the same drawing numbers represent the same parts in the following description.
[0044] Figure 1 is a schematic diagram of the structure of a memory according to some embodiments of this specification;
[0045] Figure 2 is an exemplary flow chart of a storage management method according to some embodiments of this specification;
[0046] Figure 3 is an exemplary schematic diagram of determining a target index value according to some embodiments of this specification;
[0047] Figure 4is an exemplary schematic diagram of an update status mark according to some embodiments of this specification;
[0048] Figure 5 is an exemplary schematic diagram of executing a write operation instruction according to some embodiments of this specification;
[0049] Figure 6 is an exemplary schematic diagram of executing a read operation instruction according to some embodiments of this specification;
[0050] Figure 7 This is a structural diagram of an electronic device according to some embodiments of this specification. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are only part of the embodiments of the present application, not 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.
[0052] In order to facilitate understanding of the implementation scheme provided in the embodiment of the present application, the relevant application background of the storage management method provided in the embodiment of the present application is first explained.
[0053] At present, Flash memory is a widely used non-volatile storage medium with the advantages of no data loss during power failure, fast erase and write speed, and small size. It is widely used in various electronic devices.
[0054] Because flash memory write operations can only change a "1" to a "0" and not a "0" to a "1," you must first erase the memory cells before writing new data, setting all data bits to "1" to ensure that new data can be written correctly. This erase operation increases data storage time because only erased memory cells can be used to store new data.
[0055] However, erasing Flash memory also carries certain risks. During the erase process, if an unexpected event occurs, such as a power outage or reboot, the erase operation may not be completed, leaving the memory cell in an unstable state. This can create uncertainty when writing data later. For example, partially erased data may conflict with newly written data, leading to data errors or loss. Furthermore, frequent erase operations can impact the lifespan of Flash memory, as each erase operation causes some damage to the physical structure of the memory cell. As the number of erases increases, the reliability of the memory cell gradually decreases, potentially leading to memory failure.
[0056] In view of this, some embodiments of the present specification provide a storage management method, which sets a flag storage area in each data block to save a status flag, and determines the target data block to be operated based on the status flag. While ensuring the accuracy of data storage, it can improve the reliability and stability of the erase operation, reduce the impact of emergencies on data writing, and thus improve the overall performance and service life of the Flash memory.
[0057] Figure 1 It is a schematic diagram of the structure of a memory according to some embodiments of this specification.
[0058] like Figure 1 As shown, the storage space of the memory is used to store multiple log information, one log information corresponds to multiple data blocks, each data block includes a data storage area for storing at least one piece of data and a flag storage area for storing a status flag; the status flag of each data block is used to indicate the data writing status of the data block and the erasure status of the next data block of the data block.
[0059] A data block is used to store data in the memory. The memory is erased in units of a data block.
[0060] In some embodiments, a data block includes multiple sectors. For example, a data block may include 16 minimum sectors, a minimum sector may include multiple pages, and each page includes multiple bytes.
[0061] In some embodiments, the memory's storage space can store multiple types of log information, with each type of log information corresponding to X data blocks, where a single data block can store both a data storage area and a flag storage area for Y pieces of data. In some embodiments, the number of data blocks, X, is ≥ 2. The larger the number of data blocks, X, the longer the storage lifespan of the storage area. In some embodiments, X is at least 2, which facilitates data backtracking, such as for rollback versions of embedded system software code and log review.
[0062] The data storage area is the part of the data block used to store actual data. Each data storage area can store one or more data records.
[0063] In some embodiments, the size of the data storage area can be determined according to the design and application scenario of the memory. The data storage area can be used for write operations and read operations. The contents of the data storage area are cleared after an erase operation, and the values of all storage cells are reset to "1".
[0064] The flag storage area is the portion of a data block that stores status flags. Status flags record information about a data block or data storage area, such as data validity, erase status, and error flags. The flag storage area enables the memory to more efficiently manage and maintain the status of data blocks.
[0065] In some embodiments, the flag storage area may include a small number of storage cells for storing status information. For example, the flag storage area may be one or more bytes for storing status flags. For example, a valid flag for indicating whether data is valid; an erase flag for indicating whether a data block has been erased; an error flag for indicating whether a data block has an error, etc.
[0066] In some embodiments, the content of the flag storage area is cleared after an erase operation, and when writing data, the status information of the flag storage area may be updated first.
[0067] In some embodiments, the flag storage area includes multiple flag bits, and the size of the flag bits is not limited. In some embodiments, flag 1 is a flag used to indicate that the next data block has been erased. After the last piece of data is written to the data block, the next adjacent data block begins to be erased. After the erasure is completed, flag 1 is written to the flag storage area of the data block. Flag 2 indicates that data has been written to the current data block. After the first piece of data is written to the data block, flag 2 is written to the flag storage area of the data block. Flag 3 is used to dynamically indicate the storage progress of the current data block, such as 10%, 20%, etc. This flag 3 can narrow the search range when obtaining the index value and quickly locate the position of a specific data strip in the data block. The larger the flag 3 occupies, the faster the search.
[0068] In some embodiments, the flag storage area can also be freely supplemented with other flags for adaptation. For example, if the data stored in the memory is software data to be upgraded, a flag indicating the software version number can be supplemented. After reserving storage space for the flag storage area, the remaining storage space can be stored at equal intervals according to the size of a single piece of data. For example, N minimum erase units are used to store a data storage area plus a flag storage area for a maximum of Y pieces of data. However, in actual use, (Y-1) pieces of data can meet the design requirements, resulting in a waste of storage space. In some embodiments, the data storage area is increased to Y pieces of data so that the occupied space is N minimum erase units, so as to maximize the utilization of the occupied N minimum erase units and improve storage space utilization and storage life (where N≥1, Y≥1, N and Y are both integers).
[0069] It should be noted that the above description of the memory and its components is provided for ease of description and distinction only. The references to symbols 1, 2, and 3 are not sequentially ordered and are provided for ease of description only. This description is not intended to limit this specification to the illustrated embodiments. It is understood that those skilled in the art, after understanding the principles of this memory, may arbitrarily combine the components or form subsystems connected to other modules without departing from these principles. Such variations are within the scope of this specification.
[0070] Figure 2 is an exemplary flow chart of a storage management method according to some embodiments of this specification. In some embodiments, process 200 can be executed based on a processor. Figure 2 As shown, the process 200 includes the following steps.
[0071] Step 210 , responding to an operation instruction on the memory, and determining a target data block to be operated from the data blocks according to a status flag of each data block.
[0072] An operation instruction is a command used to instruct the memory to perform a specific operation. For example, a specific operation may include reading, writing, erasing, updating, etc.
[0073] In some embodiments, an operation instruction typically includes: an operation type, a target address, and data content. The operation type refers to the type of specific operation to be performed, such as read, write, or erase. The target address refers to the target storage location of the operation, such as the number or address of a data block. For a write operation, the data content refers to the data information to be written.
[0074] The status flag refers to the status information stored in the flag storage area of each data block, which is used to record the current status of the data block.
[0075] The target data block refers to a data block determined from the memory and requiring an operation.
[0076] In some embodiments, the target data block to be operated on can be determined from the data blocks in various ways based on the status flag of each data block. For example, if the operation type of the operation instruction is write, an erased and error-free data block can be selected as the target data block based on the status flag.
[0077] In some embodiments, the status flag includes a first status flag bit indicating an erase status of a data block next to the data block and a second status flag bit for indicating a data write status of the data block;
[0078] According to the status flag of each data block, the target data block to be operated is determined from the data blocks, including:
[0079] The first data block whose first status flag is not a preset flag and whose second status flag is a preset flag is used as the target data block; and / or
[0080] In the absence of the first data block, the target data block is determined based on the second data block; wherein the second data block refers to a data block in which the first status flag and the second status flag are both preset flags, and the first status flag and the second status flag of the next data block of the second data block are not preset flags.
[0081] The first data block refers to an unfilled data block. The second data block refers to a previous data block of a new data block to be written.
[0082] The first status flag (such as Figure 1 The flag 1) shown can be a value of 0 or 1, 1 indicating that the erasure status of the next data block after the data block is not erased, and 0 indicating that the erasure status of the next data block after the data block is erased.
[0083] The second status flag (such as Figure 1 The flag 2) shown can be a value of 0 or 1, 1 indicates that the data write status of the data block is no data written, and 0 indicates that the data write status of the data block is data written.
[0084] In some embodiments, the status flag of each data block can be read, the first status flag and the second status flag can be checked, and whether the data block has been written can be determined based on each status flag. For example, if multiple status flags of a data block are not preset flags (such as 0), it means that the data block has not been written. Exemplarily, if the first status flag and the second status flag of multiple data blocks are not preset flags, the memory is blank, and the first data block of the memory is used as the target data block.
[0085] In some embodiments, if the first status flag and the second status flag of each data block are both 1, it is determined that no data is written into each data block, and the first data block is used as the target data block.
[0086] In some embodiments, if the first status flag of the existing data block is 1 and the second status flag is 0, it is determined that there is an unfulfilled first data block, and the first data block is used as the target data block.
[0087] It should be noted that the first state flag is 1 and the second state flag is 0 in the following situations:
[0088] The data block has data written to it, but the last piece of data has not been written; or
[0089] The data block has been written to the last data entry, but due to an abnormality such as a power outage, the next data block has not yet been erased.
[0090] The last piece of data refers to the last data unit expected to be written in the data block.
[0091] In some embodiments, if there is no data block whose first status flag is 1 and whose second status flag is 0, it indicates that the status flags of the current multiple data blocks have the following situations: the first status flag is 1 and the second status flag is 1; or the first status flag is 0 and the second status flag is 0.
[0092] In some embodiments, a second data block can be determined based on status flags of multiple data blocks, and the second data block satisfies: the first status flag bit is 0 and the second status flag bit is 0, and the first status flag bit and the second status flag bit of the next data block of the second data block are 1 and 1.
[0093] It should be noted that there are at least two data blocks, namely data block 1 and data block 2. When the last data is written to data block 1 and erased in data block 2, the first status flag of data block 1 is 0 and the second status flag is 0. At this time, the following situations may occur:
[0094] There is no new data to be recorded. At this time, an abnormal situation such as power failure or restart occurs. The status flag of data block 2 does not have a valid flag, that is, the first status flag bit of data block 2 is 1 and the second status flag bit is 1;
[0095] For data block 2, if a power outage, restart, etc. occurs between the operation of writing the first data and the operation of writing the second status flag, there is no valid flag in the status flag of data block 2, that is, the first status flag of data block 2 is 1 and the second status flag is 1.
[0096] In some embodiments, the target data block can be determined based on the second data block. For example, if the first data piece of the data block following the second data block has written data, the next data block of the second data block is used as the target data block; if the first data piece of the data block following the second data block does not have written data, the second data block is used as the target data block.
[0097] In some embodiments of the present specification, through clear status flags, the status of data blocks can be managed more accurately, reducing the risk of errors and data loss; by giving priority to the first data block (a data block that has been erased and not fully written with data), unnecessary erasing operations can be avoided, thereby reducing wear on the memory and extending its service life; in the absence of the first data block, by selecting the second data block, a block that has been written with data but whose next block is free can be utilized, thereby managing storage space more flexibly.
[0098] Step 220 : Determine the state of the target data block based on the target data last written into the data storage area of the target data block.
[0099] The last written target data refers to the data written by the last write operation in the data storage area of the target data block. The target data can be log information or other forms of data.
[0100] The state of the target data block may refer to the state of a state flag of the data block during the writing process. For example, the state of the target data block may indicate that the state flag of the target data block has not been updated in time due to some reason (such as power failure, system failure, etc.).
[0101] In some embodiments, the status flag of the target data block (such as the first status flag and the second status flag) can be combined to determine whether an abnormality occurs in the target data block during the writing process to determine the status of the target data block.
[0102] In some embodiments, determining the state of the target data block based on the target data last written in the data storage area of the target data block includes:
[0103] If the target data is not the first data or the last data, determine that there is no abnormality in the status flag of the target data block;
[0104] If the target data is the first piece of data or the last piece of data, the status of the target data block is determined based on the status flag.
[0105] In some embodiments, if the target data is not the first piece of data or the last piece of data, it indicates that there is no abnormality in the status flag of the target data block.
[0106] In some embodiments, if the target data is the first data or the last data, it means that after the write operation of the target data block or the erase operation of the next data block, the status flag may not be updated in time. The update status of the status flag of the target data block can be determined based on the specific value of the target data and the status flag.
[0107] In some embodiments, if the target data is the last piece of data in the target data block and the target data block does not have a first status flag written thereto (for example, the first status flag is 1), it is determined that an abnormality exists in the status flag of the target data block.
[0108] In some embodiments, if the target data is the first data in the target data block and the target data block does not have a written second status flag (for example, the second status flag is 1), it is determined that there is an abnormality in the status flag of the target data block.
[0109] In some embodiments of this specification, by checking the target data and the status flag of the target data block, the status of the target data block is determined, which helps prevent unexpected power outages, restarts, and other emergencies from interrupting the operation of the Flash memory, avoids affecting subsequent data storage, and improves data reliability.
[0110] Step 230 : Based on the status of the target data block, perform an update operation on the status flag of the target data block or operate on the data storage area of the target data block in response to an operation instruction.
[0111] In some embodiments, if there is no abnormality in the target data block, operations such as writing data, reading data, and erasing data can be performed on the data storage area of the target data block.
[0112] In some embodiments, if the target data block is abnormal, the status flag is updated to reflect the actual status of the data block, for example, the first status flag bit and the second status flag bit are updated.
[0113] In some embodiments, based on the state of the target data block, performing an update operation on the state flag of the target data block or responding to an operation instruction, operating on the data storage area of the target data block includes:
[0114] In the case that the state of the target data block is that there is no abnormality, responding to the operation instruction, performing a read and write operation on the data storage area of the target data block based on the target data last written in the data storage area;
[0115] When the state of the target data block is abnormal, an update operation of the state flag of the target data block is performed, including:
[0116] If the target data of the target data block is the last piece of data, an erase operation is performed on the next data block, and after the erase operation is completed, a first state flag is written into the flag storage area of the target data block;
[0117] If the target data of the target data block is the first piece of data, a second status flag is written into the flag storage area of the target data block.
[0118] In some embodiments, if the target data is the last piece of data in the target data block and there is no first state flag written in the target data block (for example, the first state flag is 1), the next adjacent data block is erased, and after the erase operation is completed, the first state flag is written in the target data block (for example, the first state flag is 0).
[0119] In some embodiments, if the target data is the first data in the target data block and there is no second status flag to be written in the target data block (for example, the second status flag is 1), the second status flag is written in the target data block (for example, the second status flag is 0).
[0120] In some embodiments of the present specification, by detecting and processing status flags, the consistency of the data storage status and the status flags can be ensured, thereby avoiding abnormalities in subsequent data storage; by promptly responding to abnormalities in the status flags, the impact of system failures on data storage can be reduced, thereby improving the overall stability of the system; by updating status flags and executing operation instructions, memory resources can be managed more efficiently, thereby improving the service life of the memory.
[0121] In some embodiments, the flag storage area further includes a third status flag bit, the third status flag bit indicating the storage progress of writing data to the data block, and the method further includes:
[0122] Based on the target data, determining a target storage schedule for the target data block;
[0123] When the target storage progress reaches different preset progress thresholds, the third state flag bit of the target data block flag storage area is updated.
[0124] The target storage progress refers to the percentage of data already written to a data block compared to the total amount of data to be written. The target storage progress can be used to measure the degree of completion of a write operation. The target storage progress can be a percentage (such as 20%, 50%, 100%, etc.) or the number of data items stored.
[0125] Different preset progress thresholds refer to multiple preset progress thresholds. When the target storage progress of the target data block reaches different preset progress thresholds, the third state flag (such as Figure 1 The flag 3) is shown to reflect the current writing status.
[0126] In some embodiments, the preset progress threshold can be set in a variety of ways. For example, multiple preset progress thresholds can be determined based on the maximum number of data items that can be stored in the data storage area and the number of bits of the third state flag.
[0127] For example, if the number of bits in the third state flag is N, and the data storage area can store a maximum of Y pieces of data, different preset progress thresholds can be set by equally dividing the total capacity of the data storage area, Y pieces of data, into N equal parts, with each part corresponding to a preset progress threshold. For example, if N = 3 (the third state flag has 3 bits) and Y = 100 pieces of data, the following preset progress thresholds can be set:
[0128] Preset progress threshold 1: When the target storage progress reaches 1 / 3*Y=33 pieces of data, the first bit of the third state flag is updated or written.
[0129] Preset progress threshold 2: When the target storage progress reaches 2 / 3*Y=66 pieces of data, the second bit of the third state flag is updated or written.
[0130] Preset progress threshold 3: When the target storage progress reaches Y=100 pieces of data, the third bit of the third state flag is updated or written.
[0131] For example, the number of bits of the third status flag is N, and the data storage area can store a maximum of Y pieces of data. Each preset progress threshold can be customized by customizing the progress threshold according to actual application requirements. For example:
[0132] Preset progress threshold 1: When the target storage progress reaches 20%*Y pieces of data, the first bit of the third status flag is updated.
[0133] Preset progress threshold 2: When the target storage progress reaches 50%*Y pieces of data, the second bit of the third status flag is updated.
[0134] Preset progress threshold 3: When the target storage progress reaches 80%*Y pieces of data, the third bit of the third status flag is updated.
[0135] In some embodiments of the present specification, by updating the third status flag in real time, the target storage progress of the data block can be quickly determined, which helps to quickly determine the index value of the target data block.
[0136] In some embodiments, the method further comprises:
[0137] Determining a target index interval of the target data block based on a third status flag of the target data block;
[0138] Based on the target index range, the target index value is obtained through a preset search method to determine the target data corresponding to the target index value.
[0139] The target index interval refers to an index range in the data block determined according to the third state flag.
[0140] The target index value is a specific index value determined by a preset search method within the target index range. The target index value can be used to locate a specific data record in a data block.
[0141] In some embodiments, the target index interval represents the search range of the target index value. For example, when the third state flag is 110, N=3 (the third state flag has 3 bits), Y=100 data items, and the target index interval is [33, 66], indicating that the maximum value of the target index value does not exceed 66.
[0142] In some embodiments of this specification, by determining the target index range and target index value through the third state flag, specific data in the data block can be quickly located, unnecessary data searches can be reduced, and the efficiency of data location can be improved.
[0143] In some embodiments, the index value in a single piece of data can be adjusted according to the maximum value required by the design, and the index value can occupy a single byte or multiple bytes, etc. In some embodiments, an index value of 0 represents that the data is erroneous data, and a default value (e.g., 0xFFFF) represents that the data in the storage address corresponding to this index value is empty.
[0144] In some embodiments, the index value can be saved to other storage media such as EEPROM, and when the storage space needs to be operated, the index value is directly read from the other storage medium, eliminating the index search operation and adding the operation of writing the index value to the other storage medium during the write operation.
[0145] In some embodiments, when the data storage area is increased to Y number of entries, the maximum value of the index value is Y; the check code algorithm can use CRC8, CRC16, CRC32, etc., which can be set according to actual needs; this specification prefers that the check code is double-byte, which is an addition check algorithm that accumulates and sums single bytes from the index value to the check code and then modulo 65536.
[0146] Figure 3 This is an exemplary schematic diagram of determining a target index value according to some embodiments of this specification.
[0147] In some embodiments, as Figure 3 As shown, the target index value of the target data to be operated can be determined from the data block according to the status flag of each data block.
[0148] In some embodiments, if the first status flag bit and the second status flag bit of each status flag are both 1, the index value is reset, such as setting the target index value to a default initial value (such as 1).
[0149] In some embodiments, if there is a data block with a first status flag of 1 and a second status flag of 0, it is determined that there is an unfilled first data block, and the data block is used as the target data block. The preset search method can be used to perform index search in the target data block to find the last data written in the target data block. The index value corresponding to the data is the target index value. For example, a sequential search algorithm, a binary search algorithm, etc. can be used. The present application prefers a binary search algorithm, and the maximum number of searches = log2N, where N is twice the maximum value of the corresponding target index interval. In order to reduce the complexity of the program, it is recommended that N be 2 3 ~2 9 That is, the maximum number of searches is 3 to 9 times.
[0150] In some embodiments, the target index value can be determined based on the second data block. For example, if the first data piece of the data block following the second data block has written data, the data block following the second data block is the target data block, and the target index value is the index value corresponding to the first data piece of the target data block; if the first data piece of the data block following the second data block does not have written data, the second data block is the target data block, and the target index value is the index value corresponding to the last data piece of the target data block.
[0151] Figure 4 is an exemplary schematic diagram of an update status mark according to some embodiments of this specification.
[0152] In some embodiments, as Figure 4 As shown, after determining the target index value, the memory may be checked for data, and the status flag of the target data block may be updated according to the result of the data check.
[0153] In some embodiments, it can be determined whether the target index value of the target data block points to the last data: if so, it is determined whether there is a written first status flag in the target data block; if there is no written first status flag, the next data block is erased, and after erasing the next data block, the first status flag is written in the target data block.
[0154] In some embodiments, it can be determined whether the target index value of the target data block points to the first data: if so, it is determined whether there is a written second status flag in the target data block; if there is no written second status flag, the second status flag is written in the target data block.
[0155] In some embodiments, when the target index value of the target data block does not point to the first data and the last data, it can be determined whether the conditions for writing the third status flag are met, for example, when the target storage progress reaches different preset progress thresholds, the third status flag of the flag storage area of the target data block is updated.
[0156] In some embodiments of the present specification, the status of a data block is determined by checking the status flag and the last data written to the target data block, so that potential problems such as power failure and restart can be discovered in a timely manner and the status flag can be updated in a timely manner, thereby improving processing efficiency, helping to increase the storage life of Flash data and enhance data reliability; only the target data blocks that require attention are operated without scanning the entire storage space; through multiple status flags, each type of log information in the memory can be customized with different quantity and information length requirements, and the same type of interface can be used for operation to achieve flexible management.
[0157] In some embodiments, in response to the operation instruction, operating the data storage area of the target data block includes:
[0158] Get write operation instructions;
[0159] A first index value is determined based on the target data, a write operation is performed on a storage address corresponding to the first index value based on the data to be written in the write operation instruction, and a status flag of the target data block is updated.
[0160] A write instruction is a command used to instruct the memory to perform a write operation. It can contain the following information. A write instruction can be issued by the system or the user.
[0161] In some embodiments, the write operation instruction may include the data to be written, the length of the data to be written, etc.
[0162] A first index value is a specific index value determined based on the target data in the target data block. The first index value is used to locate a specific storage location in the target data block. The first index value can be the first index value, the last index value, an intermediate index value, or another specific index value in the target data block.
[0163] The storage address corresponding to the first index value refers to the physical or logical address corresponding to the first index value in the target data block. The storage address corresponding to the first index value is the storage location of the actual write operation or the storage location where the data to be written is written.
[0164] Figure 5 This is an exemplary schematic diagram of executing a write operation instruction according to some embodiments of this specification.
[0165] For example, Figure 5 As shown, add 1 to the target index value to get the first index value (such as Figure 5The current index value of the first index value is determined, and whether the first index value is greater than the preset maximum threshold value: if so, the first index value is reset to 1 (or a new data block is dynamically allocated as the target data block, and the index value points to the storage start address of the new data block, which can be applied to scenarios that require persistent data storage, such as database management systems, etc.), and the check code is calculated based on the data to be written, and the data to be written and the check code are written to the storage address corresponding to the first index value; determine whether the target data block corresponding to the first index value is full: if so, after erasing the next adjacent data block, write the first status flag to the target data block corresponding to the first index value. Determine whether the first index value is the index value of the first data of the current data block: if so, write the second status flag to the target data block corresponding to the first index value; when the first index value does not point to the first data and the last data, determine whether the conditions for writing the third status flag are met, for example, the storage progress of the current data block reaches different preset progress thresholds, and update the third status flag of the data block corresponding to the first index value.
[0166] The target data block is a data block to which data needs to be written, and can be determined according to actual conditions.
[0167] In some embodiments of this specification, by determining the first index value and the storage address corresponding to the first index value, the target location can be quickly located, reducing unnecessary data scanning; by updating the status flag, the status of the data block can be ensured to be consistent with the actual write operation.
[0168] In some embodiments, in response to the operation instruction, operating the data storage area of the target data block includes:
[0169] Based on the second index value in the read operation instruction, read the storage data from the storage address corresponding to the second index value;
[0170] When the preset index value in the stored data is the same as the second index value, the data bits in the stored data are verified, and based on the verification result, the stored data corresponding to the next index value of the second index value is read.
[0171] A read operation instruction is a command used to instruct the memory to perform a read operation. The read operation instruction can be issued by the system or the user.
[0172] In some embodiments, the read operation instruction may include one or more second index values corresponding to the data to be read.
[0173] The second index value is an index value specified in a read operation instruction and is used to locate a specific storage location in a target data block. The second index value is used to identify a piece of data or a data segment in a data block.
[0174] The stored data refers to the data content read from the specified storage address of the target data block. The stored data can be a data record, a data segment, or other forms of data units.
[0175] A preset index value is a pre-set index value in stored data that identifies a specific location in a data block. Preset index values can be used for data verification and integrity checks. For example, a preset index value can be a specific index value.
[0176] The verification result is the result of verifying the data bits in the stored data. For example, verification methods such as checksum and CRC are used to obtain the verification result. The verification result can be: verification success or verification failure. A verification success indicates that the stored data is complete and consistent. A verification failure indicates that the stored data is incomplete or inconsistent.
[0177] In some embodiments, the method further comprises:
[0178] When the verification result is failure, the preset index value in the stored data is set as a preset mark value, and the preset mark value is used to indicate that the data bit of the stored data is erroneous data.
[0179] A preset marker value is a pre-set value used to mark a data bit in the stored data as erroneous. The preset marker value can be a fixed, predefined value. When a check fails, a preset index value in the stored data is set to the preset marker value to mark the data bit as erroneous.
[0180] Figure 6 This is an exemplary schematic diagram of executing a read operation instruction according to some embodiments of this specification.
[0181] For example, Figure 6 As shown, whether the requested data is reasonable can be determined based on the read operation instruction. For example, whether the requested data is reasonable can be determined based on the second index value in the requested data and the amount of requested data. If it is reasonable, the target storage address is calculated according to the second index value and the requested data, and the storage data at the target storage address is read out. If the preset index values in the storage data are all '1', that is, the default value, it is determined that the storage data is empty, and the storage data is ejected.
[0182] In some embodiments, if the preset index values in the stored data are not all '1', it is determined whether the preset index values in the stored data are normal, that is, whether they correspond to the target storage address: if so, data verification is performed; if the preset check code in the stored data and the calculated check code are equal, it means that the data is normal, and the storage number is popped up; if the preset check code in the stored data and the calculated check code are not equal, data exception processing is performed, for example, the preset index values of the stored data are all written 0 for marking processing, and it is determined whether all the requested data are read out: if not, the target storage address of the next data is determined.
[0183] In some embodiments, after the piece of data is popped out, it is determined whether all the requested data has been read out: if not, the target storage address of the next piece of data is determined.
[0184] In some embodiments of this specification, the reliability of data is ensured through index values and check codes; abnormal data processing helps to skip problem data in the future, thereby improving the user experience; and problem data and erroneous data are identified through index values, thereby improving the efficiency of subsequent re-reading.
[0185] In some embodiments, the memory is a Flash memory, and the memory is used to store high-frequency log information with a small amount of data.
[0186] For example, the memory can be used to store high-frequency log information whose data volume is less than a preset data volume threshold. The preset data volume threshold is a set upper limit for the amount of log information stored at any one time. The preset data volume threshold can be adjusted based on the capacity and performance of the memory to ensure that the memory is not overloaded by a large amount of data written in a single time.
[0187] High-frequency log information refers to log information that is frequently generated during system operation.
[0188] For example, for a small amount of high-frequency log information in an embedded system, it is necessary to record the time of sunrise for 1000 days (hours, minutes, seconds). Among them, in the memory, 2 bytes are used for index value, 2 bytes are used to store the check code, a single piece of data is 3 bytes, and the total size of a piece of stored data is 7 bytes; the first state flag, the second state flag, and the third state flag occupy 2 bytes together, and the flag storage area size is 2 bytes in total. A minimum erase sector is 4096 bytes. The storage starting address is 0. For the existing 88 pieces of data, in the first data block, the 87th and 88th pieces of data are shown in Table 1 below:
[0189] Table 1
[0190]
[0191] In some embodiments, the number of data entries is increased to 1170, and two minimum erase sectors constitute one data block. At least two data blocks are required to review the log. The flag storage area for the current data block is shown in Table 2. Based on the size occupied by the third status flag, the third status flag is written every 1 / 15 (i.e., 78 entries). That is, bit 0 is set to 0 after the 78th entry is written, and bit 1 is set to 0 after the 156th entry is written. The corresponding relationship between the Nth entry index value and the storage address is: (index value – 1) * 7 + the storage start address of the current data block = the storage address of the Nth entry.
[0192] Table 2
[0193]
[0194] In some embodiments, the specific operations of obtaining and checking the index value include:
[0195] S01, querying the first data block for the presence of the second status flag; if the first status flag does not exist, performing an index query on the first data block;
[0196] S02. Combining the data in the third state flag, it can be seen that the target index value is between 1 / 15 and 3 / 15, that is, between 78 and 234. The target index value is obtained by a preset search method, including:
[0197] The index value of the 156th data is 0xFFFF, so it is judged to be between 78 and 156;
[0198] The index value of the 117th data is 0xFFFF, so it is judged to be between 78 and 117;
[0199] The index value of the 97th data is 0xFFFF, so it is judged to be between 78 and 97;
[0200] The index value of the 87th data is 87, so it is judged to be between 87 and 97;
[0201] The index value of the 92nd data is 0xFFFF, so it is judged to be between 87 and 92;
[0202] The index value of the 89th data is 0xFFFF, so it is judged to be between 87 and 89;
[0203] The index value of the 88th data is 88, and the last data is the 88th data, that is, the index value is 88.
[0204] It should be noted that when the 156th data item is written, the second bit of the third status flag, i.e., bit 1, should be written to 0. However, due to power outages or other abnormalities, the second bit 1 may not be successfully written (i.e., bit 1 remains 1). To avoid misjudging or missing the status of the 156th data item, it is necessary to increase the detection of the index value of the 156th data item. Considering that the preset progress threshold corresponding to the 156th data item is 1170*2 / 15, which is between 1 / 15 and 3 / 15, when using the binary search method, the target index value range is set to the index value range between 1170*1 / 15 and 1170*3 / 15. It is possible to first determine whether the index value of the 156th data item is the default value or zero. If the index value of the 156th data item is 0xFFFF, it means that the storage address corresponding to the index value has not been written to data. The target index range is between 78 and 156, thereby effectively avoiding misjudgments or missed detections.
[0205] It is understandable that when determining the target index interval based on the data in the third state flag, it is necessary to ensure that the interval range can cover all possible situations while avoiding missed judgments due to abnormal situations. For example, when using the binary search method, the number of bits of the third state flag is N, the data storage area can store a maximum of Y data, the first X bits of the third state flag have been written into the third state flag, and the target index interval can be [X*Y / N~2X*Y / N]. At this time, it is necessary to first determine the index value of the last data in the target index interval. If the index value is valid, the target index value is 2X*Y / N; if the index value is the default value, the target index value can be determined by the binary search method between [X*Y / N, 2X*Y / N]. Alternatively, the target index interval can also be [X*Y / N~3X*Y / N], in which case the binary search method can be directly used to determine the target index value.
[0206] It should be noted that the third status flag is written every 1 / 15 (i.e., 78 entries), that is, bit 0 is set to 0 after the 78th entry is written, bit 1 is set to 0 after the 156th entry is written, and so on. Therefore, the 14-bit status flag needs to be divided into 15 intervals to indicate the status of the corresponding storage interval. At this time, an additional data bit (such as bit 15, etc.) can be used to indicate the overflow of the third status flag. Specifically, when bit 15 is 1, it indicates that the previous 14-bit status flag has not overflowed; when bit 15 is 0, it indicates that the previous 14-bit status flag has overflowed and the 1170th entry has been written.
[0207] In some embodiments, the specific operation of the read operation is as follows: (for example, it is necessary to query the latest sunrise time information),
[0208] S11. The second index value is 88. One piece of data is requested. The request is reasonable. The 88th piece of data is read.
[0209] S12. Check and find that the preset index value of data item 88 is normal;
[0210] S13. Check the 88th data and calculate the check code 0+88+7+59+256=410. 410 is not equal to the preset check code 0xFFFF, indicating that the 88th data is unreliable.
[0211] S14. Setting the preset index value of the 88th data item to 0 makes reading more efficient and eliminates the need to calculate a check code, thereby determining that the data item is unreliable.
[0212] S15, calculating the target storage address of the 87th data and reading the data;
[0213] S16. Check and find that the preset index value of data item 87 is normal;
[0214] S17. Check the 87th data and calculate the check code 0+87+7+59+59=212. 212 is equal to the preset check code 212 (0x00D4). That is, the 87th data is reliable, and the data is popped up.
[0215] In some embodiments, the write operation is specifically performed as follows: (for example, the sunrise time of a new day is 8:01:50),
[0216] S21: The target index value is 88. A new piece of data is saved, so the index value is increased by 1 to obtain the first index value 89. The changed first index value is within the range.
[0217] S22, calculate and obtain the check code 0+89+8+1+50=148;
[0218] S23. Write the data into the storage address corresponding to the 89th item. Since the 89th item is not the first or last item of the current data block or the 89th item is not an integer multiple of 78, there is no need to update the third status flag.
[0219] In some embodiments, for a large number of low-frequency applications. In embedded systems, the system needs to be upgraded online, and the Flash memory needs to save the code data to be upgraded. The minimum capacity of the MCU is mostly tens of kB. The large amount of data is split into multiple data (such as a data of 100B, 200B, etc.) for storage. At this time, one data block represents a complete data information. When used, the data of one complete data block is assembled. When the software version needs to be backtracked, more than or equal to 3 data blocks are required. For its reading and writing operations, please refer to the relevant description above.
[0220] It should be noted that the above description of the relevant processes is for illustration and purpose only and does not limit the scope of application of this specification. For those skilled in the art, various modifications and changes can be made to the processes under the guidance of this specification. However, such modifications and changes are still within the scope of this specification.
[0221] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0222] Figure 7 This is a structural diagram of an electronic device according to some embodiments of this specification.
[0223] The embodiment of the present application further provides an electronic device 700, which may include one or more processors 701 of processing cores, one or more computer-readable storage media memories 702, a power supply 703, an input unit 704, and other components. Those skilled in the art will appreciate that Figure 7 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange components differently.
[0224] Processor 701 is the storage management center, connecting the various parts of the entire electronic device using various interfaces and lines. By running or executing software programs and / or modules stored in memory 702 and calling data stored in memory 702, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. It is understood that processor 701 transmits signals with the controller. Optionally, processor 701 may include one or more processing cores; preferably, processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly handles wireless communications. It is understood that the above-mentioned modem processor may not be integrated into processor 701.
[0225] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 702 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 volatile solid-state storage device. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.
[0226] In some embodiments of the present application, the storage management device can be implemented in the form of a computer program. The computer program can be used in Figure 7 The memory of the electronic device may store various program modules constituting the storage management device. The computer program composed of the various program modules enables the processor to execute the steps of the storage management method of each embodiment of the present application described in this specification.
[0227] The electronic device includes a processor, memory, and a network interface connected via a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the electronic device is configured to communicate with external electronic devices via a network connection. When executed by the processor, the computer program implements a storage management method.
[0228] The electronic device also includes a power supply 703 for supplying power to various components. Preferably, the power supply 703 can be logically connected to the processor 701 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 703 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0229] The electronic device may further include an input unit 704, which may be configured to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0230] Specifically in this embodiment, the processor 701 in the electronic device will load the executable files corresponding to the processes of one or more applications into the memory 702 according to computer instructions, and the processor 701 will run the applications stored in the memory 702 to achieve various functions, such as the storage management methods of various embodiments of the present application described in this specification.
[0231] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0232] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to implement as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments and will not be repeated here.
[0233] It should be noted that Figure 7 This is only one implementation of the electronic device 700 provided in the embodiment of the present application. In actual applications, the electronic device 700 may also include more or fewer components, which is not limited here.
[0234] It should be understood that the various schemes of the embodiments of the present application can be reasonably combined and used, and the explanations or descriptions of the various terms appearing in the embodiments can be referenced or explained with each other in the various embodiments, without limitation to this.
[0235] Based on the above embodiments and the same concept, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a computer, the computer executes the method provided in the above embodiments.
[0236] Based on the above embodiments and the same concept, an embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program runs on a computer, it enables the computer to execute the method provided in the above embodiments.
[0237] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more features. In the description of this application, "plurality" means two or more, unless otherwise specifically defined.
[0238] The embodiments, implementation methods and related technical features of the present application can be combined and replaced with each other without conflict.
[0239] The above are only preferred embodiments of the present application and do not constitute any form of limitation to the present application. Although the descriptions of each embodiment in the embodiments of the present application have different focuses, for parts that are not described in detail in a certain embodiment, please refer to the relevant embodiments of other embodiments. However, any simple modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present application without departing from the content of the technical solution of the present application are still within the scope of the technical solution of the present application.
Claims
1. A storage management method, characterized in that: A method for storing a plurality of log information in a memory is provided, wherein the storage space of the memory is used to store a plurality of log information, wherein each log information corresponds to a plurality of data blocks, each data block includes a data storage area for storing at least one piece of data and a flag storage area for storing a status flag; the status flag of each data block is used to indicate the data writing status of the data block and the erasure status of the next data block of the data block, and the method includes: In response to an operation instruction for the memory, determining a target data block to be operated from the data blocks according to a status flag of each data block; determining a state of the target data block based on the target data last written into the data storage area of the target data block; Based on the status of the target data block, an update operation is performed on the status flag of the target data block or an operation is performed on the data storage area of the target data block in response to the operation instruction.
2. The method according to claim 1, characterized in that The status flag includes a first status flag bit indicating an erase status of a data block next to the data block and a second status flag bit for indicating a data write status of the data block; The step of determining a target data block to be operated from the data blocks according to the status flag of each data block includes: Using the first data block where the first status flag is not a preset flag and the second status flag is a preset flag as the target data block; and / or In the absence of the first data block, a target data block is determined based on the second data block; wherein the second data block refers to a data block in which the first status flag and the second status flag are both preset flags, and the first status flag and the second status flag of the next data block of the second data block are not preset flags.
3. The method according to claim 1, characterized in that The determining the state of the target data block based on the target data last written in the data storage area of the target data block includes: If the target data is not the first data piece or the last data piece, determining that there is no abnormality in the status flag of the target data block; If the target data is the first piece of data or the last piece of data, the status of the target data block is determined based on a status flag.
4. The method according to claim 1, wherein The updating operation on the status flag of the target data block based on the status of the target data block or the operation on the data storage area of the target data block in response to the operation instruction includes: In a case where the state of the target data block is not abnormal, responding to the operation instruction, performing a read and write operation on the data storage area of the target data block based on the target data last written in the data storage area; When the state of the target data block is abnormal, performing an update operation on the state flag of the target data block includes: If the target data of the target data block is the last piece of data, performing an erasing operation on the next data block, and after the erasing operation is completed, writing a first status flag bit into the flag storage area of the target data block; If the target data of the target data block is the first piece of data, a second status flag is written into the flag storage area of the target data block.
5. The method according to claim 1, characterized in that The flag storage area further includes a third status flag, and the third status flag indicates the storage progress of writing data to the data block. The method further includes: determining a target storage schedule for the target data block based on the target data; When the target storage progress reaches different preset progress thresholds, the third status flag bit of the target data block flag storage area is updated.
6. The method according to claim 5, characterized in that The method further comprises: Determining a target index interval of the target data block based on a third status flag of the target data block; Based on the target index range, a target index value is obtained by a preset search method to determine the target data corresponding to the target index value.
7. The method according to claim 1, characterized in that In response to the operation instruction, operating the data storage area of the target data block includes: Get write operation instructions; A first index value is determined based on the target data, a write operation is performed on a storage address corresponding to the first index value based on the data to be written in the write operation instruction, and a status flag of the target data block is updated.
8. The method according to claim 1, characterized in that In response to the operation instruction, operating the data storage area of the target data block includes: Based on the second index value in the read operation instruction, read the storage data from the storage address corresponding to the second index value; When the preset index value in the stored data is the same as the second index value, the data bits in the stored data are verified, and based on the verification result, the stored data corresponding to the next index value of the second index value is read.
9. The method according to claim 8, characterized in that The method further comprises: When the verification result is failure, a preset index value in the stored data is set as a preset mark value, and the preset mark value is used to indicate that a data bit of the stored data is erroneous data.
10. The method according to any one of claims 1 to 9, characterized in that The memory is a Flash memory, and the memory is used to store high-frequency log information with a small amount of data.
11. A memory, characterized in that: The storage space of the memory is used to store multiple log information. One type of log information corresponds to multiple data blocks. Each data block includes a data storage area for storing at least one piece of data and a flag storage area for storing a status flag.
12. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 10.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Data storage method and device and intelligent terminal
CN107256197A
Flash memory storage control method, device and equipment and readable storage medium
CN117724652A
Data storage method and system, vehicle and electronic equipment
CN119148934A
Data storage system and method using FLASH to simulate EEPROM
CN119759286A
Method for managing data in flash storage medium
CN1518000A
Cited By
Data storage method and device, equipment, medium and product
CN121050665A
Method, device and equipment for erasing power record of Nor flash chip and storage medium
CN121832855A