CN107315543B - Method and device for reading and writing data in EC (embedded control) memory - Google Patents

Method and device for reading and writing data in EC (embedded control) memory Download PDF

Info

Publication number
CN107315543B
CN107315543B CN201710530174.2A CN201710530174A CN107315543B CN 107315543 B CN107315543 B CN 107315543B CN 201710530174 A CN201710530174 A CN 201710530174A CN 107315543 B CN107315543 B CN 107315543B
Authority
CN
China
Prior art keywords
data
index
block
memory
writing
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.)
Active
Application number
CN201710530174.2A
Other languages
Chinese (zh)
Other versions
CN107315543A (en
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.)
Hefei Lianbao Information Technology Co Ltd
Original Assignee
Hefei Lianbao Information 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 Hefei Lianbao Information Technology Co Ltd filed Critical Hefei Lianbao Information Technology Co Ltd
Priority to CN201710530174.2A priority Critical patent/CN107315543B/en
Publication of CN107315543A publication Critical patent/CN107315543A/en
Application granted granted Critical
Publication of CN107315543B publication Critical patent/CN107315543B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/061Improving I/O performance
    • 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/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 invention discloses a method and a device for reading and writing data in an EC memory, wherein the method comprises write operation, and the write operation comprises the following steps: respectively setting an index section and a plurality of data sections in the memory, wherein a plurality of data blocks are arranged in the data sections to store data, a plurality of index blocks are arranged in the index section, and the index blocks correspond to the data blocks; when data are written into the memory, writing the data into the data blocks of the corresponding data sections according to the indexes of the index blocks; and updating the index block according to the position information of the data written into the memory. When the method is used for reading and writing the EC memory, the method can only perform the reading and writing operation on the data blocks of a partial data area of the memory, does not perform the operation on other data sections, and does not perform the operation on other data blocks of the same data section, so that the erasing frequency of the memory is reduced, and the service life of the memory is prolonged.

Description

