CN112527207A - Method and device for storing data in EEPROM - Google Patents

Method and device for storing data in EEPROM Download PDF

Info

Publication number
CN112527207A
CN112527207A CN202011505811.9A CN202011505811A CN112527207A CN 112527207 A CN112527207 A CN 112527207A CN 202011505811 A CN202011505811 A CN 202011505811A CN 112527207 A CN112527207 A CN 112527207A
Authority
CN
China
Prior art keywords
data
logic block
target
storage
eeprom
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011505811.9A
Other languages
Chinese (zh)
Inventor
刘均
李森
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Launch Technology Co Ltd
Original Assignee
Shenzhen Launch Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Launch Technology Co Ltd filed Critical Shenzhen Launch Technology Co Ltd
Priority to CN202011505811.9A priority Critical patent/CN112527207A/en
Publication of CN112527207A publication Critical patent/CN112527207A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0616Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The application discloses a method and a device for storing data in an EEPROM, comprising the following steps: receiving current real-time data corresponding to the target data type; determining the storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block; and saving the current real-time data to the next logic block adjacent to the target logic block in the EEPROM. The novel data are stored in the whole EEPROM in a circulating mode, and the data are not stored in the same logic block repeatedly, so that the phenomenon of bad blocks in the EEPROM is delayed, and the service life of the EEPROM is integrally prolonged.

Description

