Data storage method and device and electronic equipment

By employing a logical sector management scheme with multiple instance groups in the Flash-simulated EEPROM, the problems of decreased storage space utilization and shortened device lifespan caused by high-frequency data modification are solved, achieving more efficient data storage and a longer device lifespan.

CN120950001APending Publication Date: 2025-11-14BEIJING JINGWEI HIRAIN TECH CO INC
View PDF 5 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing Flash-based EEPROM emulation technologies lead to decreased storage space utilization and shortened device lifespan when data is frequently modified, mainly due to frequent data copying and increased frequency of storage space state switching.

Method used

The logical sector management scheme, which uses multiple instance groups, determines the target logical sector and copies the valid data to the erased logical sector when the written data length exceeds the remaining space of the currently active logical sector. It also sets the erased logical sector to an active state, thereby reducing the data copying ratio and improving storage space utilization and device lifespan.

Benefits of technology

This effectively reduces the data copying ratio during storage space switching, improves the utilization and lifespan of Flash storage space, and reduces the error rate during data copying, thereby improving the real-time performance and stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120950001A_ABST
    Figure CN120950001A_ABST
Patent Text Reader

Abstract

The invention discloses a data storage method and device and electronic equipment, a Flash simulation EEPROM (Electrically Erasable Programmable Read-Only Memory) area is provided with at least one instance group, each instance group is provided with at least three logic sectors, and when the length of write-in data is greater than the residual space of the currently activated logic sector, the write-in data is written into the current activated logic sector. When a target logic sector is determined based on the number of the currently activated logic sector and the target logic sector is in an effective state, copying effective data of the target logic sector to the erased logic sector, setting the erased logic sector as the latest activated logic sector, setting the currently activated logic sector as the effective state, and setting the erased logic sector as the latest activated logic sector; and executing a data writing operation by taking the latest block log address and the latest block data address in the latest activated logic sector as a writing block data address. According to the method, the valid data are distributed in the logic sectors of the instance group, all the valid data in the instance group do not need to be copied to the latest activated logic sector when the activated logic sector is switched, and the data copying proportion in the storage space switching process is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of automotive electronics technology, and more specifically, to a data storage method, apparatus, and electronic device. Background Technology

[0002] In the field of automotive electronics, large amounts of data typically need to be stored even when power is off, and this stored data often needs to be modified frequently. Because EEPROM (Electrically Erasable Programmable Read-Only Memory) has a limited number of write cycles and is expensive, this high-frequency modification requirement significantly increases data storage costs. Therefore, the automotive electronics industry currently typically uses Flash memory to simulate EEPROM for data storage.

[0003] Existing Flash-based EEPROM emulation technologies are as follows: Solution 1: Two identical storage spaces are partitioned on the Flash memory. Data is alternately written to the data area of ​​the active storage space by managing the activation state of the two spaces. Solution 2: Building upon Solution 1, one storage space is divided into a Header + Data area, where Header + Data represents a storage unit, storing the block's identifier and data information respectively. In both Solutions 1 and 2, data is written in blocks, and all blocks belong to the same storage space. If the write frequency of all blocks is at the same level, good system performance can be guaranteed. However, when the write frequency of some blocks is significantly higher than that of others, it exacerbates the frequency of storage space activation state switching. Since a large amount of data needs to be copied frequently during state switching, this leads to a decrease in Flash storage space utilization, accelerates device wear and tear, and shortens the Flash's lifespan. Summary of the Invention

[0004] In view of this, the present invention discloses a data storage method, apparatus and electronic device, which can reduce the amount of data that needs to be copied during storage space switching, improve the utilization rate of Flash storage space and the lifespan of Flash.

[0005] A data storage method, wherein a Flash simulated EEPROM area is provided with at least one instance group, each instance group is provided with at least three logical sectors, each logical sector as a storage space contains a valid status flag bit, and when the valid status flag bit is set, it indicates that the corresponding logical sector is in a valid state and stores valid data;

[0006] The data storage method includes:

[0007] When the length of the written data is greater than the remaining space of the currently active logical sector, the target logical sector for which effective data exchange needs to be performed is determined based on the number of the currently active logical sector. The target logical sector is separated from the currently active logical sector by an erased logical sector, and the currently active logical sector is the logical sector that is currently in an active state.

[0008] If the target logical sector is in a valid state, copy the valid data of the target logical sector to the erased logical sector;

[0009] Set the currently active logical sector to an active state, and set the erased logical sector to an active state as the latest active logical sector;

[0010] The latest block log address and the latest block data address in the latest activated logical sector are used as the write block data address to perform a data write operation.

[0011] Optionally, before performing the data write operation by using the latest block log address and the latest block data address in the latest activated logical sector as the write block data address, the method further includes:

[0012] An erase operation is performed on the target logical sector, and the target logical sector after the erase operation is completed is set as an erased logical sector.

[0013] Optionally, the step of using the latest block log address and the latest block data address in the latest activated logical sector as the write block data address to perform the data write operation includes:

[0014] Write block log information at the latest block log address;

[0015] Write block data information at the latest block data address;

[0016] Mark the target block corresponding to the latest block log address and the latest block data address as valid;