Method and device for reading and writing data in EC (embedded control) memory
Technical Field
The present invention relates to the field of data processing, and in particular, to a method and an apparatus for reading and writing data in an EC memory.
Background
When using an intelligent device such as a notebook computer, it is necessary to perform a read/write operation on a memory of an Embedded Controller (EC), for example, to write or read data into or from an EEPROM chip of the EC, whereas when performing a read/write operation on a memory of the EC at present, it is necessary to perform a large-scale erase or write operation on the memory regardless of the amount of data to be read or written, and the number of times of erasing the memory is limited due to the design life, so that a large number of read/write operations may cause a reduction in the life of the memory.
Disclosure of Invention
The embodiment of the invention aims to provide a method and a device for reading and writing data in an EC (embedded computer) memory, which can effectively reduce the times of reading and writing the data in the memories of the EC chips and the like of the computer and other intelligent equipment in the working process of the computer and other intelligent equipment, thereby prolonging the service life of the EC chips and the like on the premise of correct data reading and writing.
In order to solve the technical problem, the embodiment of the invention adopts the following technical scheme: a method of reading and writing data in a memory of an EC, the method comprising a write operation comprising:
respectively setting an index section and a plurality of data sections in the memory, wherein a plurality of data blocks are arranged in the data sections to store data, a plurality of index blocks are arranged in the index section, and the index blocks correspond to the data blocks;
when data are written into the memory, writing the data into the data blocks of the corresponding data sections according to the indexes of the index blocks;
and updating the index block according to the position information of the data written into the memory.
Preferably, writing data onto the data block of the corresponding data segment according to the index of the index block comprises:
acquiring information of a first data section storing effective data according to the index of the index block;
and writing data onto a second data sector adjacent to the first data sector according to the information of the first data sector, wherein the data stored in the second data sector is invalid.
Preferably, when all the data segments store valid data and continue to perform data writing operation on the memory, the valid data is moved to a preset data block of the first data segment, and the index block is updated correspondingly; and writing data to the second data segment according to the updated index of the index block.
Preferably, the index block is represented by hexadecimal values, which correspond to binary values, and the data block is indexed according to a change in bits of the binary values.
Preferably, the method further comprises a read operation, the read operation comprising: and reading the content of the index block, and reading data from the data block of the corresponding data section according to the index of the index block.
The embodiment of the invention also provides a device for reading and writing data in the memory of the EC, which comprises a writing device, wherein the writing device comprises a setting module, a writing module and an updating module;
the setting module is configured to set an index section and a plurality of data sections in the memory respectively, and set a plurality of data blocks in the data sections to store data, set a plurality of index blocks in the index section, the index blocks corresponding to the data blocks;
the writing module is configured to write data into the data blocks of the corresponding data segments according to the indexes of the index blocks when the data are written into the memory;
the updating module is connected with the writing module and is configured to update the index block according to the position information of the data written into the memory by the writing module.
Preferably, the writing module includes an obtaining unit configured to obtain information of a first data segment storing valid data according to the index of the index block, so that the writing module writes data onto a second data segment adjacent to the first data segment according to the information of the first data segment, where the data stored in the second data segment is invalid.
Preferably, the writing device further includes a transfer module, the transfer module is respectively connected to the writing module and the updating module, and the transfer module is configured to, when valid data is stored in all the data segments and the writing module continues to perform data writing operation on the memory, move the valid data to a preset data block of the first data segment, and drive the updating module to update the corresponding index block, so that the writing module writes data into the second data segment according to the updated index of the index block.
Preferably, the index block is represented by hexadecimal values, which correspond to binary values, and the data block is indexed according to a change in bits of the binary values.
Preferably, the read-write device further includes a reading device configured to read the content of the index block, and read data from the data block of the corresponding data segment according to the index of the index block.
The embodiment of the invention has the beneficial effects that: when the EC memory is read and written, the read and write operations can be performed only on the data blocks of a partial data area of the EC memory, other data sections are not operated, other data blocks of the same data section are not operated, the erasing frequency of the EC memory is reduced, and the service life of the EC memory is prolonged.
Drawings
FIG. 1 is a flow chart of a write operation of an embodiment of the present invention;
FIG. 2 is a flow chart of writing data onto a data block according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a writing apparatus according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a device for reading and writing data in the memory of the EC according to an embodiment of the present invention;
FIG. 5 is a specific flow chart of a write operation according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating another specific process of a write operation according to an embodiment of the present invention;
FIG. 7 is a flowchart of a read operation according to an embodiment of the present invention.
Description of the reference numerals
1-write device 2-setup module 3-write module
4-update module 5-transfer module 6-reading device
7-memory
Detailed Description
In order that those skilled in the art will better understand the present invention, the following detailed description of the embodiments of the present invention refers to the accompanying drawings, but the present invention is not limited thereto.
The method for reading and writing data in the memory 7 of the EC of the embodiment of the present invention can reduce the number of times of reading and writing data in the memory 7 of the EC chip, and particularly, when the memory 7 is written, only a partial area of the memory 7 can be written, and the storage medium of the whole memory 7 is avoided, so as to prolong the service life of the EC chip, and the method includes a writing operation, as shown in fig. 1, the writing operation includes:
s1, respectively setting an index section and a plurality of data sections in the memory 7, wherein the data sections are provided with a plurality of data blocks for storing data, the index section is provided with a plurality of index blocks, and the index blocks correspond to the data blocks. The memory 7 is a memory 7 of a component such as an EC of the smart device, for example, an EEPROM or a flash ROM of the EC, and it is necessary to perform a read/write operation on the memory 7 during an operation of the EC. In the present embodiment, a plurality of data sectors are provided in the memory 7, each of which can store data, and data can be written into each data sector, specifically, data can be written onto a data block, respectively, when a write operation is performed on the memory 7. In this embodiment, when writing to the memory 7, the contents of the index segment need to be read first, and a plurality of index blocks are provided in the index segment, each index block is represented in the form of a number, a letter, a character string, or the like, and can be mapped to a certain data block of a certain data segment through the index block. In one embodiment, the index blocks can be mapped to a specific data block of a certain data segment according to a preset specification, for example, a first index block can only be mapped to a first data block of the data segment, a second index block can only be mapped to a second data block of the data segment, and the like; in another embodiment, the amount of information of the index chunk may be increased in advance so that the position of the data chunk to which the index chunk is mapped may be varied.
S2, when writing data into the memory 7, the data is written to the data block of the corresponding data segment according to the index of the index block. Since the index block can be mapped to a certain data block of a certain data segment, the data to be written can be written to the appropriate data block according to the index of the index block, and the original valid data in the memory 7 is not overwritten. What is important is that writing operation can be performed only on one data block according to the index of the index block under a general condition, and the data blocks of other data segments are not operated, and other data blocks of the same data segment are not operated, so that the workload is undoubtedly reduced, the erasing times of the memory 7 are reduced, and the service life of the memory 7 is prolonged.
S3, the index block is updated according to the location information of the data written in the memory 7. Each time a write operation is completed, the data in the data block is changed, and at this time, the index block needs to be indexed according to the new data storage condition, that is, the index block needs to be updated according to the location information of the data written into the memory 7, so that the content of the index block is new, and when the write operation is performed again, the write operation can be performed according to the index of the new index block. For example, the index block indicates which data blocks of which data segments are valid data, which can be avoided during the write operation, and the pre-written data can be written into other empty data segments or data blocks, or the pre-written data can be written into data blocks storing only invalid data, and the data blocks storing the valid data are not written while avoiding the valid data, thereby reducing the number of times of erasing the memory 7 as a whole.
In one embodiment of the present invention, as shown in fig. 2, writing data onto a data block of a corresponding data segment according to the index of the index block includes:
and S21, acquiring the information of the first data section storing the effective data according to the index of the index block. In one embodiment, as long as valid data is stored on a data block, the data segment in which the data block is located is considered as a first data segment in which valid data is stored; in another embodiment, the data block is considered to be the first data block storing valid data only when all data blocks of the data block store valid data. The information of the first data section comprises information such as an ID number of the first data section, the number of data blocks or the condition of stored valid data, and the position of the first data section can be determined after the information of the first data section is acquired, so that data is not written into the first data section in which the valid data is stored in a writing operation any more, and otherwise, a writing error or data loss can be caused. In one embodiment, when the information of the first data segment is obtained according to the index of the index block, the information of the first data segment can be obtained by sequentially using each index block according to the arrangement order of the index blocks, so that the first data segment can be found according to the preset judgment step.
And S22, writing data to a second data sector adjacent to the first data sector according to the information of the first data sector, wherein the data stored in the second data sector is invalid. The writing mode can sequentially write data in appropriate data sectors without causing disordered arrangement of valid data, and for example, the data can be written in the corresponding data sectors in the order of increasing ID numbers of the data sectors.
In an embodiment of the present invention, when all the data segments store valid data and continue to write data into the memory 7, the valid data is moved to the data block of the preset first data segment, and the index block is updated correspondingly; and writing the data onto a second data section according to the index of the updated index block, wherein the second data section does not store any valid data. In this step, in the case where all the data segments store valid data (not all the data blocks in all the data segments store valid data) and the writing operation is performed on the memory 7, the data blocks storing valid data may be moved according to a preset rule, so that a space is made in the data segments to accept the writing operation again, thereby preventing a data writing error or the valid data from being overwritten.
To further illustrate the above steps, as will be described below with reference to fig. 5 by way of example, in one embodiment, 3 data sectors are provided in the memory 7, when a write operation is performed, it may be first determined, according to a preset sequence, whether a value of an index block (a position of the index block may be preset) in the index sector is 0XFF, where 0X represents whether hexadecimal data is available, and if the value of the index block is hexadecimal FF, it indicates that the data sector with ID number 1 is a valid data sector (storing valid data), so that data may be written into the data sector with ID number 2, and then the content of the index block is updated to 0X7F, where 7F indicates that the data sector with ID number 2 is a valid data sector, and if the data write operation is performed again, it is determined again according to the index block, and if the value of the index block is 0X7F, the data sector with ID number 2 is a valid data sector, it is thus necessary to write data onto the data section with ID number 3 and update the value of the index block to 0X 0F. At this time, if data is written into the memory 7 again (note that in this embodiment, only 3 data sectors are provided for the memory 7), all 3 data sectors in the memory 7 already store valid data, when the index block is determined, it is determined whether the value is 0X0F, if so, it indicates that all 3 data sectors already store valid data, and at this time, it is necessary to move the valid data to the data sector with ID number 1 (i.e. the data block of the preset first data sector), and update the index block accordingly, and then write the data into the other data sector (i.e. the second data sector) with space already left according to the index of the updated index block, in one embodiment, the valid data of the data sectors with ID numbers 1 and 2 are copied to the data sector with ID number 3, and the data sector with ID number 1 is cleared, then, the data in the data sector with the ID number of 3 is copied to the data sector with the ID number of 1 (i.e., valid data is written in the data sector with the ID number of 1), and then the value of the index block is updated to 0XFF, thereby indicating that the data sector with the ID number of 1 is a valid data sector (storing valid data), and when data is rewritten, the data needs to be written in the data sector with the ID number of 2.
In one embodiment of the invention, the index block is represented by hexadecimal values that correspond to binary values, and the data block is indexed according to changes in the bits of the binary values. For example, 0F in hexadecimal corresponds to a binary value of 1111, 1F in hexadecimal corresponds to a binary value of 11111, 3F in hexadecimal corresponds to a binary value of 111111, 7F in hexadecimal corresponds to a binary value of 1111111, and FF in hexadecimal corresponds to a binary value of 11111111111. If digit 1 of the binary value is changed to 0, at least two values of 0F, 1F, 3F, 7F or FF may be mutually converted, that is, the index block is updated, and the data is structured and conveniently operated, thereby ensuring the correctness of updating the index block.
In an embodiment of the present invention, the method for reading and writing data in the memory 7 of the EC further includes a read operation, as shown in fig. 7, the read operation includes: and reading the content of the index block, and reading data from the data block of the corresponding data section according to the index of the index block. The reading operation is accurate in positioning, the number of times of reading data in the memory 7 of the chip such as the EC of the intelligent device can be reduced, particularly, only a partial area of the memory 7 can be read when the memory 7 is read, the storage medium of the whole memory 7 is avoided, and the service life of the chip such as the EC is prolonged.
The following describes the procedure of the write operation in the read/write method of the data in the memory 7 of the EC with reference to fig. 6 as an example:
firstly, writing 11, i.e. writing 11, wherein the offset is a reference function, the offset03 is to store valid data in the 3 rd data block in the data zone, when the data 11 is written, the value of the 3 rd index block in the index zone is judged to be FF, the data zone with the ID number of 1 is indicated to be a valid data zone (the 3 rd data block stores valid data), the data 11 is written into the 3 rd data block in the data zone with the ID number of 2, and then the value of the 3 rd index block is updated to be 7F; then, the operation of writing the data 22 is carried out, if the numerical value of the 3 rd index block is 7F, which indicates that the 3 rd data block of the data section with the ID number of 2 stores valid data, the data 22 is written into the 3 rd data block of the data section with the ID number of 3, and then the numerical value of the 3 rd index block is updated to be 0F; and then, performing an operation of writing the data 33, wherein the 3 rd data block of each of the 3 data sectors stores valid data, and at this time, according to the indexes of the numerical value FF of the 1 st index block and the numerical value 7F of the 2 nd index block in the index sectors, it can be determined that the data 03 in the data sector with the ID number 1 and the data 02 in the data sector with the ID number 2 are valid data respectively, then copying 03 and 02 into the data sector with the ID number 3, removing the content in the data sector with the ID number 1, then copying the valid data in the data sector with the ID number 3 into the data sector with the ID number 1, removing the content in the data sectors with the ID numbers 2 and 3, writing the data 33 into the 3 rd data block in the data sector with the ID number 2, and then updating the numerical value of the 3 rd index block to 7F. The above method can generally write only a partial area of the memory 7, and avoid using the storage medium of the whole memory 7, and can also avoid data writing errors or valid data overwriting in special cases (the above 3 data sectors all store valid data).
The embodiment of the present invention further provides a read-write apparatus for data in a memory 7 of an EC, which can reduce the number of times of reading and writing data in the memory 7 of its chip such as an EC, and in particular, when performing a write operation on the memory 7, can only write a partial area of the memory 7, while avoiding using a storage medium of the entire memory 7, thereby prolonging the service life of the chip such as an EC, the read-write apparatus includes a write apparatus 1, and as shown in fig. 3, the write apparatus 1 includes a setting module 2, a write module 3, and an update module 4.
The setting module 2 is configured to set an index section and a plurality of data sections in the memory 7, respectively, and set a plurality of data blocks in the data sections to store data, and set a plurality of index blocks in the index section, the index blocks corresponding to the data blocks. The memory 7 is a memory 7 of a component such as an EC of the smart device, for example, an EEPROM or a flash ROM of the EC, and it is necessary to perform a read/write operation on the memory 7 during an operation of the EC. In the present embodiment, the setting module 2 sets a plurality of data sectors in the memory 7, each of which can store data, and when the writing module 3 performs a writing operation on the memory 7, the writing module can write data into each of the data sectors, specifically, data can be written onto a data block. In this embodiment, when the writing module 3 performs a writing operation on the memory 7, it is necessary to first read the content of the index segment, where the index segment is provided with a plurality of index blocks, each index block is represented in the form of a number, a letter, a character string, or the like, and the index block can be mapped to a certain data block of a certain data segment. In one embodiment, the index blocks can be mapped to a specific data block of a certain data segment according to a preset specification, for example, a first index block can only be mapped to a first data block of the data segment, a second index block can only be mapped to a second data block of the data segment, and the like; in another embodiment, the amount of information of the index chunk may be increased in advance so that the position of the data chunk to which the index chunk is mapped may be varied.
The writing module 3 is configured to write data to the data blocks of the corresponding data segment according to the index of the index block when writing data to the memory 7. Since the index block can be mapped to a certain data block of a certain data segment, the writing module 3 can write the data to be written to the appropriate data block according to the index of the index block, and does not overwrite the original valid data in the memory 7. What is important is that the write module 3 can only perform write operation on one data block according to the index of the index block, but not perform operation on the data blocks of other data segments, nor perform operation on other data blocks of the same data segment, which undoubtedly reduces the workload, reduces the erasing times of the memory 7, and improves the service life of the memory 7.
The updating module 4 is connected to the writing module 3, and the updating module 4 is configured to update the index block according to the location information of the data written into the memory 7 by the writing module 3. When the write module 3 completes one write operation, the data in the data block is changed, and at this time, the index needs to be indexed according to a new data storage condition, that is, the update module 4 needs to update the index block according to the position information of the data written in the memory 7, so that the content of the index block is new, and when the write module 3 performs the write operation again, the write operation can be performed according to the index of the new index block. For example, the index block indicates which data blocks of which data sectors are valid data, the valid data can be avoided during the write operation of the write module 3, the pre-written data can be written into other empty data sectors or data blocks, the write module 3 can also write the pre-written data onto the data blocks storing only invalid data, and the data blocks storing the valid data can not be written while avoiding the valid data, so that the erasing times of the memory 7 are reduced as a whole.
In one embodiment of the present invention, the writing module 3 includes an obtaining unit configured to obtain information of a first data segment storing valid data according to an index of the index block, so that the writing module 3 writes data onto a second data segment adjacent to the first data segment according to the information of the first data segment, wherein the data stored in the second data segment is invalid. In one embodiment, as long as valid data is stored on a data block, the data segment in which the data block is located is considered as a first data segment in which valid data is stored; in another embodiment, the data block is considered to be the first data block storing valid data only when all data blocks of the data block store valid data. The information of the first data section comprises information such as an ID number of the first data section, the number of data blocks or the condition of stored valid data, and the position of the first data section can be determined after the acquisition unit acquires the information of the first data section, so that data is not written into the first data section in which the valid data is stored in the writing operation any more, otherwise, a writing error or data loss can be caused. In an embodiment, when the obtaining unit obtains the information of the first data segment according to the index of the index block, the obtaining unit may sequentially use each index block to obtain the information of the first data segment according to the arrangement order of the index blocks, so that the first data segment may be found according to a preset determining step. The writing method of writing data into the second data sector may sequentially write data into appropriate data sectors without causing disordered arrangement of valid data, for example, the data may be written into corresponding data sectors in descending order of ID numbers of the data sectors.
In an embodiment of the present invention, as shown in fig. 4, the writing device 1 further includes a transfer module 5, where the transfer module 5 is connected to the writing module and the updating module 4, respectively, and the transfer module 5 is configured to, when valid data is stored in all the data segments and the writing module 3 continues to perform the operation of writing data into the memory 7, move the valid data to a data block of a preset first data segment, and drive the updating module 4 to update a corresponding index block, so that the writing module 3 writes data into a second data segment according to an index of the updated index block. In the above case where all the data segments store valid data (not all the data blocks in all the data segments store valid data) and the memory 7 is written again, the transfer module 5 may move the data blocks storing valid data according to a preset rule, so as to make room in the data segments to accept the operation of writing data again, thereby avoiding data writing errors or the valid data being overwritten.
To further illustrate the above steps, as will be described below with reference to fig. 5 by way of example, in one embodiment, the setting module 2 sets 3 data sectors in the memory 7, when the writing module performs the writing operation, it may be first determined, according to a preset sequence, whether a value of an index block (a position of the index block may be preset) in the index sector is 0XFF, where 0X represents whether hexadecimal, and if the value of the index block is FF of hexadecimal, it indicates that the data sector with ID number 1 is a valid data sector (storing valid data), so that data may be written into the data sector with ID number 2, and then the updating module 4 updates the content of the index block to 0X7F, where 7F indicates that the data sector with ID number 2 is a valid data sector, and if the writing module 3 performs data writing again, the judgment needs to be performed according to the index block, if the value of the index block is 0X7F, it indicates that the data segment with ID number 2 is a valid data segment, so that the data needs to be written into the data segment with ID number 3, and the updating module 4 updates the value of the index block to 0X 0F. At this time, if the writing module 3 writes data into the memory 7 again (note that in this embodiment, only 3 data segments are set in the memory 7), at this time, all 3 data segments in the memory 7 already store valid data, when determining the index block, the writing module 3 needs to determine whether the value is 0X0F, if so, it indicates that all 3 data segments already store valid data, at this time, the transferring module 5 needs to move the valid data onto the data segment with ID number 1 (i.e. the data block of the preset first data segment), and update the index block accordingly, and then the writing module 3 writes the data onto the other data segment with space already left (i.e. the second data segment) according to the index of the index block updated by the updating module 4, in one embodiment, the transferring module 5 copies the valid data of the data segments with ID numbers 1 and 2 onto the data segment with ID number 3, the data sector with the ID number 1 is cleared, the data in the data sector with the ID number 3 is copied to the data sector with the ID number 1 (i.e., valid data is written into the data sector with the ID number 1), and then the updating module 4 updates the index block to have a value of 0XFF, so as to indicate that the data sector with the ID number 1 is a valid data sector (storing valid data), and the writing module 3 needs to write the data into the data sector with the ID number 2 when rewriting the data.
In one embodiment of the invention, the index block is represented by hexadecimal values that correspond to binary values, and the data block is indexed according to changes in the bits of the binary values. For example, 0F in hexadecimal corresponds to a binary value of 1111, 1F in hexadecimal corresponds to a binary value of 11111, 3F in hexadecimal corresponds to a binary value of 111111, 7F in hexadecimal corresponds to a binary value of 1111111, and FF in hexadecimal corresponds to a binary value of 11111111111. If digit 1 of the binary value is changed to 0, at least two values of 0F, 1F, 3F, 7F or FF may be mutually converted, that is, the updating module 4 updates the index block, and the data is structured and convenient to operate, thereby ensuring the correctness of updating the index block.
In an embodiment of the present invention, in conjunction with fig. 4 and 7, the reading and writing device for reading and writing data in the memory 7 of the EC further includes a reading device 6, and the reading device 6 is configured to read the content of the index block and read data from the data block of the corresponding data segment according to the index of the index block. The reading device 6 is accurate in positioning, the number of times of reading data in the memory 7 of the chip such as the EC of the intelligent device can be reduced, particularly, only a partial area of the memory 7 can be read when the memory 7 is read, the storage medium of the whole memory 7 is avoided, and the service life of the chip such as the EC is prolonged.
The operation of the write device 1 in the read/write device for data in the memory 7 of the EC will be described below by way of example with reference to fig. 6:
firstly, the write module 3 performs write11, i.e., writing 11, the offset is a reference function, the offset03 is to store valid data in the 3 rd data block in the data segment, when the write module 3 writes the data 11, it determines that the value of the 3 rd index block in the index segment is FF, and indicates that the data segment with ID number 1 is a valid data segment (the 3 rd data block stores valid data), the write module 3 writes 11 in the 3 rd data block of the data segment with ID number 2, and then the update module 4 updates the value of the 3 rd index block to 7F; the writing module 3 performs the operation of writing the data 22 again, if the value of the 3 rd index block is 7F, which indicates that the 3 rd data block of the data section with the ID number of 2 stores valid data, the writing module 3 writes the data 22 into the 3 rd data block of the data section with the ID number of 3, and then the updating module 4 updates the value of the 3 rd index block to be 0F; the write module 3 then performs the operation of writing the data 33, at this time, the 3 rd data block of each data segment of the 3 data segments stores valid data, at this time, according to the index of the value FF of the 1 st index block and the value 7F of the 2 nd index block in the index segment, the transfer module 5 can respectively determine that the data 03 in the data segment with ID number 1 and the data 02 in the data segment with ID number 2 are valid data, then, 03 and 02 are copied to the data section with the ID number of 3, the content in the data section with the ID number of 1 is cleared, then copying the valid data in the data section with the ID number of 3 to the data section with the ID number of 1, the contents in the data sections with ID numbers 2 and 3 are cleared, the writing module 3 writes the data 33 to the 3 rd data block in the data section with ID number 2, and then the updating module 4 updates the value of the 3 rd index block to 7F. The writing device 1 can generally write only a partial area of the memory 7, and avoid using the storage medium of the entire memory 7, and can also avoid data writing errors or valid data overwriting in special cases (the 3 data sectors store valid data).
The above embodiments are only exemplary embodiments of the present invention, and are not intended to limit the present invention, and the scope of the present invention is defined by the claims. Various modifications and equivalents may be made by those skilled in the art within the spirit and scope of the present invention, and such modifications and equivalents should also be considered as falling within the scope of the present invention.