Method and device for storing data in EEPROM
Technical Field
The invention relates to the field of computer storage, in particular to a method and a device for storing data in an EEPROM.
Background
An EEPROM (Electrically Erasable Programmable read only memory) is widely used in an embedded system due to its characteristics of high reliability, ultra-long erasing times (for example, 100 ten thousand times), no data loss after power failure, and the like, and is used to store some important data that needs to be frequently stored.
In the existing using method, users usually rely on the characteristics of the EEPROM to ensure the reliability of data. Under the method, for 100 ten thousand times of erasing and writing, no problem may exist in common operation, but the frequent data is far from enough, for example, if the driving mileage of the vehicle is saved once by 0.1 kilometer, the driving mileage of the vehicle reaches 100 ten thousand times by 10 kilometers, but the vehicle must not travel 10 kilometers more, in the prior art, the driving mileage of the vehicle is intensively stored in a plurality of individual storage blocks in the EEPROM under the condition, and the storage blocks can generate bad block faults due to the fact that the storage blocks are close to the limit erasing and writing times, so that the service life of the whole EEPROM is greatly influenced.
For this reason, a method capable of improving the service life of the EEPROM as much as possible is required.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a method, a system, a device and a computer readable storage medium for storing data in an EEPROM, which can prolong the service life of the EEPROM. The specific scheme is as follows:
a data storage method in EEPROM comprises:
receiving current real-time data corresponding to the target data type;
determining the storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block;
and saving the current real-time data to the next logic block adjacent to the target logic block in the EEPROM.
Optionally, the method further includes:
storing the current real-time data into a corresponding standby logic block in a standby partition by using the storage position of the next logic block of the target logic block and the corresponding relation with the storage position in the standby partition;
and partitioning the storage space in the EEPROM in advance to obtain a main partition and a spare partition.
Optionally, the process of saving the current real-time data in the corresponding standby logical block in the standby partition by using the storage location of the next logical block of the target logical block and the corresponding relationship with the storage location in the standby partition includes:
storing the current real-time data into a corresponding standby logic block in a standby partition by using the storage position and the block length of the next logic block of the target logic block;
the block length is the number of storage blocks included in each partition, and the block lengths of the spare partition and the main partition are the same.
Optionally, after the storing the current real-time data in the corresponding standby logical block in the standby partition by using the storage location of the next logical block of the target logical block and the corresponding relationship with the storage location in the standby partition, the method further includes:
receiving a data reading instruction for reading mutually corresponding target storage data in the main partition and each standby partition in the EEPROM;
verifying the target storage data stored in each partition according to the data reading instruction;
if the target storage data stored in all the partitions are successfully verified, reading the target storage data;
and if the target storage data stored in any partition fails to be checked, reading the storage data stored in the most partitions.
Optionally, the determining a storage location of last history data stored in the EEPROM corresponding to the target data type to obtain a target history storage location includes:
determining the storage position of the historical data by utilizing the storage count of the current logic block and the adjacent logic block which point for the first time when the EEPROM is initialized in advance so as to obtain a target historical storage position;
and after the EEPROM stores data once, the stored count is increased by one, and the stored count and the stored data are stored in the same logic block.
Optionally, the method further includes:
s421: acquiring a first preservation count preserved in the current logic block;
s422: determining a second storage position of a second logic block adjacent to the current logic block by using the number of storage blocks occupied by the current logic block;
s423: judging whether the second logic block stores valid data or not by using the second storage position;
s424: if the valid data is stored, judging whether a second saving count in a second logic block is larger than the first saving count;
s425: if the second saving count is greater than the first saving count, re-executing steps S421 to S424 with the second logic block as a new current logic block until no valid data is stored in the second logic block or the second saving count is smaller than the first data saving count, and then identifying the current logic block as the first logic block in which data was last saved before the EEPROM was powered on;
and the first current logic block is the logic block pointed for the first time when the EEPROM is initialized, and the number of the current logic block is the same as that of the storage blocks in the second logic block.
Optionally, the process of saving the current real-time data to a next logic block adjacent to the target logic block in the EEPROM includes:
and saving the current real-time data to a next logic block adjacent to the target logic block by using the target historical storage position and the number of storage blocks included in the target logic block.
Optionally, the saving the current real-time data to a next logic block adjacent to the target logic block by using the target historical storage location and the number of storage blocks included in the target logic block includes:
obtaining a first storage position of a next logic block adjacent to the target logic block by using the target historical storage position and the number of storage blocks included in the target logic block;
and saving the current real-time data to a next logic block adjacent to the target logic block by using the first storage position.
Optionally, after receiving the current real-time data corresponding to the target data type, the method further includes:
acquiring the current operating temperature of the EEPROM;
judging whether the current operating temperature of the EEPROM exceeds a preset temperature threshold value or not;
if the current time is less than the preset time threshold, judging whether the time interval between the current time and the historical storage time for storing the historical data is less than the preset time threshold;
and if the current real-time data is smaller than the preset threshold value, storing the current real-time data to a memory buffer area.
The application also discloses a data storage device in the EEPROM, comprising:
a memory for storing a computer program;
a processor for executing said computer program to implement the data storage method in the EEPROM as described above.
In the present application, a data storage method in an EEPROM includes: receiving current real-time data corresponding to the target data type; determining the storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block; and saving the current real-time data to the next logic block adjacent to the target logic block in the EEPROM.
The novel data are stored in the whole EEPROM in a circulating mode, and the data are not stored in the same logic block repeatedly, so that the phenomenon of bad blocks in the EEPROM is delayed, and the service life of the EEPROM is integrally prolonged.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a schematic flowchart illustrating a data storage method in an EEPROM disclosed in an embodiment of the present application;
FIG. 2 is a flow chart illustrating another method for storing data in an EEPROM according to an embodiment of the present application;
FIG. 3 is a flow chart illustrating another method for storing data in an EEPROM according to an embodiment of the present application;
FIG. 4 is a flow chart illustrating another method for storing data in an EEPROM according to an embodiment of the present application;
FIG. 5 is a flow chart illustrating another method for storing data in an EEPROM according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a data storage system in an EEPROM disclosed in the embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application discloses a data storage method in an EEPROM (electrically erasable programmable read-only memory), and as shown in figure 1, the method comprises the following steps:
s11: receiving current real-time data corresponding to the target data type;
s12: and determining the storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining the logic block corresponding to the target historical storage position as a target logic block.
Specifically, in order to prolong the service life of the EEPROM storing the same data type, after receiving the current real-time data of the corresponding target data type, a logic block is not directly selected to store the current real-time data, but a storage location of the last historical data stored in the EEPROM corresponding to the target data type is determined first to obtain the target historical storage location. The historical data is the data stored in the EEPROM for the last time, and the data is the same as the target data type of the current real-time data.
Specifically, after the target history storage location is obtained, a specific logical block corresponding to the target history storage location may be found, and the logical block may be determined as the target logical block, where the target logical block is used to store history data, each logical block may include one or more physical storage blocks, and when history data is stored, storage space included in the logical block is not required to be completely occupied, but in order to reduce waste of storage space, one logical block may correspond to the minimum number of required storage blocks, for example, one history data is 6KB, and storage space of one storage block is 4KB, and the logical block storing one history data includes at least two storage blocks, one storage block may store 4KB history data, and another storage block may store another 2KB history data, so as to store a complete history data.
The storage block is a physical storage block in the EEPROM.
S13: and saving the current real-time data to the next logic block adjacent to the target logic block in the EEPROM.
Specifically, after the target logic block is determined, the current real-time data is stored in the next logic block adjacent to the target logic block, so that the data stored each time is ensured not to be repeatedly stored in the same logic block, namely, not to be repeatedly stored in the storage block corresponding to the logic block, and meanwhile, the current real-time data is always stored in the next logic block adjacent to the target logic block, so that the storage space in the whole EEPROM can be effectively and integrally utilized, the situation that the data is repeatedly stored in a plurality of logic blocks is avoided, the current real-time data is sequentially stored in each logic block in the EEPROM, the situation that the service life of each storage block is rapidly used up due to the fact that the individual storage blocks in the EEPROM are repeatedly erased in a concentrated mode when the data are stored is avoided, and the overall service life of the EEPROM is prolonged as much as possible.
It should be noted that, the storage space in the EEPROM may be pre-divided into a plurality of sequentially adjacent logic blocks by the size of the logic block required for storing the target data type, the first logic block is used as the next logic block adjacent to the last logic block to form a cycle of the storage space, and the current real-time data is cyclically stored in each logic block in the whole EEPROM, so as to achieve the effect of prolonging the service life of a single storage block, for example, each storage block may be erased and written 100 ten thousand times, and at present, the driving range of the vehicle needs to be repeatedly stored, if the driving range of the vehicle is stored once every 0.1 km, the driving range of the vehicle reaches 100 ten thousand times after 10 km driving, and at this time, by using the prior art, the storage block individually used for storing the driving range of the vehicle is damaged, so that the phenomenon of the damaged block occurs in the whole EEPROM, if the cycle saving method of the embodiment of the application is adopted, if the EEPROM includes 50 logic blocks, before the damage occurs, the number of times of erasing and writing can be changed to 50 × 100 ten thousand, obviously, the time of the occurrence of the bad block is greatly delayed, and the service life of the EEPROM is prolonged as a whole.
Therefore, the embodiment of the application stores new data in the whole EEPROM in a circulating manner, and the data are not repeatedly stored in the same logic block, so that the phenomenon of bad blocks in the EEPROM is delayed, and the service life of the EEPROM is integrally prolonged.
The embodiment of the application discloses a specific data storage method in an EEPROM, and compared with the previous embodiment, the embodiment further explains and optimizes the technical scheme. Referring to fig. 2, specifically:
s21: receiving current real-time data corresponding to the target data type;
s22: determining the storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block;
s23: storing the current real-time data to a next logic block adjacent to the target logic block in the EEPROM;
s24: and storing the current real-time data into the corresponding standby logical block in the standby partition by utilizing the storage position of the next logical block of the target logical block and the corresponding relation with the storage position in the standby partition.
Specifically, the whole storage space in the EEPROM is fully used by the cyclic saving, but the substantial service life of the EEPROM is not changed, so that a large number of bad blocks are likely to occur when the service life of the EEPROM is finally approached, data loss due to the bad blocks is avoided, the storage space in the EEPROM can be partitioned into blocks in advance to obtain a main partition and a spare partition, and after the current real-time data is stored in the main partition in S21 to S23, the storage position of the next logic block of the target logic block can be continuously used to find the corresponding storage position in the spare partition.
Specifically, the spare partition also includes a plurality of sequentially adjacent logical blocks, and the logical blocks of the spare partition and the main partition are also mutually continuous, for example, the EEPROM includes 6 logical blocks, and can be divided into two partitions on average, each partition includes 3 logical blocks, one partition is the main partition, and the other partition is the spare partition, the logical blocks corresponding to the main partition may be the first logical block to the third logical block in order, and the logical blocks corresponding to the spare partition may be the fourth logical block to the sixth logical block in order.
Further, the current real-time data can be stored in the corresponding standby logical block in the standby partition by using the storage location and the block length of the next logical block of the target logical block; the block length is the number of storage blocks included in each partition, and the block lengths of the spare partition and the main partition are the same.
For example, the EEPROM includes 6 logic blocks, the logic blocks corresponding to the main partition may be a first logic block to a third logic block in order, the logic blocks corresponding to the spare partition may be a fourth logic block to a sixth logic block in order, each logic block may include 2 memory blocks, the block length of one partition is 6, the memory location of the first logic block may correspond to the memory location of the first memory block being 1, the memory location of the fourth logic block is the memory location of the first logic block plus the block length, and 7 corresponds to the memory location of the first memory block in the fourth logic block.
Specifically, even if the number of logical blocks included in the main partition and the spare partition is different, the cyclic storage of data in the spare partition may be implemented by using the block length, for example, the main partition includes first to third logical blocks, the spare partition includes fourth and fifth logical blocks, the block length is 3, the storage location of the third logical block is 3, the storage location corresponding to the third logical block is 6, and the storage location of the fifth logical block in the spare partition is 5.
It is understood that a plurality of spare partitions, for example, one or two spare partitions, may be divided in the EEPROM, however, dividing too many spare partitions may reduce the amount of different data that can be simultaneously stored in the EEPROM, for this reason, one main partition and two spare partitions may be set as a preferred example, 3 partitions may equally divide the storage space in the EEPROM, so that logical blocks between the partitions can be in one-to-one correspondence, as shown in table 1, each Page corresponds to one storage block, pages 0 to 17 are consecutive 18 storage blocks in the EEPROM, pages 0 to 5 correspond to the main partition, pages 6 to 11 correspond to the first spare partition, pages 12 to 17 correspond to the third spare partition, and storage blocks between each partition are aligned.
TABLE 1
Page0 Page1 Page2 Page3 Page4 Page5
Page6 Page7 Page8 Page9 Page10 Page11
Page12 Page13 Page14 Page15 Page16 Page17
The embodiment of the application also discloses a specific data storage method in the EEPROM, and compared with the previous embodiment, the embodiment further explains and optimizes the technical scheme. Referring to fig. 3, a further improvement of the above embodiment is provided, the method comprising:
s31: and receiving a data reading instruction for reading the target storage data corresponding to each other in the main partition and each spare partition in the EEPROM.
Specifically, when the target storage data in the main partition is read, the corresponding target storage data in each spare partition is also read, and under a theoretical condition, the target storage data stored in each partition should be consistent.
S32: and checking the target storage data stored in each partition according to the data reading instruction.
Specifically, after a plurality of data are stored in the main partition and the spare partition, since it cannot be guaranteed that any partition is intact, data verification is required when data are read, and it is avoided that wrong target storage data are read due to data loss caused by bad blocks.
S33: and if the target storage data stored in all the partitions are successfully verified, reading the target storage data.
Specifically, the target storage data may be checked by using a checksum of 1 byte in the target storage data.
S34: and if the target storage data stored in any partition fails to be checked, reading the storage data stored in the most partitions.
Specifically, if the target storage data stored in any partition fails to be checked, the storage data stored in the partition with the most number is read, and since data corruption is a small probability event, reading the storage data with the largest storage amount can ensure that the correct target storage data is read.
For example, the EEPROM includes 3 partitions, a main partition, a first spare partition, and a second spare partition, the target storage data is a, the storage data corresponding to the target storage data in the first spare partition becomes a1, and the main partition and the second spare partition are the same as the storage data corresponding to the target storage data, and there are 2 partitions, storage data that is saved in the most partitions in only 1 partition as compared to a1, so the storage data in the main partition or the second spare partition is read as the target storage data.
The embodiment of the application discloses a specific data storage method in an EEPROM, and compared with the embodiment, the embodiment further explains and optimizes the technical scheme. Referring to fig. 4, specifically:
s41: receiving current real-time data corresponding to the target data type;
s42: the storage positions of historical data are determined by utilizing the storage counts of the current logic block and the adjacent logic blocks pointed for the first time during initialization of the EEPROM in advance so as to obtain the target historical storage position, and the logic block corresponding to the target historical storage position is determined as the target logic block.
Specifically, when the EEPROM is powered on for the first time, initialization is required, and the target history storage location of the last stored history data is determined again, so as to store the latest data. When the EEPROM is initialized, the first logic block in the EEPROM, namely the current logic block, is pointed, whether the current logic block is the logic block for storing data for the last time is judged according to the storage count recorded in each logic block, the logic block for storing data for the last time can be found by traversing the logic blocks in the EEPROM, then the storage position of historical data can be determined by sequentially storing the logic blocks so as to obtain a target historical storage position, and the logic block corresponding to the target historical storage position is determined as the target logic block or the logic block for storing data for the last time is determined as the target logic block.
After the data is stored in the EEPROM once, the storage count is incremented by one, and the storage count and the stored data are stored in the same logic block, where the storage count may be represented by Index and is a 4-byte unsigned integer.
S43: and saving the current real-time data to the next logic block adjacent to the target logic block in the EEPROM.
Further, the process of initializing the EEPROM mentioned in S42 may specifically include the process of initializing and searching the last saved logical block in S421 to S425; wherein the content of the first and second substances,
s421: a first preserved count saved in the current logical block is obtained.
Specifically, the first current logic block is a logic block pointed for the first time when the EEPROM is initialized, and is usually the first logic block of the EEPROM, and the first storage count stored in the current logic block is obtained for subsequent determination.
S422: and determining a second storage position of a second logic block adjacent to the current logic block by using the number of the storage blocks occupied by the current logic block.
Specifically, although the logic blocks are adjacent to each other, in the actual location search process, the actual storage location of the corresponding storage block still needs to be encountered, and since the current logic block is pointed to, the storage location of the next first storage block of the current logic block can be known, and the second storage location of the second logic block adjacent to the current logic block can be obtained by adding the storage location of the first storage block to the number of storage blocks in the current logic block.
For example, the storage location of the first storage block of the current logical block is 1, the current logical block includes 2 storage blocks, and the second storage location of the adjacent second logical block is 3, that is, the storage location of the first storage block in the second logical block.
S423: and judging whether the second logic block stores valid data or not by using the second storage position.
Specifically, after the second storage location is obtained, the second logical block is found, so that it can be determined whether valid data is stored in the second logical block, because the second logical block may not be used yet and never stores data, and if the second logical block does not store data, it can be said that the current logical block is the logical block that stores data for the last time.
S424: if the valid data is stored, whether the second saving count in the second logic block is larger than the first saving count is judged.
Specifically, if valid data is stored in the second logic block, it may be that old data stored in the second logic block in the past, that is, the old data was stored in all the logic blocks in the EEPROM once in the previous storage, and this time, the second storage is performed, so that the old data may be stored in the second logic block instead of the latest data. Therefore, it is also necessary to determine whether the second saving count in the second logical block is greater than the first saving count, and if it is smaller than the first saving count, it indicates that the data saved in the second logical block is data saved too early, and then indicates that the data in the current logical block is data saved last time, because new data is not saved in the next adjacent second logical block.
S425: if the second saving count is greater than the first saving count, the second logic block is taken as a new current logic block to re-execute steps S421 to S424 until no valid data is stored in the second logic block or the second saving count is less than the first data saving count, and the current logic block is determined as the first logic block in which data is last saved before the EEPROM is powered on.
Specifically, if the second save count is greater than the first save count, which indicates that the second logic block stores data saved later than the current logic block, the second logic block is taken back to S421 as a new current logic block, and the next adjacent logic block is compared again until no valid data is stored in the second logic block or the second save count is less than the first data save count, and the current logic block is determined as the first logic block in which data was last saved before the EEPROM was powered on.
The number of the storage blocks included in the current logic block and the second logic block is the same, the number of the storage blocks required for storing data each time is the same, and the storage space of each logic block is the same, so that the next logic block can be found by matching the number of the storage blocks with the storage position.
It should be noted that, if the current real-time data is the data that is first saved after the EEPROM is initialized, the first logic block that is finally found after the EEPROM is initialized is the target logic block, and if the current real-time data is not the data that is first saved after the EEPROM is initialized, in the subsequent data saving process, the data is saved until the data is saved to the target logic block, with the first logic block as the starting point, and then the current update data is stored according to the target history storage location of the target logic block.
The embodiment of the application also discloses a data storage method in the EEPROM, and as shown in fig. 5, the method includes:
s51: receiving current real-time data corresponding to the target data type;
s52: and acquiring the current operating temperature of the EEPROM.
Specifically, the EEPROM itself may be heated after storing data for a plurality of times, and an excessively high temperature may cause a speed at which the EEPROM stores data, and there is a possibility that the data storage fails, and for this reason, the current operating temperature of the EEPROM is detected so as to be adjusted according to the current operating temperature of the EEPROM.
S53: judging whether the current operating temperature of the EEPROM exceeds a preset temperature threshold value or not;
s54: if the current time is less than the preset time threshold, judging whether the time interval between the current time and the historical storage time for storing the historical data is less than the preset time threshold;
s55: and if the current real-time data is less than the preset threshold, storing the current real-time data to a memory buffer area.
Specifically, if the current operating temperature of the EEPROM exceeds a preset temperature threshold, it is determined that the EEPROM is overheated or approaches an overheating upper limit, and at this time, it is determined whether the time interval between the current time and the last saved historical saving time is smaller than the preset time threshold, and if the time interval is smaller than the preset time threshold, it is determined that the saving is too frequent, the EEPROM may be continuously heated due to the continuous saving, which is not beneficial to the stable operation of the EEPROM.
Specifically, if the EEPROM temperature drops, the current real-time data in the memory buffer may be saved back to the EEPROM again, and the saving process is the same as S11 to S13.
S56: if the temperature threshold value is not exceeded or the time threshold value is not less than, determining the storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block;
s57: and saving the current real-time data to a next logic block adjacent to the target logic block by using the target historical storage position and the number of storage blocks included in the target logic block.
Specifically, the first storage location of the next logic block adjacent to the target logic block may be obtained by using the target history storage location and the number of storage blocks included in the target logic block, and then the current real-time data is stored in the next logic block adjacent to the target logic block by using the first storage location, so as to complete data storage without performing a process of searching for the last stored first logic block required in initialization.
It is understood that, before the EEPROM is powered down, if the current real-time data is still stored in the memory buffer, the current real-time data may be restored to the EEPROM according to the processes from S11 to S13.
Correspondingly, the embodiment of the application also discloses a working process of the data storage method in the EEPROM under a specific application scene, and the working process comprises the following steps:
taking an EEPROM recording the mileage of the vehicle as an example, the mileage data is saved every 0.1 km traveled by the vehicle, and the current mileage data is saved into the next logic block of the logic block used when the mileage data was saved last time, for example, the current mileage data is 52.3, the mileage data saved last time is 52.2, and the current mileage data is saved into the fifth logic block, and then the current mileage data is saved into the sixth logic block.
Meanwhile, after the current mileage data is saved in the sixth logical block, the current mileage data can also be saved in the first standby partition and the second standby partition at the same time, the first standby partition obtains a storage location 23 according to the block length 12 of the main partition, that is, each block includes 12 storage blocks, each logical block includes 2 storage blocks, the mileage data needs to use 2 storage blocks, the first standby partition obtains a storage location 23 according to the storage location 11 of the sixth logical block, the current mileage data is saved to the twelfth logical block corresponding to the twelfth logical block in the first standby partition, the second standby partition finds a storage location 35 of the eighteenth logical block by using the block length 12 of the first standby partition and the storage location 23 of the twelfth logical block, and the current mileage data is saved to the eighteenth logical block.
And before saving the current mileage data, the current operating temperature and the saving time interval of the EEPROM can be detected, if the temperature is exceeded and the time interval is smaller than the temperature, the current mileage data is saved into the memory buffer area, and during the period that the vehicle stops to be closed and power off is carried out, all the remaining current mileage data in the memory buffer area is saved into the EEPROM.
Meanwhile, when the vehicle is started, the EEPROM is initialized, and the first logic block for storing the history count for the last time is determined by using the stored count in each logic block.
Correspondingly, the embodiment of the present application further discloses a data storage system in an EEPROM, as shown in fig. 6, the system includes:
the data receiving module 11 is configured to receive current real-time data corresponding to a target data type;
a logic block determining module 12, configured to determine a storage location of last history data stored in the EEPROM corresponding to the target data type to obtain a target history storage location, and determine a logic block corresponding to the target history storage location as a target logic block;
and the data storage module 13 is used for storing the current real-time data to the next logic block which is adjacent to the target logic block in the EEPROM.
Therefore, the embodiment of the application stores new data in the whole EEPROM in a circulating manner, and the data are not repeatedly stored in the same logic block, so that the phenomenon of bad blocks in the EEPROM is delayed, and the service life of the EEPROM is integrally prolonged.
Specifically, the system also comprises a data backup module; wherein the content of the first and second substances,
the data backup module is used for storing the current real-time data into the corresponding standby logical block in the standby partition by utilizing the storage position of the next logical block of the target logical block and the corresponding relation with the storage position in the standby partition;
the method comprises the steps of carrying out block division on a storage space in an EEPROM in advance to obtain a main partition and a spare partition.
Specifically, the data backup module may be specifically configured to store the current real-time data in a corresponding standby logical block in the standby partition by using a storage location and a block length of a next logical block of the target logical block;
the block length is the number of storage blocks included in each partition, and the block lengths of the spare partition and the main partition are the same.
Specifically, the system also comprises a reading instruction receiving module, a data checking module, a first data reading module and a second data reading module; wherein the content of the first and second substances,
the reading instruction receiving module is used for receiving a data reading instruction for reading target storage data corresponding to each other in a main partition and each standby partition in the EEPROM;
the data checking module is used for checking the target storage data stored in each partition according to the data reading instruction;
the first data reading module is used for reading the target storage data if the target storage data stored in all the partitions are successfully verified;
and the second data reading module is used for reading the storage data stored in the most partition area if the target storage data stored in any partition fails to be checked.
Specifically, the logic block determining module 12 is specifically configured to determine a storage location of the historical data by using the storage count of the current logic block and the adjacent logic block pointed for the first time during initialization of the EEPROM in advance, so as to obtain a target historical storage location;
after the EEPROM stores data once, the stored count is increased by one, and the stored count and the stored data are stored in the same logic block.
Specifically, the system further comprises a first counting acquisition module, a storage position determination module, an effective data judgment module, a counting judgment module and a logic block determination module 12; wherein the content of the first and second substances,
a first count acquisition module, configured to acquire a first saved count saved in the current logic block;
the storage position determining module is used for determining a second storage position of a second logic block adjacent to the current logic block by using the number of the storage blocks occupied by the current logic block;
the effective data judging module is used for judging whether the second logic block stores effective data or not by utilizing the second storage position;
the count judging module is used for judging whether a second saving count in the second logic block is larger than the first saving count or not if the valid data are stored;
the logic block determination module 12 is configured to, if the second saving count is greater than the first saving count, call the second logic block as a new current logic block to the first count obtaining module again until no valid data is stored in the second logic block or the second saving count is smaller than the first data saving count, and determine the current logic block as the first logic block in which data is last saved before the EEPROM is powered on;
the first current logic block is a logic block pointed for the first time when the EEPROM is initialized, and the number of the current logic block is the same as that of the storage blocks in the second logic block.
Specifically, the data storage module 13 is specifically configured to store the current real-time data to a next logic block adjacent to the target logic block by using the target historical storage location and the number of storage blocks included in the target logic block.
Specifically, the data storage module 13 includes a storage location obtaining unit and a data storage unit; wherein the content of the first and second substances,
a storage location obtaining unit, configured to obtain, by using the target historical storage location and the number of storage blocks included in the target logical block, a first storage location of a next logical block adjacent to the target logical block;
and the data storage unit is used for storing the current real-time data to the next logic block adjacent to the target logic block by using the first storage position.
The system comprises an operation temperature acquisition module, a temperature judgment module, a time interval judgment module and a memory storage module; wherein the content of the first and second substances,
the operating temperature acquisition module is used for acquiring the current operating temperature of the EEPROM;
the temperature judging module is used for judging whether the current operating temperature of the EEPROM exceeds a preset temperature threshold value;
the time interval judging module is used for judging whether the time interval between the current time and the historical storage time for storing the historical data is smaller than a preset time threshold value or not if the time interval exceeds the preset time threshold value;
and the memory storage module is used for storing the current real-time data into the memory buffer area if the current real-time data is smaller than the current real-time data.
Specifically, the system further comprises a power-off saving module; wherein the content of the first and second substances,
and the power-off storage module is used for storing the current real-time data into the EEPROM before the EEPROM is powered off if the current real-time data is stored in the memory buffer area.
In addition, the embodiment of the present application further discloses a data storage device in an EEPROM, including:
a memory for storing a computer program;
a processor for executing a computer program to implement the data storage method in the EEPROM as described above.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The technical content provided by the present application is described in detail above, and the principle and the implementation of the present application are explained in the present application by applying specific examples, and the description of the above examples is only used to help understanding the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method for storing data in an EEPROM (electrically erasable programmable read-Only memory), comprising the steps of:
receiving current real-time data corresponding to the target data type;
determining the storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block;
and saving the current real-time data to the next logic block adjacent to the target logic block in the EEPROM.
2. The method of claim 1, further comprising:
storing the current real-time data into a corresponding standby logic block in a standby partition by using the storage position of the next logic block of the target logic block and the corresponding relation with the storage position in the standby partition;
and partitioning the storage space in the EEPROM in advance to obtain a main partition and a spare partition.
3. The method according to claim 2, wherein the step of saving the current real-time data to the corresponding spare logical block in the spare partition by using the storage location of the next logical block of the target logical block and the corresponding relationship with the storage location in the spare partition comprises:
storing the current real-time data into a corresponding standby logic block in a standby partition by using the storage position and the block length of the next logic block of the target logic block;
the block length is the number of storage blocks included in each partition, and the block lengths of the spare partition and the main partition are the same.
4. The method according to claim 2, wherein after storing the current real-time data in the corresponding spare logical block in the spare partition by using the storage location of the next logical block of the target logical block and the corresponding relationship with the storage location in the spare partition, the method further comprises:
receiving a data reading instruction for reading mutually corresponding target storage data in the main partition and each standby partition in the EEPROM;
verifying the target storage data stored in each partition according to the data reading instruction;
if the target storage data stored in all the partitions are successfully verified, reading the target storage data;
and if the target storage data stored in any partition fails to be checked, reading the storage data stored in the most partitions.
5. The method as claimed in claim 1, wherein the step of determining the storage location of the last historical data stored in the EEPROM corresponding to the target data type to obtain the target historical storage location comprises:
determining the storage position of the historical data by utilizing the storage count of the current logic block and the adjacent logic block which point for the first time when the EEPROM is initialized in advance so as to obtain a target historical storage position;
and after the EEPROM stores data once, the stored count is increased by one, and the stored count and the stored data are stored in the same logic block.
6. The method of claim 5, further comprising:
s421: acquiring a first preservation count preserved in the current logic block;
s422: determining a second storage position of a second logic block adjacent to the current logic block by using the number of storage blocks occupied by the current logic block;
s423: judging whether the second logic block stores valid data or not by using the second storage position;
s424: if the valid data is stored, judging whether a second saving count in a second logic block is larger than the first saving count;
s425: if the second saving count is greater than the first saving count, re-executing steps S421 to S424 with the second logic block as a new current logic block until no valid data is stored in the second logic block or the second saving count is smaller than the first data saving count, and then identifying the current logic block as the first logic block in which data was last saved before the EEPROM was powered on;
and the first current logic block is the logic block pointed for the first time when the EEPROM is initialized, and the number of the current logic block is the same as that of the storage blocks in the second logic block.
7. The method for storing data in EEPROM according to any one of claims 1 to 6, wherein the process of saving the current real-time data to the next logic block adjacent to the target logic block in the EEPROM comprises:
and saving the current real-time data to a next logic block adjacent to the target logic block by using the target historical storage position and the number of storage blocks included in the target logic block.
8. The method according to claim 7, wherein the step of saving the current real-time data to the next adjacent logic block relative to the target logic block by using the target historical storage location and the number of storage blocks included in the target logic block comprises:
obtaining a first storage position of a next logic block adjacent to the target logic block by using the target historical storage position and the number of storage blocks included in the target logic block;
and saving the current real-time data to a next logic block adjacent to the target logic block by using the first storage position.
9. The method for storing data in EEPROM according to any one of claims 1 to 6, wherein after receiving the current real-time data corresponding to the target data type, further comprising:
acquiring the current operating temperature of the EEPROM;
judging whether the current operating temperature of the EEPROM exceeds a preset temperature threshold value or not;
if the current time is less than the preset time threshold, judging whether the time interval between the current time and the historical storage time for storing the historical data is less than the preset time threshold;
and if the current real-time data is smaller than the preset threshold value, storing the current real-time data to a memory buffer area.
10. A data storage device in an EEPROM, comprising:
a memory for storing a computer program;
a processor for executing said computer program to implement the method of data storage in EEPROM as claimed in any one of claims 1 to 9.
CN202011505811.9A 2020-12-18 2020-12-18 Method and device for storing data in EEPROM Pending CN112527207A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011505811.9A CN112527207A (en) 2020-12-18 2020-12-18 Method and device for storing data in EEPROM

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011505811.9A CN112527207A (en) 2020-12-18 2020-12-18 Method and device for storing data in EEPROM