[0017] Update the latest block log address and the latest block data address.

[0018] Optionally, it also includes:

[0019] When the length of the written data is not greater than the remaining space of the currently active logical sector, the latest block log address and the latest block data address in the currently active logical sector are used as the write block data address to perform the data write operation.

[0020] Optionally, after all the logical sectors of all the instance groups in the Flash simulated EEPROM area have been configured, the method further includes:

[0021] The parsing operation is performed sequentially on all the logical sectors, and the latest block log address and latest block data address of the active logical sectors are recorded during the parsing process, until all the logical sectors have been parsed.

[0022] Optionally, the process of sequentially performing the parsing operation on all the logical sectors includes:

[0023] Within the Flash simulated EEPROM area, the system jumps to the state of reading logical sector log information and reads the logical sector log information.

[0024] Within the Flash simulated EEPROM area, the process jumps to the state of parsing logical sector log information and parses the read logical sector log information to obtain logical sector status information.

[0025] When it is determined that the corresponding current logical sector is in a valid or active state based on the logical sector status information, the system jumps to the state of reading block log information in the Flash simulated EEPROM area and reads block log information from the current logical sector.

[0026] Within the Flash simulated EEPROM area, the process jumps to the state of parsing block log information and parses the block log information read from the current logical sector to obtain block status information.

[0027] When it is determined that the corresponding current block is in a valid state based on the block status information, the block status information is recorded in the block log information storage area;

[0028] After all block data in the current logical sector has been parsed, switch to the next logical sector of the current logical sector, and return to the state of reading logical sector log information in the Flash simulated EEPROM area. Read the logical sector log information, and perform the parsing operation again until all logical sectors have been parsed.

[0029] Optionally, it also includes:

[0030] When it is determined that the corresponding current logical sector is invalid based on the logical sector status information, switch to the next logical sector of the current logical sector, and return to the state of jumping to read logical sector log information in the Flash simulated EEPROM area, and read the logical sector log information and perform the parsing operation again.

[0031] Optionally, each logical sector includes a logical sector log information area and a logical sector data area;

[0032] The logical sector log information area is used to store logical sector log information parameters;

[0033] The logical sector data area is used to store block information;

[0034] In this context, a block serves as the smallest unit for writing operations to the Flash simulated EEPROM region. Each block contains a block log information and a block data information. The block log information increments from low address to high address, while the block data information decreases from high address to low address.

[0035] A data storage device, wherein a Flash emulated EEPROM area is provided with at least one instance group, each instance group is provided with at least three logical sectors, each logical sector as a storage space contains a valid status flag bit, and when the valid status flag bit is set, it indicates that the corresponding logical sector is in a valid state and stores valid data;

[0036] The data storage device includes:

[0037] The target logical sector determination unit is used to determine the target logical sector that needs to perform effective data exchange based on the number of the currently active logical sector when the length of the written data is greater than the remaining space of the currently active logical sector. The target logical sector is separated from the currently active logical sector by an erased logical sector, and the currently active logical sector is the logical sector that is currently in an active state.

[0038] The copying unit is used to copy valid data from the target logical sector to the erased logical sector when the target logical sector is in a valid state.

[0039] The setting unit is used to set the currently active logical sector to an active state and set the erased logical sector to an active state as the latest active logical sector.

[0040] The write operation unit is used to perform a data write operation by using the latest block log address and the latest block data address in the latest activated logical sector as the write block data address.

[0041] An electronic device, comprising: a memory and a processor;

[0042] The memory is used to store at least one instruction;

[0043] The processor is used to execute the at least one instruction to implement the data storage method described above.

[0044] As can be seen from the above technical solution, the present invention discloses a data storage method, apparatus, and electronic device. The Flash simulated EEPROM area is configured with at least one instance group, each instance group is configured with at least three logical sectors, each logical sector is a storage space, and contains valid data when it is in a valid state. When the length of the written data is greater than the remaining space of the currently active logical sector, the target logical sector for which valid data exchange needs to be performed is determined based on the number of the currently active logical sector. When the target logical sector is in a valid state, the valid data of the target logical sector is copied to the erased logical sector, and the erased logical sector is set to the active state as the latest active logical sector. The latest block log address and the latest block data address in the latest active logical sector are used as the write block data address to perform the data writing operation. This application distributes valid data across various logical sectors within an instance group. When the length of the written data exceeds the remaining space of the currently active logical sector, it is not necessary to copy all valid data in the instance group to the newly active logical sector when switching active logical sectors. Instead, only the valid data in the target logical sector where valid data exchange needs to be performed is copied to the newly active logical sector. This significantly reduces the data copying ratio during storage space switching, improves the utilization rate of Flash storage space, and extends the lifespan of Flash. Attached Figure Description

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

[0046] Figure 1 This is a schematic diagram illustrating the mapping relationship of a Flash-simulated EEPROM data storage structure disclosed in an embodiment of the present invention;

[0047] Figure 2 This is a schematic diagram of a logical sector data storage structure disclosed in an embodiment of the present invention;

[0048] Figure 3 This is a schematic diagram of the composition format of logical sector log information disclosed in an embodiment of the present invention;

[0049] Figure 4 This is a schematic diagram of a block log information composition format disclosed in an embodiment of the present invention;

[0050] Figure 5 This is a flowchart of a data storage method disclosed in an embodiment of the present invention;

[0051] Figure 6 This is a schematic diagram illustrating the distribution of logical sector states in an instance group according to an embodiment of the present invention;

[0052] Figure 7 This is a schematic diagram of a sector switching operation process in an example grouping disclosed in an embodiment of the present invention;

[0053] Figure 8 This is a schematic diagram of a data writing process disclosed in an embodiment of the present invention;

[0054] Figure 9 This is a state diagram of a data parsing process disclosed in an embodiment of the present invention;

[0055] Figure 10 This is a flowchart for determining whether the index of a logical sector has reached its maximum value, as disclosed in an embodiment of the present invention.

[0056] Figure 11 This is a schematic diagram of the structure of a data storage device disclosed in an embodiment of the present invention;

[0057] Figure 12 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. Detailed Implementation

[0058] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0059] To address the shortcomings of existing solutions, this application provides a novel data storage method that uses a Flash-simulated EEPROM data storage structure and sector switching algorithm. By managing the active and valid states of N (N>=3) storage spaces, data is written sequentially into the active storage space.

[0060] The Flash-simulated EEPROM area is configured with at least one instance group, and each instance group has at least three logical sectors. Each logical sector, as a storage space, contains a valid status flag. When the valid status flag is set, it indicates that the corresponding logical sector is in a valid state and stores valid data. That is, in this application, when a logical sector is marked as valid, it indicates that the corresponding logical sector contains valid data, and the logical sector in a valid state is considered non-erasable space. When a logical sector is marked as invalid, it indicates that the corresponding logical sector does not contain valid data, and the logical sector in an invalid state is considered erasable space.

[0061] It should also be noted that each logical sector in this application includes an activation status flag, and the latest data will be written to the active logical sector. When the length of the written data is less than the remaining space of the active logical sector, the data is written to the active storage space; when the length of the written data is greater than the remaining space of the active storage space, the activation status of the current logical sector is turned off, and the next logical sector is activated, and the data is written to the newly activated logical sector.

[0062] For details, see Figure 1 This invention discloses a schematic diagram of the data storage structure mapping of a Flash-simulated EEPROM. Figure 1 The left half of the image represents the Flash emulation EEPROM storage structure, abbreviated as FEE, while the right half represents the Flash memory structure.

[0063] Figure 1 The FEE in the model consists of n distinct instance groups, each instance group comprising N logical sectors (LcSec). Each logical sector is mapped to m consecutive physical sectors (PySec). For example, logical sector LcSec0 is mapped to PySec0, PySec1, ..., PySecm-1, and logical sector LcSecN-1 is mapped to PySec(N-1)m, PySec(N-1)m+1, ..., PySec(N-1)m+N-1.

[0064] In practical applications, FEE should be configured with at least one instance group, and each instance group should be configured with at least two logical sectors to implement sector switching operations.

[0065] The logical sector LcSec data storage structure distribution in this application is as follows: Figure 2As shown, each enabled LcSec contains a logical sector log information area (denoted as LcSec Log information area) and a logical sector data area (denoted as LcSecData area).

[0066] The LcSec Log information area is used to store logical sector log information parameters.

[0067] The LcSec Data area is used to store block information.

[0068] A block is the smallest unit of a FEE write operation.

[0069] A block contains block log information (denoted as Block Log information) and block data information (denoted as Block Data information). The Block Log information starts from the low address (e.g., ...). Figure 4 The address increments from 0x0000 to the latest block log address (denoted as the latest Block Log address). Block Data information is generated from higher addresses (e.g., 0x0000). Figure 4 The address is incremented from 0x1000 to the latest block data address (denoted as the latest block data address).

[0070] In summary, the Flash-simulated EEPROM scheme disclosed in this application uses multiple instance groups to divide blocks with different refresh rates. That is, blocks with similar refresh rates are assigned to the same instance group space. Compared with existing technical solutions, this application can effectively utilize the sector space of the Flash memory, improve the high-frequency sector switching operation caused by blocks with different refresh rates existing in the same instance group at the same time, reduce the sector erasure frequency to a certain extent, and improve the lifespan of the Flash.

[0071] The logical sector log information area in this application is formatted as follows: Figure 3 As shown, the logical sector log information area specifically contains the following information:

[0072] LcSec ID: Current logical sector number, 2 bytes in length.

[0073] LcSec Start address: The starting address of the current logical sector, with a length of 4 bytes.

[0074] LcSec size: Current logical sector size, 4 bytes in length.

[0075] Checksum: Checksum of the current logical sector, 4 bytes in length;

[0076] FEE_VALIDATED_VALUE: The current logical sector valid status flag, with a length of 8 bytes.

[0077] FEE_ACTIVE_VALIDATED_VALUE: Current logical sector activation status flag, 8 bytes in length.

[0078] FEE_INVALIDATED_VALUE: The current logical sector invalid status flag, with a length of 8 bytes.

[0079] FEE_ACTIVE_INVALIDATED_VALUE: The current logical sector is inactive, with a length of 8 bytes.

[0080] When the current logical sector valid status flag is set to 0x0D and the current logical sector active status flag is set to 0x0E, while the current logical sector invalid status flag and the current logical sector inactive status flag are empty, the logical sector LcSec is in an active state (i.e., Active state).

[0081] 0x0D indicates that the logical sector is set to a valid state, and 0x0E indicates that the logical sector is set to an active state.

[0082] When the current logical sector valid status flag is set to 0x0D, the current logical sector active status flag is set to 0x0E, and the current logical sector inactive status flag is set to 0xE0, while the current logical sector invalid status flag is empty, the logical sector LcSec is in a valid state (i.e., Valid state).

[0083] 0xE0 indicates that the logical sector is set to an inactive state.

[0084] Apart from the two cases mentioned above, in all other cases, the logical sector LcSec is in an invalid state (i.e., Invalid state).

[0085] The block log information (denoted as Block Log information) in this application is formatted as follows: Figure 4 As shown, the block log information specifically includes the following information:

[0086] Block Number: The index number of the current block, with a length of 2 bytes.

[0087] Block size: The size of the current block, with a length of 2 bytes.

[0088] Block Start address: The starting address of the current block, with a length of 4 bytes.

[0089] Immediate status: The priority (immediate) status of the current block, with a length of 1 byte.

[0090] Block Assignment project: Current block assignment attribute, length 1 byte.

[0091] History block sequence: Historical version information of the current block, 1 byte in length.

[0092] Checksum: The checksum of the current block, with a length of 4 bytes.

[0093] FEE_VALIDATED_VALUE: The valid status flag for the current block, 8 bytes in length.

[0094] FEE_INVALIDATED_VALUE: Invalid status flag for the current block, 8 bytes in length.

[0095] The current block is in a valid state (i.e., Valid state) when the valid state is marked as 0x0D and the invalid state is marked as empty; otherwise, the current block is in an invalid state (i.e., Invalid state).

[0096] Based on the above Figures 1-4 For the content shown, please refer to [link / reference]. Figure 5 The present application discloses a data storage method flowchart, which may include:

[0097] Step S101: When the length of the written data is greater than the remaining space of the currently active logical sector, determine the target logical sector that needs to perform effective data exchange based on the number of the currently active logical sector.

[0098] The currently active logical sector refers to the logical sector that is currently active.

[0099] Before storing data, this application first compares the length of the data to be written with the remaining space of the currently active logical sector. When the length of the data to be written is greater than the remaining space of the currently active logical sector, it indicates that the remaining space of the currently active logical sector cannot completely store the data to be written. At this time, a sector swapping operation is required to activate a new logical sector to store the data to be written.

[0100] In this application, the next logical sector after the currently active logical sector is the erased logical sector, and the next sector after the erased logical sector is the target logical sector for which valid data exchange needs to be performed.

[0101] That is, there is an erased logical sector between the target logical sector and the currently active logical sector.

[0102] In this application, each logical sector has a unique corresponding number. Therefore, based on the number of the currently active logical sector, the position of the currently active logical sector can be determined. The next logical sector after the currently active logical sector is the erased logical sector, and the next sector after the erased logical sector is the target logical sector for which valid data exchange needs to be performed.

[0103] Step S102: If the target logical sector is in a valid state, copy the valid data of the target logical sector to the erased logical sector.

[0104] When the target logical sector is invalid, the operation in step S102 is not executed, and step S103 is executed directly.

[0105] Step S103: Set the currently active logical sector to the valid state, and set the erased logical sector to the active state and use it as the latest active logical sector.

[0106] The sector swapping operation is achieved by setting the erased logical sector to the active state and making it the latest active logical sector.

[0107] Step S104: Use the latest block log address and the latest block data address in the latest activated logical sector as the write block data address and perform the data write operation.

[0108] For ease of understanding, an example of the sector switching operation in this application is provided; see [link to relevant documentation]. Figure 6 and Figure 7 As shown. Sector swapping is the core of the Flash-simulated EEPROM area (FEE). Traditional Flash memory requires erasing the original data when changing data at the same address, and the erasure unit is the entire sector, which greatly reduces the lifespan of the Flash memory. To avoid repeated sector erasure and writing, FEE uses logical sectors instead of physical sectors. When a second write operation is needed at the same address, it is logically defined as the same address, but physically it is the next valid address. When the length of the data to be written is greater than the remaining available space of the currently active logical sector, a sector swapping operation is triggered, and the data is written to the newly active logical sector.

[0109] See Figure 6 As shown, two scenarios will occur after the sector swapping operation is initiated. Scenario 1 shows that LcSec1 is in a valid state. During the sector swapping operation, the valid block data in LcSec1 needs to be copied to the erased LcSec0, and then the active state is switched. Scenario 2 shows that LcSec1 is in an invalid state. During the sector swapping operation, the active state is switched directly.

[0110] Taking scenario 1 as an example, Figure 7 It contains 8 logical sectors, of which logical sector 7 is active, logical sector 0 is erased, logical sectors 1, 3, and 5 are valid, and logical sectors 2, 4, and 6 are invalid. When the length of the data to be written exceeds the remaining available space of the active logical sector, a sector swapping operation is initiated, specifically including:

[0111] ① Update the log information for logical sector 0.

[0112] ② Copy the latest valid block data in logical sector 1 to the erased logical sector 0, and set the valid data in logical sector 1 to an invalid state. At the same time, record the log address and data address after the block change.

[0113] ③Activate logical sector 0 and set logical sector 0 to the active state, and set logical sector 7 to the active state.

[0114] ④ Erase logical sector 1 and set it to the erased state. The erased state refers to the state after the erase operation on logical sector 1 is completed.

[0115] ⑤ Record the data to be written before initiating the sector swapping operation into the currently active sector.

[0116] In summary, this invention discloses a data storage method. The Flash-simulated EEPROM area is configured with at least one instance group, each instance group having at least three logical sectors. Each logical sector serves as a storage space and contains valid data when in an active state. When the length of the written data exceeds the remaining space of the currently active logical sector, the target logical sector for which valid data exchange needs to be performed is determined based on the number of the currently active logical sector. While the target logical sector is in an active state, the valid data of the target logical sector is copied to an erased logical sector, and the erased logical sector is set to an active state as the latest active logical sector. The latest block log address and the latest block data address in the latest active logical sector are used as the write block data address to perform the data write operation. This application distributes valid data across various logical sectors within an instance group. When the length of the written data exceeds the remaining space of the currently active logical sector, it is not necessary to copy all valid data in the instance group to the newly active logical sector when switching active logical sectors. Instead, only the valid data in the target logical sector where valid data exchange needs to be performed is copied to the newly active logical sector. This significantly reduces the data copying ratio during storage space switching, improves the utilization rate of Flash storage space, and extends the lifespan of Flash.

[0117] In addition, since this application reduces the data replication ratio during storage space switching, it effectively reduces the occurrence of errors during data replication, thereby improving the real-time performance and stability of the entire system to a certain extent.

[0118] In one embodiment, prior to step S104, the following may also be included:

[0119] Perform an erase operation on the target logical sector, and set the target logical sector as an erased logical sector after the erase operation is completed.

[0120] Since the valid data of the target logical sector has been copied to the erased logical sector, and the erased logical sector containing the valid data has been activated after the copying is complete, the storage space of the Flash simulated EEPROM area can be effectively saved by performing an erase operation on the target logical sector and setting it as an erased logical sector.

[0121] In one embodiment, step S104 may specifically include:

[0122] (1) Write block log information at the latest block log address.

[0123] The block log information is used to record the block number, storage address, block size, and verification information.

[0124] (2) Write block data information at the latest block data address.

[0125] Among them, block data information is used to record the actual data of the block.

[0126] (3) Mark the target block corresponding to the latest block log address and the latest block data address as valid.

[0127] (4) Update the latest block log address and the latest block data address.

[0128] Specifically, the process of writing the data disclosed in this application is as follows: Figure 8 As shown, the steps include:

[0129] ① Write the block 1 log information at the latest block log address of the logical sector data area of ​​the active logical sector.

[0130] ② Write the data information of block 1 at the latest block data address of the logical sector data area of ​​the activated logical sector.

[0131] ③ Write valid marker information into the log area of ​​block 1 of the active logical sector, and update the latest block log address and the latest block data address.

[0132] ④ Write invalid flag information into the log area of ​​block 1 in the valid logical sector where block 1 is located.

[0133] After completing the above four steps, determine the number of valid blocks in the valid logical sector where block 1 is located. If the number of valid blocks is 0, the valid logical sector where block 1 is located needs to be set as an invalid logical sector.

[0134] In one embodiment, the data storage method may further include:

[0135] When the length of the data to be written is not greater than the remaining space of the currently active logical sector, the latest block log address and the latest block data address in the currently active logical sector are used as the write block data address to perform the data writing operation.

[0136] In this application, when the length of the written data is not greater than the remaining space of the currently active logical sector, the sector swapping operation is not performed. Instead, the latest block log address and the latest block data address in the currently active logical sector are used as the write block data address, and the data is written to the currently active logical sector.

[0137] It should be noted that, in response to Figure 1 After the mapping relationship of the data storage structure of the Flash simulated EEPROM is set, before executing the data storage method, it is also necessary to perform parsing operations on all logical sectors in the Flash simulated EEPROM in sequence.

[0138] In one embodiment, the process of sequentially performing parsing operations on all logical sectors includes:

[0139] (1) Jump to the state of reading logical sector log information in the Flash simulated EEPROM area and read the logical sector log information.

[0140] (2) Jump to the state of parsing logical sector log information in the Flash simulated EEPROM area, and parse the read logical sector log information to obtain logical sector status information.

[0141] (3) When the current logical sector is determined to be in a valid or active state based on the logical sector status information, the current logical sector is read from the current logical sector to the state of reading block log information in the Flash simulated EEPROM area.

[0142] Specifically, when it is determined that the current logical sector is in an active state, the latest block log address and the latest block data address of the current logical sector are recorded.

[0143] (4) Jump to the block log information parsing state in the Flash simulated EEPROM area, and parse the block log information read from the current logical sector to obtain the block status information.

[0144] (5) When it is determined that the current block is in a valid state based on the block status information, the block status information is recorded in the block log information storage area.

[0145] (6) After all block data in the current logical sector has been parsed, switch to the next logical sector of the current logical sector and return to the state of reading logical sector log information in the Flash simulated EEPROM area. Read the logical sector log information and perform the parsing operation again until all logical sectors have been parsed.

[0146] In one embodiment, the process of sequentially performing the parsing operation on all logical sectors may further include:

[0147] When it is determined that the current logical sector is invalid based on the logical sector status information, switch to the next logical sector of the current logical sector, and return to the state of reading logical sector log information in the Flash simulated EEPROM area, and read the logical sector log information and perform the parsing operation again.

[0148] For ease of understanding, this application provides a detailed explanation of the data parsing process, as follows:

[0149] The data parsing process in this application is as follows: Figure 9 As shown, the states included are as follows:

[0150] FEE_JOB_READ_LC_SEC_LOG_INFO: Status of reading logical sector log information.

[0151] FEE_JOB_PARSE_LC_SEC_LOG_INFO: Parse the status of logical sector log information.

[0152] FEE_JOB_READ_BLOCK_LOG_INFO: Status of read block log information.

[0153] FEE_JOB_PARSE_BLOCK_LOG_INFO: Parse block log information status.

[0154] The data parsing steps are as follows:

[0155] (1) After power-on, Fee_JobInstanceIt (instance index), Fee_JobLcSecIt (logical sector index), and status (status variable) are all marked as 0. When in the state of reading logical sector log information, the LcSecLog (logical sector log) read job is started. After the LcSec log read job is completed, the process jumps to the LcSec Log parsing job. The state of reading logical sector log information is a state in the state machine diagram, and the LcSec Log read job is the operation performed in this state.

[0156] (2) When in the state of parsing logical sector log information, after the LcSec Log parsing job is completed, if the logical sector is not in an active / valid state, Fee_JobLcSecIt (logical sector index) performs an accumulation operation and jumps to the LcSec Log reading job; if the logical sector is in an active / valid state, it indicates that the logical sector contains valid block data, and jumps to the Block Log reading job. Among them, the state of parsing logical sector log information is a state in the state machine diagram, and the LcSec Log parsing job is the operation performed in this state.

[0157] (3) After the Block Log reading job is completed, the process jumps to the Block Log parsing job and records the valid Blocks in the block log information storage area (denoted as the Block Log Info table). The block log information storage area is used to store relevant information about valid Blocks.

[0158] (4) After the Block Log parsing job is completed, if the Block is not in a BLANK state, change the Block log address and jump to the read Block Log job; if the Block is in a BLANK state, Fee_JobLcSecIt performs the accumulation operation and jumps to the read LcSec Log state.

[0159] The function `status = isMaxLcSec(Fee_JobLcSecIt)` is used to determine whether the index of the logical sector has reached the maximum value in the current instance group. The method for determining `status` is as follows: Figure 10 As shown. The function isMaxLcSec is used to calculate whether the logical sector corresponding to Fee_JobLcSecIt is the last logical sector in the current instance.

[0160] The function isMaxLcSec is used to calculate whether the logical sector corresponding to Fee_JobLcSecIt is the last logical sector in the current instance.

[0161] See Figure 10 Flowchart for determining whether the index of the judgment logic sector has reached the maximum value. The judgment process is as follows:

[0162] (1) After the Fee_JobLcSecIt (logic sector index) performs an accumulation operation, it is necessary to determine whether Fee_JobLcSecIt is equal to u16LcSecCnt (the maximum value in the current instance group);

[0163] (2) If Fee_JobLcSecIt is equal to u16LcSecCnt, set the status variable status = 1, and Fee_JobInstanceIt performs an accumulation operation;

[0164] (3) If Fee_JobLcSecIt is not equal to u16LcSecCnt, set the status variable status = 0.

[0165] As Figure 9 shown, if Fee_JobInstanceIt < FEE_INSTANCE_NUMBER (that is, the current instance index value is less than the configured number of instances) and 1 == status, then set status and Fee_JobLcSecIt to 0, and jump to the read LcSec log job to re - execute the data parsing step to parse the information of LcSec in this Instance group; if Fee_JobInstanceIt == FEE_INSTANCE_NUMBER (that is, the current instance index value is equal to the configured number of instances), it indicates that the data parsing process is completed.

[0166] Corresponding to the above - mentioned method embodiment, the present application also discloses a data storage device.

[0167] See Figure 11 , a schematic structural diagram of a data storage device disclosed in an embodiment of the present invention. The Flash - simulated EEPROM area is provided with at least one instance group. Each instance group is provided with at least three logic sectors. Each logic sector serves as a storage space and contains a valid status flag bit. When the valid status flag bit is set, it indicates that the corresponding logic sector is in a valid state and stores valid data.

[0168] The data storage device includes:

[0169] The target logical sector determination unit 201 is used to determine the target logical sector that needs to perform effective data exchange based on the number of the currently active logical sector when the length of the written data is greater than the remaining space of the currently active logical sector. The target logical sector is separated from the currently active logical sector by an erased logical sector, and the currently active logical sector is the logical sector that is currently in the active state.

[0170] The copying unit 202 is used to copy the valid data of the target logical sector to the erased logical sector when the target logical sector is in a valid state.

[0171] Setting unit 203 is used to set the currently active logical sector to an active state and set the erased logical sector to an active state as the latest active logical sector.

[0172] The write operation unit 204 is used to perform a data write operation by using the latest block log address and the latest block data address in the latest activated logical sector as the write block data address.

[0173] In summary, this invention discloses a data storage device. The Flash-simulated EEPROM area is configured with at least one instance group, each instance group having at least three logical sectors. Each logical sector serves as a storage space and contains valid data when in a valid state. When the length of the written data exceeds the remaining space of the currently active logical sector, the target logical sector for valid data exchange is determined based on the number of the currently active logical sector. While the target logical sector is in a valid state, the valid data of the target logical sector is copied to an erased logical sector, and the erased logical sector is set to an active state as the latest active logical sector. The latest block log address and the latest block data address in the latest active logical sector are used as the write block data address to perform a data write operation. This application distributes valid data across various logical sectors within an instance group. When the length of the written data exceeds the remaining space of the currently active logical sector, it is not necessary to copy all valid data in the instance group to the newly active logical sector when switching active logical sectors. Instead, only the valid data in the target logical sector where valid data exchange needs to be performed is copied to the newly active logical sector. This significantly reduces the data copying ratio during storage space switching, improves the utilization rate of Flash storage space, and extends the lifespan of Flash.

[0174] In addition, since this application reduces the data replication ratio during storage space switching, it effectively reduces the occurrence of errors during data replication, thereby improving the real-time performance and stability of the entire system to a certain extent.

[0175] In one embodiment, before the data storage performs a write operation unit 204, the system further includes:

[0176] The erase unit is used to perform an erase operation on the target logical sector and set the target logical sector as an erased logical sector after the erase operation is completed.

[0177] In one embodiment, the write operation unit 204 can be specifically used for:

[0178] Write the block log information at the latest block log address;

[0179] Write block data information to the latest block data address;

[0180] Mark the target block corresponding to the latest block log address and the latest block data address as valid;

[0181] Update the latest block log address and the latest block data address.

[0182] In one embodiment, the data storage device may further include:

[0183] The active logical sector holding unit is used to perform data writing operations when the length of the written data is not greater than the remaining space of the currently active logical sector, using the latest block log address and the latest block data address in the currently active logical sector as the write block data address.

[0184] In one embodiment, the data storage device may further include:

[0185] The parsing unit is used to perform parsing operations on all logical sectors sequentially after all logical sectors of all instance groups in the Flash simulated EEPROM area have been configured. During the parsing process, it records the latest block log address and the latest block data address of the active logical sectors until all logical sectors have been parsed.

[0186] In one embodiment, the parsing unit can specifically be used for:

[0187] Within the Flash simulated EEPROM area, jump to the state of reading logical sector log information and read the logical sector log information;

[0188] Within the Flash simulated EEPROM area, jump to the state of parsing logical sector log information, and parse the read logical sector log information to obtain logical sector status information;

[0189] When the current logical sector is determined to be in a valid or active state based on the logical sector status information, the system jumps to the state of reading block log information in the Flash simulated EEPROM area and reads block log information from the current logical sector.

[0190] Within the Flash simulated EEPROM area, jump to the state of parsing block log information, and parse the block log information read from the current logical sector to obtain block status information;

[0191] When it is determined that the current block is in a valid state based on the block status information, the block status information is recorded in the block log information storage area;

[0192] Once all block data in the current logical sector has been parsed, switch to the next logical sector and return to the state of reading logical sector log information in the Flash simulated EEPROM area. Read the logical sector log information and perform the parsing operation again until all logical sectors have been parsed.

[0193] In one embodiment, the parsing unit can specifically be used for:

[0194] When it is determined that the current logical sector is invalid based on the logical sector status information, switch to the next logical sector of the current logical sector, and return to the state of reading logical sector log information in the Flash simulated EEPROM area, and read the logical sector log information and perform the parsing operation again.

[0195] It should be noted that for the specific working principles of each component in the device embodiment, please refer to the corresponding section of the method embodiment, which will not be repeated here.

[0196] Corresponding to the above embodiments, such as Figure 12 As shown, the present invention also provides an electronic device, which may include: a processor 1 and a memory 2;

[0197] The processor 1 and memory 2 communicate with each other via communication bus 3.

[0198] Processor 1, for executing at least one instruction;

[0199] Memory 2 is used to store at least one instruction;

[0200] Processor 1 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.

[0201] Memory 2 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0202] The processor executes at least one instruction to implement the steps shown in the data storage method embodiment.

[0203] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0204] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0205] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data storage method, characterized in that, The Flash simulated EEPROM area is configured with at least one instance group, each instance group is configured with at least three logical sectors, and each logical sector contains a valid status flag bit as a storage space. When the valid status flag bit is set, it indicates that the corresponding logical sector is in a valid state and stores valid data. The data storage method includes: When the length of the written data is greater than the remaining space of the currently active logical sector, the target logical sector for which effective data exchange needs to be performed is determined based on the number of the currently active logical sector. The target logical sector is separated from the currently active logical sector by an erased logical sector, and the currently active logical sector is the logical sector that is currently in an active state. If the target logical sector is in a valid state, copy the valid data of the target logical sector to the erased logical sector; Set the currently active logical sector to an active state, and set the erased logical sector to an active state as the latest active logical sector; The latest block log address and the latest block data address in the latest activated logical sector are used as the write block data address to perform a data write operation.

2. The data storage method according to claim 1, characterized in that, Before performing the data write operation by using the latest block log address and the latest block data address in the latest activated logical sector as the write block data address, the following steps are also included: An erase operation is performed on the target logical sector, and the target logical sector after the erase operation is completed is set as an erased logical sector.

3. The data storage method according to claim 1 or 2, characterized in that, The step of using the latest block log address and the latest block data address in the latest activated logical sector as the write block data address to perform a data write operation includes: Write block log information at the latest block log address; Write block data information at the latest block data address; Mark the target block corresponding to the latest block log address and the latest block data address as valid; Update the latest block log address and the latest block data address.

4. The data storage method according to claim 1 or 2, characterized in that, Also includes: When the length of the written data is not greater than the remaining space of the currently active logical sector, the latest block log address and the latest block data address in the currently active logical sector are used as the write block data address to perform the data write operation.

5. The data storage method according to claim 1, characterized in that, After all the logical sectors of all the instance groups in the Flash simulated EEPROM area have been configured, the following steps are also included: The parsing operation is performed sequentially on all the logical sectors, and the latest block log address and latest block data address of the active logical sectors are recorded during the parsing process, until all the logical sectors have been parsed.

6. The data storage method according to claim 5, characterized in that, The process of sequentially performing the parsing operation on all the logical sectors includes: Within the Flash simulated EEPROM area, the system jumps to the state of reading logical sector log information and reads the logical sector log information. Within the Flash simulated EEPROM area, the process jumps to the state of parsing logical sector log information and parses the read logical sector log information to obtain logical sector status information. When it is determined that the corresponding current logical sector is in a valid or active state based on the logical sector status information, the system jumps to the state of reading block log information in the Flash simulated EEPROM area and reads block log information from the current logical sector. Within the Flash simulated EEPROM area, the process jumps to the state of parsing block log information and parses the block log information read from the current logical sector to obtain block status information. When it is determined that the corresponding current block is in a valid state based on the block status information, the block status information is recorded in the block log information storage area; After all block data in the current logical sector has been parsed, switch to the next logical sector of the current logical sector, and return to the state of reading logical sector log information in the Flash simulated EEPROM area. Read the logical sector log information, and perform the parsing operation again until all logical sectors have been parsed.

7. The data storage method according to claim 6, characterized in that, Also includes: When it is determined that the corresponding current logical sector is invalid based on the logical sector status information, switch to the next logical sector of the current logical sector, and return to the state of jumping to read logical sector log information in the Flash simulated EEPROM area, and read the logical sector log information and perform the parsing operation again.

8. The data storage method according to claim 1, characterized in that, Each logical sector contains a logical sector log information area and a logical sector data area; The logical sector log information area is used to store logical sector log information parameters; The logical sector data area is used to store block information; In this context, a block serves as the smallest unit for writing operations to the Flash simulated EEPROM region. Each block contains a block log information and a block data information. The block log information increments from low address to high address, while the block data information decreases from high address to low address.

9. A data storage device, characterized in that, The Flash simulated EEPROM area is configured with at least one instance group, each instance group is configured with at least three logical sectors, and each logical sector contains a valid status flag bit as a storage space. When the valid status flag bit is set, it indicates that the corresponding logical sector is in a valid state and stores valid data. The data storage device includes: The target logical sector determination unit is used to determine the target logical sector that needs to perform effective data exchange based on the number of the currently active logical sector when the length of the written data is greater than the remaining space of the currently active logical sector. The target logical sector is separated from the currently active logical sector by an erased logical sector, and the currently active logical sector is the logical sector that is currently in an active state. The copying unit is used to copy valid data from the target logical sector to the erased logical sector when the target logical sector is in a valid state. The setting unit is used to set the currently active logical sector to an active state and set the erased logical sector to an active state as the latest active logical sector. The write operation unit is used to perform a data write operation by using the latest block log address and the latest block data address in the latest activated logical sector as the write block data address.

10. An electronic device, characterized in that, The electronic device includes: a memory and a processor; The memory is used to store at least one instruction; The processor is used to execute the at least one instruction to implement the data storage method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method for increasing NOR FLASH erase / write life

    CN102736981A

  • Data storage management method, device and equipment

    CN117075801A

  • Multi-sector management method and device for Fe module of automobile open system architecture

    CN118151842A

  • Analog electrically erasable memory data processing method, memory and micro-processing chip

    CN118471299A

  • Method and system for quickly acquiring effective data in power-on process, vehicle and medium

    CN119105699A