Claims (8)

1. A method of reading and writing data in a memory of an EC, the method comprising a write operation comprising:
respectively setting an index section and a plurality of data sections in the memory, wherein a plurality of data blocks are arranged in the data sections to store data, a plurality of index blocks are arranged in the index section, and the index blocks correspond to the data blocks;
when data are written into the memory, writing the data into the data blocks of the corresponding data sections according to the indexes of the index blocks;
updating the index block according to the position information of the data written into the memory;
wherein writing data onto the data blocks of the corresponding data segments according to the index of the index block comprises:
acquiring information of a first data section storing effective data according to the index of the index block;
and writing data onto a second data sector adjacent to the first data sector according to the information of the first data sector, wherein the data stored in the second data sector is invalid.
2. The method according to claim 1, wherein when all of the data segments store valid data and the operation of writing data into the memory is continued, the valid data is moved to a preset data block of the first data segment, and the index block is updated accordingly; and writing data to the second data segment according to the updated index of the index block.
3. Read-write method according to claim 1, characterized in that the index block is represented by hexadecimal values, which correspond to binary values, the data block being indexed according to the change of the bits of the binary values.
4. A method as claimed in claim 1, further comprising a read operation, said read operation comprising: and reading the content of the index block, and reading data from the data block of the corresponding data section according to the index of the index block.
5. The read-write device for the data in the memory of the EC is characterized by comprising a write device, wherein the write device comprises a setting module, a write-in module and an updating module;
the setting module is configured to set an index section and a plurality of data sections in the memory respectively, and set a plurality of data blocks in the data sections to store data, set a plurality of index blocks in the index section, the index blocks corresponding to the data blocks;
the writing module is configured to write data into the data blocks of the corresponding data segments according to the indexes of the index blocks when the data are written into the memory;
the updating module is connected with the writing module and is configured to update the index block according to the position information of the data written into the memory by the writing module;
the writing module comprises an obtaining unit, and the obtaining unit is configured to obtain information of a first data sector storing valid data according to the index of the index block, so that the writing module writes data onto a second data sector adjacent to the first data sector according to the information of the first data sector, wherein the data stored in the second data sector is invalid.
6. The device according to claim 5, further comprising a transfer module, the transfer module being respectively connected to the write module and the update module, the transfer module being configured to, when valid data is stored in all the data segments and the write module continues to write data into the memory, move the valid data to a preset data block of the first data segment, and drive the update module to update the corresponding index block, so that the write module writes data into the second data segment according to an updated index of the index block.
7. A read-write device according to claim 5, characterized in that the index block is represented by hexadecimal values, which correspond to binary values, the data block being indexed according to the change of the bits of the binary values.
8. A read-write device according to claim 5, further comprising a reading device configured to read the contents of the index block and to read data from the data block of the corresponding data segment according to the index of the index block.
CN201710530174.2A 2017-07-03 2017-07-03 Method and device for reading and writing data in EC (embedded control) memory Active CN107315543B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710530174.2A CN107315543B (en) 2017-07-03 2017-07-03 Method and device for reading and writing data in EC (embedded control) memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710530174.2A CN107315543B (en) 2017-07-03 2017-07-03 Method and device for reading and writing data in EC (embedded control) memory