Publications (1)

Publication Number Publication Date
CN112527207A true CN112527207A (en) 2021-03-19

Family

ID=75001446

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011505811.9A Pending CN112527207A (en) 2020-12-18 2020-12-18 Method and device for storing data in EEPROM

Country Status (1)

Country Link
CN (1) CN112527207A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113660180A (en) * 2021-07-30 2021-11-16 鹏城实验室 Data storage method, device, terminal and storage medium
CN113849338A (en) * 2021-09-29 2021-12-28 东风汽车集团股份有限公司 Combined instrument total mileage storage device and method

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130132640A1 (en) * 2011-11-18 2013-05-23 Phison Electronics Corp. Data writing method, and memory controller and memory storage apparatus using the same
EP2602707A2 (en) * 2011-12-05 2013-06-12 Seagate Technology LLC Environmental-based device operation
CN103514177A (en) * 2012-06-20 2014-01-15 盛趣信息技术(上海)有限公司 Data storage method and system
CN104484280A (en) * 2014-12-25 2015-04-01 重庆邮电大学 Automobile mileage access system
CN107797765A (en) * 2017-09-26 2018-03-13 昆明理工大学 A kind of method for extending electric erasable memory element service life
CN109358814A (en) * 2018-10-17 2019-02-19 天津易众腾动力技术有限公司 A kind of method of EEPROM storage
CN111966287A (en) * 2020-08-07 2020-11-20 深圳移航通信技术有限公司 Data storage method, electronic device and storage medium
CN112000513A (en) * 2020-08-20 2020-11-27 北京浪潮数据技术有限公司 Computer and VPD data operation method, device and storage medium thereof

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130132640A1 (en) * 2011-11-18 2013-05-23 Phison Electronics Corp. Data writing method, and memory controller and memory storage apparatus using the same
EP2602707A2 (en) * 2011-12-05 2013-06-12 Seagate Technology LLC Environmental-based device operation
CN103176748A (en) * 2011-12-05 2013-06-26 希捷科技有限公司 Environmental-based device operation
CN103514177A (en) * 2012-06-20 2014-01-15 盛趣信息技术(上海)有限公司 Data storage method and system
CN104484280A (en) * 2014-12-25 2015-04-01 重庆邮电大学 Automobile mileage access system
CN107797765A (en) * 2017-09-26 2018-03-13 昆明理工大学 A kind of method for extending electric erasable memory element service life
CN109358814A (en) * 2018-10-17 2019-02-19 天津易众腾动力技术有限公司 A kind of method of EEPROM storage
CN111966287A (en) * 2020-08-07 2020-11-20 深圳移航通信技术有限公司 Data storage method, electronic device and storage medium
CN112000513A (en) * 2020-08-20 2020-11-27 北京浪潮数据技术有限公司 Computer and VPD data operation method, device and storage medium thereof

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113660180A (en) * 2021-07-30 2021-11-16 鹏城实验室 Data storage method, device, terminal and storage medium
CN113660180B (en) * 2021-07-30 2023-11-28 鹏城实验室 Data storage method, device, terminal and storage medium
CN113849338A (en) * 2021-09-29 2021-12-28 东风汽车集团股份有限公司 Combined instrument total mileage storage device and method
CN113849338B (en) * 2021-09-29 2024-03-01 东风汽车集团股份有限公司 Combined instrument total mileage storage device and method

