Data management methods, apparatus, devices, and storage media based on EEPROM

By copying EEPROM data to a mapped data block in RAM and assigning values ​​to the mapped members first and then the original members during writing, the problem of low read/write efficiency in EEPROM data management methods is solved, achieving more efficient data access and simplified software module management.

CN116860176BActive Publication Date: 2026-11-10DONGFENG AUTOMOBILE ELECTRONICS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310951421.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2026-11-10
Estimated Expiration
2043-07-31

AI Technical Summary

Technical Problem

Existing EEPROM-based data management methods have low read/write efficiency, and frequent access to EEPROM increases system time consumption.

Method used

The data in the EEPROM is copied to the mapped data block in the RAM. The mapped members correspond one-to-one with the original members. When writing data, the mapped members are assigned values ​​first, and then the original members are assigned values. When reading data, the data in the mapped members is read directly.

Benefits of technology

This reduces the access frequency of EEPROM, improves read and write efficiency, reduces system time consumption, and simplifies the complexity of software modules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116860176B_ABST
    Figure CN116860176B_ABST
Patent Text Reader

Abstract

This invention provides a data management method, apparatus, device, and storage medium based on EEPROM. The method includes: copying all data in the EEPROM to a mapped data block in RAM, wherein the mapped members in the mapped data block correspond one-to-one with the original members in the EEPROM; determining the first original member and the first mapped member corresponding to the data to be written; assigning a value to the first mapped member with the data to be written; and assigning a value to the first original member with the data of the first mapped member; determining the second original member and the second mapped member corresponding to the data to be read; and reading the data of the second mapped member, wherein the data of the second mapped member is the same as the data of the second original member. Through this invention, no access to the EEPROM is required when reading data, reducing the access frequency of the EEPROM, thereby reducing system time consumption and significantly improving read / write efficiency. Furthermore, only the write timing exists, and there is no read timing, eliminating the need for time-sharing management and arbitration of two timing sequences, greatly reducing the complexity of the software module.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data management technology, and in particular to a data management method, apparatus, device and storage medium based on EEPROM. Background Technology

[0002] Today, with the widespread adoption of automotive informatization and intelligence, various automotive electronic units (EMUs) are undertaking increasingly complex and efficient execution functions, some of which require the retention of critical data and information even when power is off. Therefore, most automotive EMUs possess data storage capabilities, typically achieved through external EEPROMs or by using the processor's internal FLASH memory to simulate an EEPROM. Traditional data management methods always access the EEPROM before performing read / write operations to determine if it is "busy," waiting until it is no longer busy before executing the operation command. This is because after an EEPROM write operation, it takes some time to update the data, during which time read / write operations are impossible. Therefore, frequent EEPROM accesses increase system time consumption, resulting in low read / write efficiency for data management methods. Summary of the Invention

[0003] The main objective of this invention is to provide a data management method, apparatus, device, and storage medium based on EEPROM, aiming to solve the technical problem of low read / write efficiency in existing EEPROM-based data management methods.

[0004] In a first aspect, the present invention provides a data management method based on EEPROM, the data management method based on EEPROM comprising:

[0005] All data in the EEPROM is copied to a mapped data block in RAM, and the mapped members in the mapped data block correspond one-to-one with the original members in the EEPROM.

[0006] Determine the first original member and the first mapped member corresponding to the data to be written, assign a value to the first mapped member with the data to be written, and assign a value to the first original member with the data of the first mapped member;

[0007] Determine the second original member and the second mapped member corresponding to the data to be read, and read the data of the second mapped member, which is the same as the data of the second original member.

[0008] Furthermore, in one embodiment, an enumeration table and a configuration information table are stored in the FLASH memory;

[0009] The enumeration members in the enumeration table are used to abstractly declare the mapping members in the mapping data block and their corresponding original members in the EEPROM.

[0010] Each configuration member in the configuration information table is used to store the RAM address and data length of the corresponding mapping member, and the enumeration member is also used to locate the configuration member.

[0011] Further, in one embodiment, the steps of determining the first original member and the first mapped member corresponding to the data to be written, assigning a value to the first mapped member with the data to be written, and assigning a value to the first original member with the data of the first mapped member include:

[0012] Determine the first enumeration member corresponding to the data to be written, the length of the data to be written, and the write storage address in RAM. The first enumeration member is used to abstractly declare the first original member and the first mapped member.

[0013] The data to be written is stored at the write storage address;

[0014] If the length of the data stored in the target configuration member located by the first enumerated member is equal to the length of the data to be written, then the target RAM address of the target configuration member is obtained, and the target RAM address is used to store the first mapping member;

[0015] If the data in the target RAM address is different from the data in the write storage address, then the data in the write storage address is copied to the target RAM address;

[0016] The target EEPROM address is calculated based on the target RAM address and the RAM address stored in the first configuration member in the configuration information table. The target EEPROM address is used to store the first original member.

[0017] Copy the data from the target RAM address to the target EEPROM address.

[0018] Further, in one embodiment, the step of copying data from the target RAM address to the target EEPROM address includes:

[0019] If the FIFO memory is not full, then the target RAM address and the target EEPROM address are input into the FIFO memory;

[0020] The data in the target RAM address is copied to the target EEPROM address through the FIFO memory.

[0021] Further, in one embodiment, after the step of calculating the target EEPROM address based on the target RAM address and the RAM address stored in the first configuration member of the configuration information table, wherein the target EEPROM address is used to store the first original member, the method further includes:

[0022] If the FIFO memory is full, wait for a preset time and then try to input the target RAM address and the target EEPROM address into the FIFO memory again.

[0023] Further, in one embodiment, the step of determining the second original member and the second mapped member corresponding to the data to be read, and reading the data of the second mapped member, wherein the data of the second mapped member is the same as the data of the second original member, includes:

[0024] Determine the second enumeration member corresponding to the data to be read, the length of the data to be read, and the read storage address in RAM. The second enumeration member is used to abstractly declare the second original member and the second mapped member.

[0025] If the length of the data stored in the target configuration member located by the second enumeration member is equal to the length of the data to be read, then the target RAM address of the target configuration member is obtained, and the target RAM address is used to store the second mapping member;

[0026] The data in the target RAM address is copied to the read storage address to read the data of the second mapped member, and the data of the second mapped member is the same as the data of the second original member.

[0027] Furthermore, in one embodiment, the original members in the EEPROM are, in order, data BOOT, data HEAD, multiple intermediate data members, and data TAIL;

[0028] The step of copying all data from the EEPROM to the mapped data block in RAM also includes:

[0029] If the data BOOT in the mapped data block is different from the BOOT special word, then the EEPROM is determined to be a new EEPROM, and the data to be written is determined to be the BOOT special word, the HEAD special word, the TAIL special word and multiple first preset data, wherein the first preset data is used to assign values ​​to the intermediate data members;

[0030] If the data BOOT in the mapped data block is the same as the BOOT special word, and the data HEAD in the mapped data block is different from the HEAD special word, then the data in the EEPROM is determined to be invalid, and the data to be written is determined to be the HEAD special word, the TAIL special word, and multiple second preset data, wherein the second preset data is used to assign values ​​to the intermediate data members;

[0031] If the data BOOT in the mapped data block is the same as the BOOT special word, the data HEAD in the mapped data block is the same as the HEAD special word, and the data TAIL in the mapped data block is different from the TAIL special word, then the data in the EEPROM is determined to be invalid, and the data to be written is determined to be the TAIL special word and multiple second preset data.

[0032] Secondly, the present invention also provides an EEPROM-based data management device, the EEPROM-based data management device comprising:

[0033] An initialization module is used to copy all data in the EEPROM to a mapped data block in RAM, wherein the mapped members in the mapped data block correspond one-to-one with the original members in the EEPROM.

[0034] The writing module is used to determine the first original member and the first mapped member corresponding to the data to be written, assign a value to the first mapped member with the data to be written, and assign a value to the first original member with the data of the first mapped member;

[0035] The reading module is used to determine the second original member and the second mapping member corresponding to the data to be read, and to read the data of the second mapping member, wherein the data of the second mapping member is the same as the data of the second original member.

[0036] Thirdly, the present invention also provides an EEPROM-based data management device, the EEPROM-based data management device including a processor, a memory, and an EEPROM-based data management program stored in the memory and executable by the processor, wherein when the EEPROM-based data management program is executed by the processor, it implements the steps of the above-described EEPROM-based data management method.

[0037] Fourthly, the present invention also provides a storage medium storing an EEPROM-based data management program, wherein when the EEPROM-based data management program is executed by a processor, it implements the steps of the above-described EEPROM-based data management method.

[0038] This invention copies all data from the EEPROM to a mapped data block in RAM, ensuring that the data in the mapped data block is identical to the corresponding mapped and original members in the EEPROM in the initial state. When writing data, the mapped member is first assigned a value using the data to be written, and then the original member is assigned a value using the data in the mapped member. This ensures that after writing data, the corresponding mapped and original members remain identical. When reading data, the corresponding original data in the EEPROM can be read directly from the mapped member.

[0039] This invention eliminates the need to access the EEPROM when reading data, reducing the frequency of EEPROM accesses and thus minimizing system time consumption, significantly improving read / write efficiency. Furthermore, during the execution of periodic tasks in the system, only the write sequence exists, eliminating the need for time-sharing management and arbitration of the read and write sequences, greatly reducing software module complexity. Attached Figure Description

[0040] Figure 1 This is a flowchart illustrating a data management method based on EEPROM in one embodiment of the present invention;

[0041] Figure 2 This is a schematic diagram of the software architecture of the EEPROM-based data management method of the present invention;

[0042] Figure 3 This is a schematic diagram of the data structure of the mapped data block and EEPROM in one embodiment of the present invention;

[0043] Figure 4 This is a schematic diagram of the data structure of the enumeration table in one embodiment of the present invention;

[0044] Figure 5 This is a schematic diagram of the data structure of the configuration information table in one embodiment of the present invention;

[0045] Figure 6 This is a schematic diagram of the data writing process of the application data management layer in one embodiment of the present invention;

[0046] Figure 7 This is a schematic diagram of the FIFO data input process of the data transmission layer in one embodiment of the present invention;

[0047] Figure 8 This is a schematic diagram of the FIFO data output process of the data transmission layer in one embodiment of the present invention;

[0048] Figure 9 This is a schematic diagram of the data reading process applied to the data management layer in one embodiment of the present invention;

[0049] Figure 10This is a schematic diagram of the data verification and repair process applied to the data management layer in one embodiment of the present invention;

[0050] Figure 11 This is a schematic diagram of the hardware structure of a data management device based on EEPROM in one embodiment of the present invention.

[0051] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0052] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0053] In a first aspect, embodiments of the present invention provide a data management method based on EEPROM.

[0054] Figure 1 A flowchart illustrating a data management method based on EEPROM according to an embodiment of the present invention is shown.

[0055] Reference Figure 1 In one embodiment, the EEPROM-based data management method includes the following steps:

[0056] S11. Copy all data in the EEPROM to the mapped data block in RAM. The mapped members in the mapped data block correspond one-to-one with the original members in the EEPROM.

[0057] Figure 2 A schematic diagram of the software architecture of the EEPROM-based data management method of the present invention is shown; Figure 3 A schematic diagram of the data structure of the mapping data block and EEPROM is shown in one embodiment of the present invention.

[0058] Reference Figure 2 The software architecture is divided into an application data management layer, a data transmission layer, and an EEPROM driver layer. The application data management layer is the top layer, primarily responsible for configuring and managing stored data, providing EEPROM data writing and reading functions for other application layers. The data transmission layer is the middle layer, responsible for transferring data from the application data management layer to the EEPROM driver layer. The EEPROM driver layer is the bottom layer, primarily responsible for the peripheral driver and timing implementation for communication between different types of EEPROM hardware chips (such as EEPROMs with different communication types or storage spaces, like IIC and SPI). This method mainly focuses on describing the application data management layer and the data transmission layer.

[0059] Reference Figure 3In this embodiment, the application data management layer, in order to configure and manage the data that needs to be stored, takes a portion of RAM as a RAM mapping area and copies all data from the EEPROM to the RAM mapping area to form a mapped data block. Data members stored in the EEPROM are defined as original members, and the corresponding data members copied from the original members in the mapped data block are defined as mapped members. Forming the mapped data block is defined as data initialization. The data initialization operation ensures that, in the initial state, the data (content) of the mapped data block is the same as the corresponding mapped members and original members in the EEPROM. For example, original member 1 in the EEPROM corresponds to mapped member 1 in the mapped data block, and the data in both is data A.

[0060] S12. Determine the first original member and the first mapped member corresponding to the data to be written, assign the value to the first mapped member with the data to be written, and assign the value to the first original member with the data of the first mapped member;

[0061] In this embodiment, the purpose of data writing is to modify the data of a certain original member in the EEPROM. The original member corresponds to a specific mapped member, so both the original member and the mapped member corresponding to the data to be written can be determined. When writing data, the mapped member is first assigned a value using the data to be written, and then the original member is assigned a value using the data of the mapped member. This ensures that after the data is written, the corresponding mapped members and the original members remain identical. For example, continuing to refer to... Figure 3 If a user wants to modify the data of the original member 1 in the EEPROM to data X, then the data to be written is data X, corresponding to the original member 1 and the mapped member 1. After the write operation, the data of both the original member 1 and the mapped member 1 will change from data A to data X.

[0062] S13. Determine the second original member and the second mapping member corresponding to the data to be read, and read the data of the second mapping member. The data of the second mapping member is the same as the data of the second original member.

[0063] In this embodiment, the purpose of data reading is to read the data of a specific original member in the EEPROM. Since the original member corresponds to a specific mapped member, both the original member and the mapped member corresponding to the data to be read can be determined. The aforementioned initialization and write operations ensure that the data of the corresponding mapped members and original members remain identical. Therefore, when reading data, directly reading the data of the mapped member is sufficient to complete the reading of the corresponding original data in the EEPROM. For example, if the user wants to read the data of original member 2 in the EEPROM, the data to be read corresponds to original member 2 and mapped member 2. Reading the data of mapped member 2, which is data B and data C, is equivalent to reading the data of original member 2.

[0064] Therefore, this embodiment eliminates the need to access the EEPROM when reading data, reducing the frequency of EEPROM access and thus minimizing system time consumption, significantly improving read / write efficiency. Furthermore, during the execution of periodic tasks in the system, only the write sequence exists, eliminating the need for time-sharing management and arbitration of the read and write sequences, greatly reducing software module complexity.

[0065] It should be noted that since the data in RAM is lost after power failure, step S11 needs to be executed every time power is restored to complete data initialization. Steps S12 and S13 do not have a specific timing; they are determined based on the user's operation at power-up. When the user calls the data write interface, step S12 is executed; when the user calls the data read interface, step S13 is executed.

[0066] Figure 4 A schematic diagram of the data structure of the enumeration table in one embodiment of the present invention is shown; Figure 5 A schematic diagram of the data structure of the configuration information table in one embodiment of the present invention is shown.

[0067] Reference Figure 4 and Figure 5 Furthermore, in one embodiment, the FLASH memory stores an enumeration table and a configuration information table. The enumeration members in the enumeration table are used to abstractly declare the mapping members in the mapped data block and their corresponding original members in the EEPROM. Each configuration member in the configuration information table is used to store the RAM address and data length of the corresponding mapping member; the enumeration members are also used to locate the configuration member.

[0068] Continue to refer to Figure 3 The RAM space occupied by the mapped members within the mapped data block is determined by the size of each stored data. Optionally, a character array can be used to define the data length to avoid the problem of discontinuous address distribution of different members of the mapped data block in RAM. Figure 3 In the mapping member 1, data A is contained, which occupies 1 byte and has a length defined as uint8[1]. Mapping member 2 contains data B and data C, which occupy 2 bytes and have a length defined as uint8[2]. Mapping member 3 contains data D, data E and data F, which occupy 3 bytes and have a length defined as uint8[3].

[0069] In this embodiment, through abstract declaration, other modules can directly substitute enumerated members into formal parameters when calling the stored data of EEPROM. The configuration information table is an array of structure types, and the structure (configuration member) contains two members: address and length. There is also a one-to-one correspondence between configuration members and enumerated members, so configuration members can be located through enumerated members. Specifically, the configuration member is found through the enumeration ID, and the corresponding configuration information is obtained. For example, the configuration member found through the enumeration ID "member 1" stores the configuration information of the RAM address and data length of mapping member 1.

[0070] It should be noted that although the data content of some original members in the EEPROM may change due to data write operations, the storage address and data length of each original member will remain unchanged under normal circumstances, and the storage address and data length of each mapped member in the corresponding mapped data block will also remain unchanged. Therefore, by storing the enumeration table and configuration information table in FLASH, this data will not be lost after a power outage, and can be directly used each time power is restored without the need to reacquire data and rebuild the parameter table, thus improving the convenience of data management and maintenance. Optionally, both the enumeration table and the configuration information table are of type CONST and are stored in FLASH as read-only data after software compilation.

[0071] Furthermore, in one embodiment, step S12 specifically includes:

[0072] Determine the first enumeration member corresponding to the data to be written, the length of the data to be written, and the write storage address in RAM. The first enumeration member is used to abstractly declare the first original member and the first mapped member.

[0073] Store the data to be written at the write storage address;

[0074] If the length of the data stored in the target configuration member located by the first enumerated member is equal to the length of the data to be written, then the target RAM address of the target configuration member is obtained, and the target RAM address is used to store the first mapped member;

[0075] If the data in the target RAM address is different from the data in the write storage address, then copy the data in the write storage address to the target RAM address;

[0076] The target EEPROM address is calculated based on the target RAM address and the RAM address stored in the first configuration member in the configuration information table. The target EEPROM address is used to store the first original member.

[0077] Copy the data from the target RAM address to the target EEPROM address.

[0078] In this embodiment, two comparison operations are set up. The first is to compare the length of the data stored in the target configuration member (the data length of the first mapped member) with the length of the data to be written. The second is to compare the data in the target RAM address (the data of the first mapped member) with the data in the write storage address (the data to be written). The length comparison is to determine the validity of the data length. For example, if the length of the data to be written is 2 bytes, but the length of the data in the first mapped member is 3 bytes, this is considered a length error, and the write operation is not allowed. The data comparison is to determine the necessity of the data write operation. For example, if the data to be written is data X, and the data in the first mapped member is also data X, it means that the data in the first original member is also X, and there is no need to perform subsequent copy operations, saving system resources and time.

[0079] In this embodiment, the write storage address is a segment of address in RAM requested from the user, used to temporarily store the data to be written. In this embodiment, the write storage address, target RAM address, and EEPROM address all refer to an address segment matching the data length. In practice, it is usually obtained through the starting address and the data length. The address of the first original member in the EEPROM is 0, while the address of the first mapped member in the mapping data table is determined by the allocation of the RAM mapping area. However, the target EEPROM address can be calculated by the offset of the target RAM address relative to the RAM address of the first mapped member. For example, if the RAM address of the first mapped member is m, and the target RAM address is (m+10) to (m+12), then the target EEPROM address is calculated to be 10 to 12.

[0080] Figure 6 A schematic diagram of the data writing process of the application data management layer is shown in one embodiment of the present invention.

[0081] Reference Figure 6 In one embodiment, the application data management layer performs data writing operations using the write function `write()`. The enumeration ID, `buff`, and `length` are the input parameters of the write function. The enumeration ID is the ID of the first enumerated member corresponding to the data to be written, `buff` is the starting address of the RAM requested from the user, and `length` is the length of the data to be written. The target RAM address is determined by the RAM starting address `a` and `length`, the parameter `buff` address is determined by the `buff` pointer and `length`, and the target EEPROM address is determined by the EEPROM starting address `x` and `length`.

[0082] It should be noted that in each data write operation in step S12, the step of copying the data from the target RAM address to the target EEPROM address is not performed by the application data management layer, but by the EEPROM driver layer. The application data management layer needs to transfer the data required for the copy operation (RAM start address a, EEPROM start address x, and length) to the EEPROM driver layer through the data transmission layer.

[0083] Figure 7 A schematic diagram of the FIFO data input process of the data transmission layer in one embodiment of the present invention is shown; Figure 8 A schematic diagram of the FIFO data output process of the data transmission layer in one embodiment of the present invention is shown.

[0084] Furthermore, in one embodiment, the step of copying data from the target RAM address to the target EEPROM address includes:

[0085] If the FIFO memory is not full, input the target RAM address and target EEPROM address into the FIFO memory;

[0086] The data at the target RAM address is copied to the target EEPROM address using a FIFO memory.

[0087] In this embodiment, the write timing is managed through a FIFO (Firstin, Firstout) memory. The FIFO memory acts as a buffer, allowing user programs that call the data storage module to perform EEPROM read and write operations anytime and anywhere without having to consider read-write conflicts or other issues.

[0088] Specifically, refer to Figure 7 The data transmission layer uses a FIFO (First-In, First-Out) memory for data input and output. FIFO data input is real-time; data is pushed into the FIFO memory in real time. Unless the FIFO memory is full, the application layer does not need to handle subsequent processing of the stored data. (See reference...) Figure 8The FIFO data output of the data transmission layer is periodic. After the last data write to the EEPROM, a waiting time of t1 is reached before the next data write (excluding the time occupied by the write itself). t1 needs to be set according to the BUSY time (self-erase time) t2 after the data write of the specific EEPROM being used, and t1 must be greater than t2. In each cycle, the data in the FIFO memory is transferred to the EEPROM driver layer. The EEPROM driver layer writes the data into the EEPROM byte by byte until the write operation corresponding to the current FIFO data is completed. After the EEPROM driver layer returns a successful write, the data transmission layer outputs the current FIFO data from the FIFO memory. If a write error occurs and the count exceeds three, the current FIFO data is recorded, and this data is forcibly output to troubleshoot hardware and software problems.

[0089] Further, in one embodiment, after the step of calculating the target EEPROM address based on the target RAM address and the RAM address stored in the first configuration member of the configuration information table, and using the target EEPROM address to store the first original member, the method further includes:

[0090] If the FIFO memory is full, wait for a preset time and then try to input the target RAM address and target EEPROM address into the FIFO memory again.

[0091] In this embodiment, when the FIFO memory is full, the user program can make a record and attempt to write again in the next execution cycle. For the application data management layer, it waits for a preset time before attempting to input the relevant data into the FIFO memory again. The preset time is determined based on the execution cycle of the user program.

[0092] Furthermore, in one embodiment, step S13 specifically includes:

[0093] Determine the second enumeration member corresponding to the data to be read, the length of the data to be read, and the read storage address in RAM. The second enumeration member is used to abstractly declare the second original member and the second mapped member.

[0094] If the length of the data stored in the target configuration member located by the second enumeration member is equal to the length of the data to be read, then the target RAM address of the target configuration member is obtained, and the target RAM address is used to store the second mapping member;

[0095] The data in the target RAM address is copied to the read storage address to read the data of the second mapped member, which is the same as the data of the second original member.

[0096] In this embodiment, the data length stored in the target configuration member (the data length of the second mapped member) is compared with the length of the data to be read to determine the validity of the data length. For example, if the length of the data to be read is 2 bytes, but the data length of the second mapped member is 3 bytes, this is considered a length error, and the read operation is not allowed. The read storage address is a segment of address in RAM requested from the user, used to temporarily store the data read from the target RAM address. Because the mapped data block is accessed internally by the storage module, it is protected and not publicly declared. In this embodiment, both the read storage address and the target RAM address refer to a segment of address that matches the data length. In actual operation, it is usually obtained through the starting address and the data length.

[0097] Figure 9 A schematic diagram of the data reading process using the data management layer in one embodiment of the present invention is shown.

[0098] Reference Figure 9 In one embodiment, the application data management layer performs data reading operations using the read() function. The enumeration ID, buff, and length are the input parameters of the read function. The enumeration ID is the ID of the second enumerated member corresponding to the data to be read, buff is the starting address in the RAM requested from the user, and length is the length of the data to be read. The target RAM address is determined by the RAM starting address 'a' and length, and the buff parameter address is determined by the buff pointer and length. All data reading operations in step S13 are executed by the application data management layer.

[0099] Figure 10 This diagram illustrates a data verification and repair process using the data management layer in one embodiment of the present invention.

[0100] See Figure 3 and Figure 10 Furthermore, in one embodiment, the original members in the EEPROM are, in order, data BOOT, data HEAD, multiple intermediate data members, and data TAIL. Following the step of copying all data from the EEPROM to the mapped data block in RAM, the method further includes:

[0101] If the data BOOT in the mapped data block is different from the BOOT special word, then the EEPROM is determined to be a new EEPROM, and the data to be written is determined to be the BOOT special word, the HEAD special word, the TAIL special word and multiple first preset data, wherein the first preset data is used to assign values ​​to intermediate data members;

[0102] If the data BOOT in the mapped data block is the same as the BOOT special word, and the data HEAD in the mapped data block is different from the HEAD special word, then the data in the EEPROM is determined to be invalid. The data to be written is determined to be the HEAD special word, the TAIL special word, and multiple second preset data, wherein the second preset data is used to assign values ​​to intermediate data members.

[0103] If the data BOOT in the mapped data block is the same as the BOOT special word, the data HEAD in the mapped data block is the same as the HEAD special word, and the data TAIL in the mapped data block is different from the TAIL special word, then the data in the EEPROM is determined to be invalid, and the data to be written is determined to be the TAIL special word and multiple second preset data.

[0104] In this embodiment, BOOT is the boot data at address 0x0000 of the EEPROM storage segment. A special word, such as 0xFE or another special word, can be set in the software. Generally, the default data at address 0x0000 of a new EEPROM is 0xFF. After copying, by reading the data BOOT in the mapped data block and comparing it with the set BOOT special word, it can be determined whether the EEPROM is new. Similarly, HEAD and TAIL are special words for the head and tail addresses of the data storage segment. After the BOOT special word comparison passes, the HEAD and TAIL special words are compared. If either is different, it is considered that although the EEPROM has been used by this software, the data length of the data storage segment has changed, therefore the data in the EEPROM is deemed invalid.

[0105] After data verification, for EEPROMs identified as new or with invalid data, data repair is performed using the data writing function provided in step S12. In both cases, the data BOOT, data HEAD, and data TAIL need to be corrected to the corresponding special words. For new EEPROMs, all intermediate data members ( Figure 3 The original members (1, 2, 3, etc.) in the EEPROM need to be modified to the first preset data. For EEPROMs with invalid data, all intermediate data members need to be modified to the second preset data. The first and second preset data are different. For example, the first preset data is all 0, and the second preset data is the data in array A. Array A is of type CONST and is used to define local default data. After data repair, the automotive electronic unit will produce different display results when these two types of EEPROMs are connected.

[0106] Secondly, embodiments of the present invention also provide a data management device based on EEPROM.

[0107] In one embodiment, the EEPROM-based data management device includes:

[0108] The initialization module is used to copy all the data in the EEPROM to the mapped data block in RAM. The mapped members in the mapped data block correspond one-to-one with the original members in the EEPROM.

[0109] The writing module is used to determine the first original member and the first mapped member corresponding to the data to be written, assign the first mapped member a value with the data to be written, and assign the first original member a value with the data of the first mapped member;

[0110] The reading module is used to determine the second original member and the second mapped member corresponding to the data to be read, and to read the data of the second mapped member, which is the same as the data of the second original member.

[0111] Furthermore, in one embodiment, an enumeration table and a configuration information table are stored in the FLASH memory;

[0112] The enumeration members in the enumeration table are used to abstractly declare the mapping members in the mapped data block and their corresponding original members in the EEPROM.

[0113] Each configuration member in the configuration information table is used to store the RAM address and data length of the corresponding mapping member, and the enumeration member is also used to locate the configuration member.

[0114] Furthermore, in one embodiment, the writing module is used for:

[0115] Determine the first enumeration member corresponding to the data to be written, the length of the data to be written, and the write storage address in RAM. The first enumeration member is used to abstractly declare the first original member and the first mapped member.

[0116] Store the data to be written at the write storage address;

[0117] If the length of the data stored in the target configuration member located by the first enumerated member is equal to the length of the data to be written, then the target RAM address of the target configuration member is obtained, and the target RAM address is used to store the first mapped member;

[0118] If the data in the target RAM address is different from the data in the write storage address, then copy the data in the write storage address to the target RAM address;

[0119] The target EEPROM address is calculated based on the target RAM address and the RAM address stored in the first configuration member in the configuration information table. The target EEPROM address is used to store the first original member.

[0120] Copy the data from the target RAM address to the target EEPROM address.

[0121] Furthermore, in one embodiment, the writing module is used for:

[0122] If the FIFO memory is not full, input the target RAM address and target EEPROM address into the FIFO memory;

[0123] The data at the target RAM address is copied to the target EEPROM address using a FIFO memory.

[0124] Furthermore, in one embodiment, the writing module is also used for:

[0125] If the FIFO memory is full, wait for a preset time and then try to input the target RAM address and target EEPROM address into the FIFO memory again.

[0126] Furthermore, in one embodiment, the reading module is used for:

[0127] Determine the second enumeration member corresponding to the data to be read, the length of the data to be read, and the read storage address in RAM. The second enumeration member is used to abstractly declare the second original member and the second mapped member.

[0128] If the length of the data stored in the target configuration member located by the second enumeration member is equal to the length of the data to be read, then the target RAM address of the target configuration member is obtained, and the target RAM address is used to store the second mapping member;

[0129] The data in the target RAM address is copied to the read storage address to read the data of the second mapped member, which is the same as the data of the second original member.

[0130] Furthermore, in one embodiment, the original members in the EEPROM are, in order, data BOOT, data HEAD, multiple intermediate data members, and data TAIL;

[0131] The EEPROM-based data management device also includes a verification and repair module, used for:

[0132] If the data BOOT in the mapped data block is different from the BOOT special word, then the EEPROM is determined to be a new EEPROM, and the data to be written is determined to be the BOOT special word, the HEAD special word, the TAIL special word and multiple first preset data, wherein the first preset data is used to assign values ​​to intermediate data members;

[0133] If the data BOOT in the mapped data block is the same as the BOOT special word, and the data HEAD in the mapped data block is different from the HEAD special word, then the data in the EEPROM is determined to be invalid. The data to be written is determined to be the HEAD special word, the TAIL special word, and multiple second preset data, wherein the second preset data is used to assign values ​​to intermediate data members.

[0134] If the data BOOT in the mapped data block is the same as the BOOT special word, the data HEAD in the mapped data block is the same as the HEAD special word, and the data TAIL in the mapped data block is different from the TAIL special word, then the data in the EEPROM is determined to be invalid, and the data to be written is determined to be the TAIL special word and multiple second preset data.

[0135] The functions of each module in the EEPROM-based data management device correspond to the steps in the EEPROM-based data management method embodiment, and their functions and implementation processes will not be described in detail here.

[0136] Thirdly, embodiments of the present invention provide an EEPROM-based data management device, which can be a personal computer (PC), a laptop computer, a server, or other device with data processing capabilities.

[0137] Figure 11 A schematic diagram of the hardware structure of a data management device based on EEPROM according to an embodiment of the present invention is shown.

[0138] Reference Figure 11 In this embodiment of the invention, the EEPROM-based data management device may include a processor 1001 (e.g., a Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to implement communication between these components; the user interface 1003 may include a display screen or an input unit such as a keyboard; the network interface 1004 may optionally include a standard wired interface or a wireless interface (e.g., Wireless Fidelity, Wi-Fi); the memory 1005 may be high-speed random access memory (RAM) or stable memory (non-volatile memory), such as a disk storage device. Alternatively, the memory 1005 may also be a storage device independent of the aforementioned processor 1001. Those skilled in the art will understand that… Figure 11The hardware structure shown does not constitute a limitation of the invention and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0139] Continue to refer to Figure 11 , Figure 11 The memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an EEPROM-based data management program. The processor 1001 can call the EEPROM-based data management program stored in the memory 1005 and execute the EEPROM-based data management method provided in this embodiment of the invention.

[0140] Fourthly, embodiments of the present invention also provide a storage medium.

[0141] The present invention stores an EEPROM-based data management program on a storage medium, wherein when the EEPROM-based data management program is executed by a processor, it implements the steps of the EEPROM-based data management method described above.

[0142] The method implemented when the EEPROM-based data management program is executed can be referred to in various embodiments of the EEPROM-based data management method of the present invention, and will not be repeated here.

[0143] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system 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 system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0144] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0145] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of the present invention.

[0146] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A data management method based on EEPROM, characterized in that, The EEPROM-based data management method includes: All data in the EEPROM is copied to a mapped data block in RAM, and the mapped members in the mapped data block correspond one-to-one with the original members in the EEPROM. Determine the first original member and the first mapped member corresponding to the data to be written, assign a value to the first mapped member with the data to be written, and assign a value to the first original member with the data of the first mapped member; Determine the second original member and the second mapped member corresponding to the data to be read, and read the data of the second mapped member, which is the same as the data of the second original member; wherein, the FLASH stores an enumeration table and a configuration information table; The enumeration members in the enumeration table are used to abstractly declare the mapping members in the mapping data block and their corresponding original members in the EEPROM. Each configuration member in the configuration information table is used to store the RAM address and data length of the corresponding mapping member, and the enumeration member is also used to locate the configuration member.

2. The data management method based on EEPROM as described in claim 1, characterized in that, The steps of determining the first original member and the first mapped member corresponding to the data to be written, assigning a value to the first mapped member using the data to be written, and assigning a value to the first original member using the data of the first mapped member include: Determine the first enumeration member corresponding to the data to be written, the length of the data to be written, and the write storage address in RAM. The first enumeration member is used to abstractly declare the first original member and the first mapped member. The data to be written is stored at the write storage address; If the length of the data stored in the target configuration member located by the first enumerated member is equal to the length of the data to be written, then the target RAM address of the target configuration member is obtained, and the target RAM address is used to store the first mapping member; If the data in the target RAM address is different from the data in the write storage address, then the data in the write storage address is copied to the target RAM address; The target EEPROM address is calculated based on the target RAM address and the RAM address stored in the first configuration member in the configuration information table. The target EEPROM address is used to store the first original member. Copy the data from the target RAM address to the target EEPROM address.

3. The data management method based on EEPROM as described in claim 2, characterized in that, The step of copying the data from the target RAM address to the target EEPROM address includes: If the FIFO memory is not full, then the target RAM address and the target EEPROM address are input into the FIFO memory; The data in the target RAM address is copied to the target EEPROM address through the FIFO memory.

4. The data management method based on EEPROM as described in claim 3, characterized in that, After the step of calculating the target EEPROM address based on the target RAM address and the RAM address stored in the first configuration member of the configuration information table, wherein the target EEPROM address is used to store the first original member, the method further includes: If the FIFO memory is full, wait for a preset time and then try to input the target RAM address and the target EEPROM address into the FIFO memory again.

5. The data management method based on EEPROM as described in claim 1, characterized in that, The step of determining the second original member and the second mapped member corresponding to the data to be read, and reading the data of the second mapped member, wherein the data of the second mapped member is the same as the data of the second original member, includes: Determine the second enumeration member corresponding to the data to be read, the length of the data to be read, and the read storage address in RAM. The second enumeration member is used to abstractly declare the second original member and the second mapped member. If the length of the data stored in the target configuration member located by the second enumeration member is equal to the length of the data to be read, then the target RAM address of the target configuration member is obtained, and the target RAM address is used to store the second mapping member; The data in the target RAM address is copied to the read storage address to read the data of the second mapped member, and the data of the second mapped member is the same as the data of the second original member.

6. The data management method based on EEPROM as described in claim 1, characterized in that, The original members in the EEPROM are, in order, data BOOT, data HEAD, multiple intermediate data members, and data TAIL; The step of copying all data from the EEPROM to the mapped data block in RAM also includes: If the data BOOT in the mapped data block is different from the BOOT special word, then the EEPROM is determined to be a new EEPROM, and the data to be written is determined to be the BOOT special word, the HEAD special word, the TAIL special word and multiple first preset data, wherein the first preset data is used to assign values ​​to the intermediate data members; If the data BOOT in the mapped data block is the same as the BOOT special word, and the data HEAD in the mapped data block is different from the HEAD special word, then the data in the EEPROM is determined to be invalid, and the data to be written is determined to be the HEAD special word, the TAIL special word, and multiple second preset data, wherein the second preset data is used to assign values ​​to the intermediate data members; If the data BOOT in the mapped data block is the same as the BOOT special word, the data HEAD in the mapped data block is the same as the HEAD special word, and the data TAIL in the mapped data block is different from the TAIL special word, then the data in the EEPROM is determined to be invalid, and the data to be written is determined to be the TAIL special word and multiple second preset data.

7. A data management device based on EEPROM, characterized in that, The EEPROM-based data management device includes: An initialization module is used to copy all data in the EEPROM to a mapped data block in RAM, wherein the mapped members in the mapped data block correspond one-to-one with the original members in the EEPROM. The writing module is used to determine the first original member and the first mapped member corresponding to the data to be written, assign a value to the first mapped member with the data to be written, and assign a value to the first original member with the data of the first mapped member; The reading module is used to determine the second original member and the second mapped member corresponding to the data to be read, and to read the data of the second mapped member, wherein the data of the second mapped member is the same as the data of the second original member. The FLASH memory contains an enumeration table and a configuration information table. The enumeration members in the enumeration table are used to abstractly declare the mapping members in the mapping data block and their corresponding original members in the EEPROM. Each configuration member in the configuration information table is used to store the RAM address and data length of the corresponding mapping member, and the enumeration member is also used to locate the configuration member.

8. A data management device based on EEPROM, characterized in that, The EEPROM-based data management device includes a processor, a memory, and an EEPROM-based data management program stored in the memory and executable by the processor, wherein when the EEPROM-based data management program is executed by the processor, it implements the steps of the EEPROM-based data management method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that, The storage medium stores an EEPROM-based data management program, wherein when the EEPROM-based data management program is executed by the processor, it implements the steps of the EEPROM-based data management method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data writing method and device, computer equipment and storage medium

    CN111290973A

  • Data management method and device for storage chip

    CN116483281A