Publications (2)

Publication Number Publication Date
CN107315543A CN107315543A (en) 2017-11-03
CN107315543B true CN107315543B (en) 2020-10-09

Family

ID=60180531

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710530174.2A Active CN107315543B (en) 2017-07-03 2017-07-03 Method and device for reading and writing data in EC (embedded control) memory

Country Status (1)

Country Link
CN (1) CN107315543B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779180A (en) * 2012-06-29 2012-11-14 华为技术有限公司 Operation processing method of data storage system and data storage system
CN103729303A (en) * 2014-01-20 2014-04-16 飞天诚信科技股份有限公司 Data writing and data reading methods of Flash
CN105138282A (en) * 2015-08-06 2015-12-09 上海七牛信息技术有限公司 Storage space recycling method and storage system
CN106445416A (en) * 2016-09-22 2017-02-22 飞天诚信科技股份有限公司 Data record storage, query and retrieval method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103403709B (en) * 2012-11-15 2016-10-05 华为技术有限公司 A kind of methods, devices and systems of reading and writing data
CN102981779A (en) * 2012-11-22 2013-03-20 华为技术有限公司 Data processing method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779180A (en) * 2012-06-29 2012-11-14 华为技术有限公司 Operation processing method of data storage system and data storage system
CN103729303A (en) * 2014-01-20 2014-04-16 飞天诚信科技股份有限公司 Data writing and data reading methods of Flash
CN105138282A (en) * 2015-08-06 2015-12-09 上海七牛信息技术有限公司 Storage space recycling method and storage system
CN106445416A (en) * 2016-09-22 2017-02-22 飞天诚信科技股份有限公司 Data record storage, query and retrieval method and device

Also Published As

Publication number Publication date
CN107315543A (en) 2017-11-03

Similar Documents

Publication Publication Date Title
US20180260317A1 (en) Method for managing the copying and storing of data in garbage collection, memory storage device and memory control circuit unit using the same
CN110908925B (en) High-efficiency garbage collection method, data storage device and controller thereof
US8037232B2 (en) Data protection method for power failure and controller using the same
US8291155B2 (en) Data access method, memory controller and memory storage system
TWI592800B (en) Memory management method and storage controller using the same
US8041884B2 (en) Controller for non-volatile memories and methods of operating the memory controller
JP4524309B2 (en) Memory controller for flash memory
JP5035636B2 (en) Moving sectors in blocks in flash memory
US10540276B2 (en) Method of processing data based on erase operations of logical pages related to data compression rate of mapping table in data storage device
US9582416B2 (en) Data erasing method, memory control circuit unit and memory storage apparatus
US9037814B2 (en) Flash memory management method and flash memory controller and storage system using the same
US9058256B2 (en) Data writing method, memory controller and memory storage apparatus
CN109582216B (en) Data storage device and data processing method of memory device
US20120198131A1 (en) Data writing method for rewritable non-volatile memory, and memory controller and memory storage apparatus using the same
CN106445401B (en) Table updating method, memory storage device and memory control circuit unit
CN107943710B (en) Memory management method and memory controller using the same
TWI450271B (en) Method for managing a plurality of blocks of a flash memory, and associated memory device and controller thereof
CN108733577A (en) Storage management method, memorizer control circuit unit and memory storage apparatus
US8943264B2 (en) Data storing method, and memory controller and memory storage apparatus using the same
US8943289B2 (en) Data moving method for flash memory module, and memory controller and memory storage apparatus using the same
US8762685B2 (en) Data writing method, memory controller and memory storage apparatus
US8417909B2 (en) Block management and data writing method, and flash memory storage system and controller using the same
CN111338562B (en) Data storage device and data processing method
US9760456B2 (en) Memory management method, memory storage device and memory control circuit unit
CN107315543B (en) Method and device for reading and writing data in EC (embedded control) memory

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
GR01 Patent grant
GR01 Patent grant