Similar Documents

Publication Publication Date Title
US9612954B2 (en) Recovery for non-volatile memory after power loss
CN110175001B (en) NOR-FLASH data storage method, computer equipment and storage medium
CN103440205B (en) A kind of set top box data storage method and device
CN112527207A (en) Method and device for storing data in EEPROM
CN106155915B (en) Data storage processing method and device
CN102890657A (en) Method for reducing data read-write errors of EEPROM (electrically erasable programmable read-only memory)
CN102024502B (en) Flash device testing method and device as well as board and network equipment
CN107239411B (en) Memory management method and system for vehicle-mounted controller
CN112817527A (en) Power failure data storage method, single chip microcomputer and computer readable storage medium
CN112631516B (en) FLASH file management system with service life management function
CN104282342A (en) Flash memory device, memory controller and control method of flash memory
CN115292266B (en) High-reliability log storage method based on memory
CN104978148A (en) Data writing method and device and data reading method and device
CN103984506A (en) Method and system for data writing of flash memory storage equipment
CN102929794A (en) Storage method for electrically erasable programmable read only memory (EEPROM)
CN105446664A (en) Memory file storage method and storage apparatus
CN104978154A (en) Cache operation-based flash rapid read-write method and system
CN110989931A (en) Bad block processing method, device and equipment for storage equipment and storage medium
US7539905B2 (en) Method of and apparatus for detecting an error in writing to persistent memory
CN106293622A (en) A kind of self-healing over-the-air upgrade method of power-off and device
CN105095101A (en) Method and device for writing data in memorizer and intelligent card
CN113434438B (en) Method for prolonging FLASH write-in life of smart card
CN113918485B (en) Method, device, equipment and storage medium for preventing flash memory data from being lost
CN107908500B (en) Bad block identification method and device
CN109947364A (en) A kind of method for storing real-time data in FLASH/EEPROM

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination