A kind of method and apparatus for extending the erasable chip life-span
Technical field
The present invention relates to chip technology field, and in particular to a kind of method and apparatus in extension erasable chip life-span.
Background technology
Erasable chip, such as flash chip, band EEPROM EEPROM, safety chip SE,
Wiped due to the existing information in erasable chip, reprogramed, be widely used in every field.Erasable chip
Write operation must be carried out in white space, if there have been data target area, it is necessary to first wipe and write afterwards, therefore erasing behaviour
Work is the basic operation of flash memory.But each erasing to chip and re-operate and can all consume the life-span of chip.In order to the greatest extent
The service life of chip may be extended, common chip is usually substituted using professional chip, such as safety chip SE,
The M2M chips of rank can be advised with the M2M chips or car of technical grade, but be found in practical application, for answering for some fields
For, even technical grade or car advise the chip of rank, application demand can not be met, and the price of professional chip compares
It is expensive so as to be greatly improved using the chip and using the cost of the equipment of this kind of chip.
The content of the invention
For defect present in prior art, it is an object of the invention to provide a kind of extension erasable chip life-span
Method, with it, the life-span of chip can be greatly promoted.
To achieve the above object, the technical solution adopted by the present invention is:A kind of method for extending the erasable chip life-span, bag
Include:
The size of specified file in erasable chip, is that the specified file distributes N number of continuous read-write space,
N≥2;
The space address in first read-write space of record, and one counter, Suo Youji are set respectively for each read-write space
The initial value of number device is identical;
Space, and the counter for reading and writing space by described first are read and write into the primary data write-in first of the specified file
Value add 1;
The write-in of new filling data is carried out to the specified file, the new filling data of specified file are written to the
Two read-write spaces, and by the value of the counter in the described second read-write space be updated to it is last carry out data write-in when read-write it is empty
Between the value of counter add 1.
Further, a kind of method for extending the erasable chip life-span as described above, in addition to:Read the specified file
Data, reading manner is:
According to the space address in the first of specified file read-write space, N number of continuous reading of the specified file is searched
Write space;Read the data in the maximum read-write space of N number of read-write space Counter value.
Further, a kind of method for extending the erasable chip life-span as described above, in addition to:The specified file is set
Protection mark, the protection mark refers to the mark that there are multiple read-write spaces for identifying specified file.
Further, a kind of method for extending the erasable chip life-span as described above, is carried out newly to the specified file
The write-in of data is filled, space is read and write into the new filling data write-in second of specified file, including:
The specified file is searched according to the file identification of specified file;
When specified file has protection mark, according to the space address in its first read-write space, its N number of reading is found
Write space;
Search the maximum read-write space of N number of read-write space Counter value;
In next read-write space that new filling data are written to the maximum read-write space of the Counter Value.
Further, a kind of method for extending the erasable chip life-span as described above, by new filling data write-in the
Before two read-write spaces, if there are data in the second read-write space, in addition to:
The data in the second read-write space are wiped, the new filling data are written to the second read-write after erasing
In space.
Further, a kind of method for extending the erasable chip life-span as described above, the second read-write space is upper one
Next read-write space in the secondary read-write space for carrying out data write-in.
A kind of device for extending the erasable chip life-span is additionally provided in the embodiment of the present invention, including:
Many read-write space distribute modules, are the specified text for the size of the specified file in erasable chip
Part distributes N number of continuous read-write space, N >=2;
Space setup module is read and write, the space address for recording first read-write space, and be each read-write space point
One counter is not set, and the initial value of all counters is identical;
Data write. module, for the primary data write-in first of the specified file to be read and write into space, and to institute
When stating the write-in of the new filling data of specified file progress, the new filling data of specified file are written to the second read-write empty
Between;
Counter update module, for when primary data write-in first is read and write into space, space to be read and write by described first
The value of counter add 1, when being additionally operable to the new filling data of specified file being written to the second read-write space, by described second
The value of the counter in the read-write space when value for reading and writing the counter in space is updated to last progress data write-in plus 1.
Further, a kind of device for extending the erasable chip life-span as described above, in addition to:
Data read module, the data for reading the specified file;The data read module includes:
Spatial lookup unit is read and write, for the space address in first read-write space according to specified file, is searched described
The N number of read-write space of specified file;
Data in data-reading unit, the read-write space maximum for reading N number of read-write space Counter.
Further, a kind of device for extending the erasable chip life-span as described above, the read-write space setup module bag
Include:
Protection mark setting unit, for setting the protection of the specified file to mark, the protection mark refers to be used for
There is the mark in multiple read-write spaces in mark specified file.
Further, a kind of device for extending the erasable chip life-span as described above, the second read-write space is upper one
Next read-write space in the secondary read-write space for carrying out data write-in.
The beneficial effects of the present invention are:The method and device in extension erasable chip life-span provided by the present invention, leads to
Cross and distribute multiple read-write spaces for specified file, it is empty by using different read-writes when data update in carrying out specified file
Between write or wiped write operation again, improve the erasable number of times of chip, so as to improve the life-span of overall chip, adopt
With this method and device, it may be such that common chip surmounts technical grade or car advises the index of aging of level chip, and greatly reduce into
This, has better met the demand of practical application.
Brief description of the drawings
Fig. 1 is a kind of schematic flow sheet for the method for extending the erasable chip life-span in the specific embodiment of the invention;
Fig. 2 is a kind of structural representation for the device for extending the erasable chip life-span in the specific embodiment of the invention;
Fig. 3 is the structural representation in the read-write space after the primary data write-in of completion specified file in the embodiment of the present invention
Figure;
Fig. 4 is the knot in the read-write space after the once new filling data write-in of completion specified file in the embodiment of the present invention
Structure schematic diagram;
Fig. 5 is the read-write space after the filling data write-in new again of completion specified file in the embodiment of the present invention
Structural representation.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on
Embodiments of the invention, the every other reality that those of ordinary skill in the art are obtained under the premise of creative work is not made
Example is applied, the scope of protection of the invention is belonged to.
Fig. 1 shows a kind of flow signal of method for extending the erasable chip life-span in the specific embodiment of the invention
Figure, as can be seen from Figure, this method can mainly include following steps:
Step S100:The size of specified file in erasable chip, is that the specified file distribution is N number of continuous
Read and write space;
It is the specified file distribution N first according to the size of the specified file of erasable chip in the embodiment of the present invention
Individual continuous read-write space, wherein, N >=2.For example, for a certain specified file, its file size is 100 bytes, if N=
10, then the read-write space of 100 × 10=1000 byte can be distributed for this document.In actual applications, the specified file
Generally refer to need to carry out some or certain the several files, which specifically chosen text of high frequency time read-write operation in erasable chip
Part, can be determined according to actual needs.Wherein, the erasable chip includes but does not limit safety chip SE.
Wherein, the continuous space address for referring to read-write space is continuous.In the present embodiment, the erasable chip refers to
Can do can take common page between the erasable chip of byte rank, two read-write spaces, i.e., non-page wipes the chip that page is write,
The page is the minimum erasure unit of erasable chip, generally 128 bytes or 256 bytes or 512 bytes
Deng.For example, the size of specified file is 100 bytes, the size of the page of erasable chip is 128 bytes, then first read-write is empty
Between only take up 100 bytes in one page, and remaining 28 bytes are then as the part in next read-write space.
In one embodiment of the invention, after the distribution in read-write space of specified file is completed, in addition to institute is set
The protection mark of specified file is stated, the protection mark refers to the mark that there are multiple read-write spaces for identifying specified file.
In the digital independent in needing progress file, it can know that specified file has multiple read-write spaces by protection mark.
Wherein, the specific pattern of protection mark is unrestricted, can voluntarily set as needed.
Step S200:The space address in first read-write space of record, and one counting is set respectively for each read-write space
Device, the initial value of all counters is identical;
After the distribution for completing N number of reading space, the space address in first read-write space is recorded and stores, and be each
Read-write space sets a counter respectively, and the initial value of all counters is identical.For example, the initial value of all counters can
0.Because N number of read-write space is continuous, therefore, the space address in first read-write space need to be only recorded, you can according to first reading
The space address for writing space finds other corresponding read-write spaces.
In actual applications, can be with order to ensure that the tally function of counter disclosure satisfy that the useful life demand of chip
Several bytes are distributed as counter, the space of three bytes can be such as reserved for each counter.In addition, being counted when a certain
The count value of device reaches that it maximum can will go out all counters outside the corresponding counter of maximum count value after count value
Value initialization, the value of the corresponding counter of maximum count value is updated to initialization value and adds 1 again.
Step S300:Space is read and write into the primary data write-in first of the specified file, and the described first read-write is empty
Between the value of counter add 1;
The primary data refers to the data write when carrying out data write-in to specified file for the first time, completes primary data
Write-in after, the value of counter in the first read-write space is added 1.
Step S400:The write-in of new filling data is carried out to the specified file, by the new filler of specified file
According to the second read-write space is written to, the value of the counter in the second read-write space is updated to reading during last progress data write-in
The value for writing the counter in space plus 1.
The new filling data refer to the data for subsequently needing to write after the renewal in specified file.To the specified text
When part carries out the write-in of new filling data, the new filling data of specified file are written to the second read-write space, and by institute
State the counter in the second read-write space value be updated to it is last (it is current carry out data write operation it is preceding once) carry out data
The value of the counter in read-write space during write-in adds 1.For example, three read-write spaces are respectively A, B, C, last time carries out data write-in
Be the corresponding read-write spaces of B, its Counter Value is 5, then current when carrying out data and updating write-in, can be by new filling data
The corresponding read-write spaces of writing address C, its corresponding Counter Value is updated to 6.
The value of the counter in current read-write space is set in the upper Counter Value for reading and writing space once used
On the basis of add 1, by this way, it is ensured that the currently active number that the data in the maximum read-write space of Counter Value are
According to.That is, the data which read-write space is the value for the counter for passing through multiple read-write spaces just can be distinguished in are most
New data are the currently valid data of specified file.
After the protection for being provided with specified file is identified, space is read and write into the new filling data write-in second of specified file
Concrete mode be:
The specified file is searched according to the file identification of specified file;
When specified file has protection mark, according to the space address in its first read-write space, search it and arrive all
Read and write space;
Search the maximum read-write space of Counter Value;
In next read-write space that new filling data are written to the maximum read-write space of the Counter Value.
The file identification of the specified file can be the title or other unique marks of specified file, according to file identification
Locating file is general technology means.It is first when it is to need to write new filling data that the data for carrying out specified file, which update,
Specified file is first found, and judges that specified file is identified with the presence or absence of protection, if being not present, supporting paper only has unique reading
Space is write, the erasing and write operation in its unique read-write space is directly carried out, if in the presence of being that to illustrate that specified file is present N number of
Space is read and write, now, the space address in space is read and write according to first of specified file, just can find all readings of specified file
Space is write, and further searches for the maximum read-write space of Counter Value, new filling data being write into the maximum reading of Counter Value
Write space.
In one embodiment of the invention, in order to ensure that N number of read-write space of specified file can be interleaved, keep away
Exempt to read and write space using uneven situation, preferably to extend the life-span of chip, in one embodiment of the invention, described the
Next read-write space in read-write space when two read-write spaces are preferably last progress data write-in.
In addition, in actual applications, before by new filling data write-in the second read-write space, if described second reads
Write and there are data in space, in addition to:The data in the second read-write space are wiped, the new filling data are written to
In the second read-write space after erasing.All completed in all read-write spaces after a data write-in, then carry out data more
, it is necessary to be write again after the erasing of advanced row data when new.
That is, after the use in turn in N number of read-write space is completed, the read-write again returned to shared by primary data is empty
Between when, follow-up each data are write, it is necessary to which the erasing for being first written and read data in space writes again.
In one embodiment of the invention, methods described also includes step S500, as shown in figure 1, reading the finger
The step of determining the data of file.
In present embodiment, the concrete mode of the data for reading specified file is:
According to the space address in first read-write space according to specified file, N number of read-write space of specified file is found, is looked into
The read-write space for looking for the value of calculator in N number of read-write space maximum, reads the data in the maximum read-write space of the counter.
The method in the extension erasable chip life-span provided in present embodiment, by distributing N times for specified file
Space is read and write, each read-write space can carry out the erasing and write-in of data respectively, so that avoid when carrying out data renewal,
Same read-write space is repeated a number of times after erasing and writes (particularly with being the specified file that needs high frequency erasable) again, because
When the erasable number of times of specified file exceedes projected life, cause the problem of whole chip can not be used, wiped by extending high-frequency
The erasing and writing life for the specified file write, improves the life-span of whole chip.And this method, by setting counter, it is ensured that refer to
Determining N number of read-write space of file can be interleaved, it is to avoid read-write space preferably extends chip using uneven situation
Life-span.
It is corresponding with the method shown in Fig. 1, a kind of extension erasable chip life-span is additionally provided in the embodiment of the present invention
Device, as shown in Fig. 2 the device includes many read-write space distribute modules 100, read-write space setup module 200, read-write space
Setup module 200, Data write. module 300, counter update module 400 and data read module 500.Wherein:
Many read-write space distribute modules 100, are described specify for the size of the specified file in erasable chip
File distributes N number of continuous read-write space, N >=2;
Space setup module 200 is read and write, the space address for recording first read-write space, and be each read-write space
One counter is set respectively, and the initial value of all counters is identical;
Data write. module 300, for the primary data write-in first of the specified file to be read and write into space, and right
When the specified file carries out the write-in of new filling data, the new filling data of specified file are written to the second read-write empty
Between;
Counter update module 400, it is for when primary data write-in first is read and write into space, the described first read-write is empty
Between the value of counter add 1, when being additionally operable to the new filling data of specified file being written to the second read-write space, by described
The values of counter corresponding to two read-write spaces are updated to the value of the counter in last read-write space when carrying out data write-in
Plus 1;Wherein, the second read-write space is preferably next read-write space in the last read-write space for carrying out data write-in;
Data read module 500, the data for reading the specified file;Wherein, the data read module 500 is wrapped
Include read-write spatial lookup unit 510 and data-reading unit 520.
Spatial lookup unit 510 is read and write, for the space address in first read-write space according to specified file, institute is searched
State the N number of continuous read-write space of specified file;
Data in data-reading unit 520, the read-write space maximum for reading N number of read-write space Counter.
In one embodiment of the present of invention, read-write space setup module 200 also includes protection mark setting unit
210, for setting the protection of the specified file to mark, the protection mark refers to there are multiple readings for identifying specified file
Write the mark in space.
In order to be better understood from the present invention, with reference to specific embodiment, the present invention will be described in further detail.
Embodiment
In the present embodiment, erasable chip is safety chip SE, and specified file is under 3F00 catalogues in SE, entitled
6F5B file, the size of file is 100 bytes, and in the application, this file of 6F5B can carry out the read-write of high frequency, this text
Part once reaches the write-in life-span of chip design, and file will be unable to write-in, cause whole SE all to cancel, using present invention implementation
The flow that the method that method described in example extends the chip life-span is protected to the chip is as follows:
Make protection mark for the 6F5B files under SE 3F00 catalogues, and it is 100 to distribute 20 read-writes space, i.e. total sizes
The read-write space of × 20 bytes, then be used for for each read-write space other 3 bytes of distribution at the beginning of depositing counter, counter
Initial value is all identical, the present embodiment, and the initial value of counter is 0, according to space address order, and 20 read-write space address are remembered respectively
For the structural representation for reading and writing space for space 1- spaces 20, Fig. 3 for 20 before write-in data.
After the setting for completing read-write space, below to carrying out data write-in in 6F5B files, flow is as follows:
The data for carrying out assuming write-in for the first time in primary data write-in, the present embodiment to 6F5B files are AAAA.This reality
Apply and space 1 is used as to the described first read-write space in example, naturally it is also possible to select other spaces as first and read and write space.
AAAA is write into space 1, and the Counter Value in space 1 is added 1, the read-write space of the file after first write-in is completed
Schematic diagram as shown in Figure 4, the Counter Value in space 1 is updated to 1.
Need to carry out 6F5B files data renewal, it is necessary to which the data BBBB after renewal is written in 6F5B files.Write
It is fashionable, this document is found according to filename 6F5B first, it is found that it has protection to mark, illustrates that this document there are multiple read-write spaces,
According to the space address in space 1, all read-write spaces being found, traveling through all read-write spaces, can find the last time writes
Enter the maximum read-write space of the read-write space i.e. Counter Value of data, i.e., described space 1 now, writes new data into address 1
Next read-write space is space 2, i.e., write data BBBB in space 2, and the value of the counter in space 2 is updated into space 1
Counter Value add 1, i.e. the value of the counter in space 2 is updated to 2, completes to update the schematic diagram in read-write space after write-in as schemed
Shown in 5.
Above-mentioned data writing mode is repeated, it is necessary to when being updated write-in again to the data in 6F5B files, search meter
The maximum read-write space of number device, will using next read-write space in the maximum space of counter as the second current read-write space
The data of renewal are written in the space, and the value that the value of the counter in its space is updated into the counter in a space thereon adds
1。
After will update the data write-in behind the corresponding space 20 in address 20, if necessary to carry out data write-in again, then need
Write data into next read-write space in space 20, i.e., in space 1, now, there is data AAAA in space 1, need
AAAA is first wiped, then carries out new data write-in.It can be seen that, using which, after 20 data renewals are completed, just need to open
Begin to carry out data erasing.
In the present embodiment, 20 read-write spaces of specified file are used in turn, in chip by the way of space is doubled
Specified file protected, lift its erasable use time, improve the service life of chip.
When needing from the reading data of 6F5B files, pass through the read-write space that the value for searching counter is maximum, you can complete
Into the reading of data.
In actual applications, the read-write space number of the specified file distribution according to the actual requirements, can be customized for,
That is N numerical value.
Find, the method and device provided in the embodiment of the present invention using the party applied in practical application scene
Method and device, can make common chip surmount the service life of technical grade and/or the chip of car rule level, better meet user's
Actual demand, and by this method and device, applied in technical grade or the chip of car rule level, more can further improve and use the longevity
Life.For example, the chip hardware of consumer level support 100,000 times it is erasable, using the present invention method and device, we can carry for it
For 10 times of protection, make its erasable number of times reach 1,000,000 times it is erasable;Likewise, advising level in 500,000 erasable cars of hardware supported
On chip, ten times of protection result is exactly 5,000,000 erasable life-spans.
It should be noted that herein, such as first and second or the like relational terms are used merely to a reality
Body or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or deposited between operating
In any this actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant are intended to
Nonexcludability is included, so that process, method, article or equipment including a series of key elements not only will including those
Element, but also other key elements including being not expressly set out, or also include being this process, method, article or equipment
Intrinsic key element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that
Also there is other identical element in process, method, article or equipment including the key element.
Obviously, those skilled in the art can carry out the essence of various changes and modification without departing from the present invention to the present invention
God and scope.So, if these modifications and variations of the present invention belong to the scope of the claims in the present invention and its equivalent technology
Within, then the present invention is also intended to comprising including these changes and modification.