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 effectively be lifted.
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 read-write region being sized is reserved in erasable chip;
First data of the first specified file are write to first subregion in the read-write region, the first specified file is recorded
Internal file mark FID, and for the first subregion set the first counter, set the first counter count value;Described
One data are the data in first write-in read-write region;
Second data of the second specified file are write to second subregion in the read-write region, the first specified file is recorded
Internal file mark FID, and the second counter is set for the second subregion, the count value of the second counter is in read-write region
The count value of the maximum counter of current count value adds 1;Second subregion is unappropriated region or interior in read-write region
Portion file identification FID is identical and the off-peak subregion of count value of corresponding counter.
Further, a kind of method for extending the erasable chip life-span as described above, in addition to:Write in read-write region
Before data, according to default space size, the read-write region is divided into N number of read-write space, sub-regions correspondence one
Read and write space, N >=2.
Further, a kind of method for extending the erasable chip life-span as described above, in addition to:For each read-write space point
Not She Zhi a counter, the initial value of all counters is identical;The count value of first counter is initial for counter
Value Jia 1.
Further, a kind of method for extending the erasable chip life-span as described above, the current count value from read-write region
The second subregion is searched in the subregion after subregion corresponding to maximum counter.
Further, a kind of method for extending the erasable chip life-span as described above, first subregion and the second son
Region is continuously or discontinuously;Described discontinuously to refer to mutually be not take up identical page between two sub-regions, the page is can
The minimum erasure unit of erasable chip.
Further, a kind of method for extending the erasable chip life-span as described above, methods described also includes:
File identification mapping table is set;The file identification mapping table is used to store the file stored in the read-write region
File name and file internal file identify FID mapping relations.
Further, a kind of method for extending the erasable chip life-span as described above, reads first specified file
Data, reading manner is:
Searched according to the file name of the first specified file in the file identification mapping table in the first specified file
Portion file identification FID;
FID is identified according to the internal file found, lookup FID is identical in the read-write region and count value is maximum
Subregion;
Read the data in the subregion found.
Further, a kind of method for extending the erasable chip life-span as described above, in addition to:
The protection of the first specified file and the second specified file is set to mark, the protection is labeled as being used to identify file
Data storage is in the read-write region.
A kind of device for extending the erasable chip life-span is additionally provided in the embodiment of the present invention, described device includes:
Read and write region and reserve module, for reserving the read-write region being sized in erasable chip;
Data write. module, with the first subregion that the first data of the first specified file are write to the read-write region,
And record the internal file mark FID of the first specified file;For the second data of the second specified file to be write into the read-write
Second subregion in region, and record the internal file mark FID of the first specified file;
Counter is configured and update module, for setting the first counter for the first subregion, sets the first counter
Count value;Be additionally operable to for the second subregion set the second counter, set the second counter count value for read-write region in when
The count value of the maximum counter of preceding count value adds 1;
Wherein, second subregion is that unappropriated region in read-write region or internal file mark FID are identical and right
The off-peak subregion of count value for the counter answered.
Further, a kind of device for extending the erasable chip life-span as described above, in addition to:
Space partitioning module is read and write,, will be described according to default space size before the write-in data in read-write region
Read-write region is divided into N number of read-write space, one read-write space of sub-regions correspondence, N >=2.
The beneficial effects of the present invention are:The method in extension erasable chip life-span provided in the embodiment of the present invention and
Device, by the reserved shared read-write region of specified file to need progress high frequency read-write, the data in specified file is carried out
When write-in and renewal, write operation again is write or is wiped by using subregion different in read-write region, so as to avoid
When carrying out data renewal, same data writing area is repeated a number of times when being write again after erasing, because of the wiping of file
When writing number of times more than projected life, cause the problem of whole chip can not be used, the specified text erasable by extending high-frequency
The erasing and writing life of part, improves the life-span of whole chip, using this method and device, may be such that common chip surmounts technical grade
Or car advises the index of aging of level chip, and cost is greatly reduced, 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 one embodiment of the present of invention;
Fig. 2 is a kind of structural representation for the device for extending the erasable chip life-span in one embodiment of the present of invention;
Fig. 3 is the schematic diagram for reading and writing region under init state in embodiment;
Fig. 4 be embodiment in complete the first specified file for the first time write-in after read-write region schematic diagram;
The schematic diagram in the read-write region after data renewals of the Fig. 5 to complete the first specified file in embodiment;
The schematic diagram in the read-write region after data write-ins of the Fig. 6 to complete the second specified file in embodiment.
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 that a kind of flow of the method in the extension provided in one embodiment of the invention erasable chip life-span is shown
It is intended to, as can be seen from Figure, this method mainly may comprise steps of:
Step S100:The read-write region being sized is reserved in erasable chip;
Step S200:First data write-in is carried out, the first data write-in of the first specified file is read and write the first of region
Subregion, the internal file mark FID of the first specified file of record, and the first counter is set for the first subregion, set the
The count value of one counter;
Step S300:By second subregion in the second data write-in read-write region of the second specified file, record first refers to
Determine the internal file mark FID of file, and the second counter is set for the second subregion, the count value of the second counter is current
Maximum count value adds 1;
Step S400:First is read according to the count value that the internal file of the first specified file identifies FID and its counter
The data of specified file.
Method described in the present embodiment, first according to may be needed in erasable chip in practical application carry out high frequency time reading
Some or certain several files of write operation reserve the read-write region being sized in erasable chip, and the read-write region is used as text
The part communal space, can carry out the multiple read-write operation of the file in the communal space, that is, to it is described some or certain
Several files are written and read protection.Wherein, some or some which specifically chosen file of file, can be according to actual needs
Voluntarily it is determined.The erasable chip includes but does not limit safety chip SE or embedded security chip eSE.
Completed by the COS of erasable chip after the division in the read-write region, the first data of the first specified file are write
Enter first subregion in the read-write region, and record the internal file mark FID of the first specified file, be that the first subregion is set
The first counter is put, the count value of the first counter is set;Wherein, first data are the number in first write-in read-write region
According to.Wherein, the internal file mark FID is file identification ID of the file in the read-write region.
When carrying out the write-in of data again, the second data of the second specified file are write to second son in the read-write region
Region, and the internal file mark FID of the first specified file is recorded, it is that the second subregion sets the second counter, second counts
The count value of device adds 1 for the count value of the maximum counter of current count value in read-write region;Second subregion is read-write
Unappropriated region or internal file mark FID is identical and the off-peak subregion of count value of corresponding counter in region.
Method described in the present embodiment, identifying FID by the internal file of the setting of counter and file realizes pair
The mark of the newest valid data of different files in region is read and write, i.e., identifies FID (i.e. same specified file) for internal file
Identical specified file, one of the count value maximum of counter is the newest valid data of the specified file.Therefore, carrying out
During the second data write-in of the second specified file, the data can be written to unappropriated space or internal file mark in region
Know that FID is identical but in the off-peak subregion of counter.It should be noted that internal file mark FID described at this is identical
But the off-peak subregion of counter not only refer to it is identical with the internal file of the second specified file mark FID, also including it
The internal file mark FID of his specified file, if for example, 3 sub-regions that are stored with read-write region store first and specified
The content of file, the internal file mark FID corresponding to this 3 sub-regions is the FID of the first specified file, now, internal
File identification FID is identical but the off-peak subregion of counter also includes off-peak two of this 3 sub-regions Counter
Subregion.
May be used also for the ease of the management and reading, in one embodiment of the invention, this method of the Chinese part in read-write region
With including:One file identification mapping table is set;The file identification mapping table is used to store the text stored in the read-write region
The file name of part and the internal file of file identify FID mapping relations.
When needing to be written and read the digital independent of the specified file of some in region, you can according to the title of file described
File identification mapping table finds the file internal file used when being stored in reading and writing region and identifies FID.
In present embodiment, following step can specifically be included by reading the reading manner of the data of first specified file
Suddenly:
1) the first specified file is searched in the file identification mapping table according to the file name of the first specified file
Internal file identifies FID;
2) according to the internal file mark FID found, lookup FID is identical in the read-write region and count value is maximum
Subregion;
3) data in the subregion found are read, the data now read are probably first data, also may be used
Can be updating the data for the first data for subsequently writing, identifying FID by the count value and internal file of counter can ensure
The data read are the newest valid data of the first specified file.
In actual applications, first subregion and the second subregion can be continuously or discontinuously;It is described discontinuous
Refer to mutually be not take up identical page between two sub-regions, the page is the minimum erasure unit of erasable chip, generally
128 bytes or 256 bytes or 512 bytes etc., are wiped between the chip that page is write, different subregions for non-page
Can be continuous, you can to take identical page, such as fruit chip is that page wipes the read-write space that page is write, in order to avoid reading a certain
When writing space and being wiped, other read-write spaces are impacted, it is preferably discontinuous between read-write space.
The method in the extension erasable chip life-span described in the present embodiment, is specified file by reserved read-write region
There is provided the different subregions of data write-in can be carried out, so as to avoid when carrying out data renewal, same data are write
Region is repeated a number of times after erasing writes (particularly with being the file that needs high frequency erasable) again, because the erasable number of times of file surpasses
When spending projected life, cause the problem of whole chip can not be used, by extending the erasable of the erasable specified file of high-frequency
In the life-span, improve the life-span of whole chip, and the read-write region can as multiple specified files shared interval, realize multiple
The protection of different specified files.
For the ease of data write-in and read-write space management in one embodiment of the invention, this method can be with
Including:Before by write-in data in read-write region, according to default space size, the read-write region is divided into N number of read-write
Space, one read-write space of sub-regions correspondence, N >=2.
The read-write region is divided into N number of independent read-write space in advance, each read-write space may be used to dress
A specified file is carried, each read-write space writes again after can carrying out multiple data erasing.Wherein, the default space
Size needs to be set according to the time, and the space size is not less than maximum file in the specified file to be write to be taken
The size in space, can be correctly written in the data for ensureing each specified file.
Wherein, in one embodiment of the invention, the second data of the second specified file are being write into the second subregion
When middle, if there are data in second subregion, now, in addition to:
The data in second subregion are wiped, second data are written to second subregion after erasing
In.
All read-write spaces in i.e. described read-write region are all completed after a data write-in, then when carrying out data write-in,
Need first to carry out that internal file mark FID is identical and erasings of data in the off-peak space of read-write mark.
In actual applications, this method also includes:The protection of the first specified file and the second specified file is set to mark, institute
State protection and be labeled as being used for the data storage for identifying file in the read-write region.
By setting protection mark, erasable chip just may know that the data for the file to be handled (write-in is read) are
It is no to be stored in the read-write region.
Corresponding to 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 is including the reserved module 100 in read-write region, Data write. module 200 and counter configuration and more
New module 300, wherein:
Read and write region and reserve module 100, for reserving the read-write region being sized in erasable chip;
Data write. module 200, with the first sub-district that the first data of the first specified file are write to the read-write region
Domain, and record the internal file mark FID of the first specified file;For the second data of the second specified file to be write into described read
Second subregion in region is write, and records the internal file mark FID of the first specified file;
Counter is configured and update module 300, for setting the first counter for the first subregion, sets the first counter
Count value;It is additionally operable to set the second counter for the second subregion, the count value of the second counter is set in read-write region
The count value of the maximum counter of current count value adds 1;
Wherein, second subregion is that unappropriated region in read-write region or internal file mark FID are identical and right
The off-peak subregion of count value for the counter answered.
In one embodiment of the invention, the device also includes read-write space partitioning module 400.
Space partitioning module 400 is read and write, for that will read and write in region before write-in data, according to default space size,
The read-write region is divided into N number of read-write space, one read-write space of sub-regions correspondence, N >=2.
In order to better illustrate the method and device provided in the embodiment of the present invention, with reference to specific embodiment to this
Invention is further elaborated.
Embodiment
In the present embodiment, erasable chip is safety chip SE, and the first specified file is under 3F00 catalogues in SE, title
For 6F5B file, the size of file is 100 bytes, and the second specified file is under 3F00 catalogues in SE, entitled 4F20
File, file size is 200 bytes, and in the application, 6F5B and 4F20 both of these documents can carry out the read-write of high frequency, and this two
Any one File once reaches the write-in life-span of chip design in individual file, and file will be unable to write-in, cause whole SE
It will cancel.Before the write-in that 6F5B files and 4F20 files are carried out in SE, send and specify to SE, notify the two needs of SE
Protected, SE does protection mark to two files.
The stream that the method for extending the chip life-span using the method described in the embodiment of the present invention is protected to the chip
Journey is as follows:
First, the read-write region that size is 256 × 20=5120 bytes is reserved in safety chip SE, is referred to as first
Determine the shared region of file and the second specified file, and the read-write region of 5120 bytes is divided into the reading that 20 sizes are 256k
Space is write, 20 read-write spaces are designated as space 1- spaces 20 respectively, wherein, preceding 4 bytes in each space are used for read-write sky
Between tag definitions, preceding 3 bytes are used as the counter Count in space, and next byte of counter is used to record in space
The internal file mark FID (ID for corresponding to read-write space) for the file to be write.In the present embodiment, 20 are read and write space
The initial value of counter is 0, and internal file mark FID is the reading under empty (with 0 mark in the present embodiment), init state
The schematic diagram for writing region is as shown in Figure 3.
In the present embodiment, 6F5B internal file mark FID is A, and 4F20 internal file mark FID is B, by two texts
The mapping relations that the file name of part identifies FID with internal file are stored into file identification mapping table.
When carrying out the first time write-in of data, in the present embodiment for need toward 6F5B files write data AAAA (6F5B's
Initial content) when, write step is as follows:
1st, SE finds 6F5B files, it is found that it has protection to identify, then pass through file identification mapping table corresponding relation and find
Its internal file mark A;
2nd, write data AAAA in the space 1 in read-write region (data write-in is preferably carried out in sequence, naturally it is also possible to
It is other spaces), the FID is updated to A, the count value of counter is updated to 1, completes the read-write space after data AAAA write-ins
As shown in Figure 4.
When needing the data for carrying out 6F5B files to update, it is assumed that the data after renewal are BBBB, and data BBBB is write
The step read and write in region is as follows:
1st, SE finds 6F5B files, it is found that it has protection to identify, and 6F5B inside text is found from file identification mapping table
Part identifies A;
2nd, it is space 1 in the space for searching current count value maximum in read-write region, the present embodiment;
3rd, according to agreement order (being sequentially to carry out data write-in by space 1-20 in the present embodiment), from the next of space 1
Space is begun look for, and finds unappropriated space or the file internal mark off-peak sky of FID identicals space count value
Between, preferably unappropriated space is space 2 in the present embodiment;
4th, the count value Count of the counter in the space 2 Count values for being updated to current maximum Jia 1, that is, be updated to 2, and
Internal file mark FID is set to A, data BBBB is write into space 2.
The read-write region completed after data BBBB write-ins is as shown in Figure 5.
When toward write-in data CCCC in 4F20 files, write step is as follows:
1st, SE finds 4F20 files, it is found that it has protection to identify, and 4F20 inside text is found from file identification mapping table
Part identifies B;
2nd, it is space 2 in the space for searching current count value maximum in read-write region, the present embodiment;
3rd, begun look for according to agreement order from next space in space 2, find unappropriated space or file internal
Identify in the FID identicals space off-peak space of count value, preferably unappropriated space, the present embodiment, be space 3;
4th, the count value Count of the counter in space 3 is updated 3, and internal file mark FID is set to B, by data
BBBB writes space 3.
The read-write region completed after data CCCC write-ins is as shown in Figure 6.
After 20 spaces complete a data write-in, during the write-in for the file for carrying out 6F5B again, it is assumed that needs are write
The data entered are DDDD, and write step is as follows:
1st, SE finds 6F5B files, it is found that it has protection to identify, and 6F5B inside text is found from file identification mapping table
Part identifies A;
2nd, the maximum space of current count value is searched in read-write region, is now space 20;
3rd, according to agreement order (being sequentially to carry out data write-in by space 1-20 in the present embodiment), from the next of space 20
Space is begun look for, and finds unappropriated space or the file internal mark off-peak sky of FID identicals space count value
Between, now, all spaces had been taken, and the internal file mark FID identicals space off-peak space of count value is pressed
Agreement order is defined as space 1;
4th, the count value Count of the counter in the space 1 Count values for being updated to current maximum Jia 1, that is, are updated to 21,
And internal file mark FID is set to A, data DDDD is write into space 2.
Complete after above-mentioned write-in, in the data in needing reading file 6F5B, read step is as follows:
1st, SE finds 6F5B files, it is found that it has protection to identify, and 6F5B inside text is found from file identification mapping table
Part identifies A;
2nd, the lookup internal file mark FID in read-write region is A and count value is the file count value for being designated A
Maximum space, is now space 1, reads the data DDDD in space 1.
By the method and device provided in the embodiment of the present invention, find, can make common applied in practical application scene
Chip surmount the service life of technical grade and/or the chip of car rule level, better meet the actual demand of user, and by the party
Method and device, applied in technical grade or the chip of car rule level, more can further improve service life.
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.