The content of the invention
It is initial with OTP programs in solving correlation technique it is a primary object of the present invention to provide a kind of program writing method
The limited problem of address burning number of times.
To achieve these goals, according to an aspect of the invention, there is provided a kind of program writing method, the method bag
Include:The first initial address of the first program for having been written into storage region is obtained from reserved area, wherein, the memory block
Domain is the storage region in disposal programmable device, multiple reserved areas has been reserved in the storage region, each trough
Domain is used to be stored in the initial address of the program stored in the storage region;Obtain in the storage region close to described
The address that can write the second program after first program;The second initial address is obtained, wherein, second initial address
Value meets following condition:More than or equal to the address that can write second program and by 0 in first initial address
It is revised as what can be obtained after 1;0 in the first initial address in the reserved area is repaiied according to second initial address
It is changed to 1;Second program is write from second initial address.
Further, obtaining the second initial address includes:Determine one or more 0 modifications in first initial address
It is the modified values that can be obtained after 1;Calculate the difference of the modified values and the address that second program can be write;Really
Numerical value is the modified values just and corresponding to the difference of minimum in the fixed difference;Using the corresponding modified values as institute
State the second initial address.
Further, after the difference of the modified values with the address that can write second program is calculated,
Methods described also includes:If the difference is negative, the storage region after the storage region of first initial address
Interior write-in second initial address.
Further, the second program can be write close to after first program in the storage region obtaining
Address after, methods described also includes:Default invalidation word joint number is obtained, wherein, the invalidation word joint number is disposably may be used
Byte number at most idle between two initial addresses of program in storage region in programming device;Judge second starting
Whether idle byte number is less than or equal to most free word joint numbers between address and first initial address;If described
Idle byte number is less than or equal to most free word joint numbers between second initial address and first initial address, then from
Second initial address writes second program;If empty between second initial address and first initial address
Not busy byte number is more than most free word joint numbers, then the end of first initial address is wiped according to the byte number having more
Position, writes second program at position after being erased.
Further, obtaining the second initial address includes:First initial address can be write described with described
The address of two programs is carried out or computing, is obtained or operation result;Using described or operation result value as second starting point
Location.
To achieve these goals, according to another aspect of the present invention, a kind of program writing station, the device are additionally provided
Including:First acquisition unit, the first starting for obtaining the first program for having been written into storage region from reserved area
Address, wherein, the storage region is the storage region in disposal programmable device, and multiple has been reserved in the storage region
Reserved area, each reserved area is used to be stored in the initial address of the program stored in the storage region;Second obtains
Unit, for obtaining in the storage region close to the address that can write the second program after first program;The
Three acquiring units, for obtaining the second initial address, wherein, the value of second initial address meets following condition:More than etc.
It is revised as what can be obtained after 1 in the address that can write second program and by 0 in first initial address;
Modification unit, for 0 in the first initial address in the reserved area to be revised as into 1 according to second initial address;
First writing unit, for writing second program from second initial address.
Further, the 3rd acquiring unit includes:First determining module, for determining first initial address in
One or more 0 be revised as the modified values that can be obtained after 1;First computing module, for calculate the modified values with it is described
The difference of the address of second program can be write;Second determining module, for determining that numerical value is for just and most in the difference
The modified values corresponding to small difference;Modified module, for initial using the corresponding modified values as described second
Address.
Further, described device also includes:Second writing unit, for that can be write with described in the calculating modified values
After the difference of the address for entering second program, if the difference is negative, in the storage of first initial address
Write-in second initial address in storage region behind region.
Further, described device also includes:4th acquiring unit, for obtaining in the storage region close to institute
State after the address that can write the second program after the first program, obtain default invalidation word joint number, wherein, it is described invalid
Byte number is byte numbers at most idle between two initial addresses of program in the storage region in disposal programmable device;
Judging unit, for judging whether byte number idle between second initial address and first initial address is less than
In most free word joint numbers;3rd writing unit, for second initial address and first initial address it
Between idle byte number when being less than or equal to most free word joint numbers, write second journey from second initial address
Sequence, idle byte number is more than most free word joint numbers between second initial address and first initial address
When, the last bit of first initial address is wiped according to the byte number having more, described second is write at position after being erased
Program.
Further, the 3rd acquiring unit includes:Second computing module, for by first initial address and institute
Stating can write the address of second program and carry out or computing, obtain or operation result;Processing module, for inciting somebody to action described or fortune
The value of result is calculated as second initial address.
The present invention has been written into the first initial address of the first program of storage region by the acquisition from reserved area,
Wherein, storage region is the storage region in disposal programmable device, and multiple reserved areas have been reserved in storage region, each
Reserved area is used to be stored in the initial address of the program stored in storage region;Obtain in storage region close to the first journey
The address that can write the second program after sequence;The second initial address is obtained, wherein, the value of the second initial address meets as follows
Condition:Can be obtained after being revised as 1 more than or equal to the address that can write the second program and by 0 in the first initial address
's;0 in the first initial address in reserved area is revised as 1 according to the second initial address;From the write-in of the second initial address
Second program, the step of as a result of 0 in the first initial address is revised as into 1, OTP programs rise in solving correlation technique
The limited problem of beginning address burning number of times, and then reached the effect for improving OTP program origin burning number of times.
Specific embodiment
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the application can phase
Mutually combination.Describe the present invention in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
In order that those skilled in the art more fully understand application scheme, below in conjunction with the embodiment of the present application
Accompanying drawing, is clearly and completely described to the technical scheme in the embodiment of the present application, it is clear that described embodiment is only
The embodiment of the application part, rather than whole embodiments.Based on the embodiment in the application, ordinary skill people
The every other embodiment that member is obtained under the premise of creative work is not made, should all belong to the model of the application protection
Enclose.
It should be noted that term " first ", " in the description and claims of this application and above-mentioned accompanying drawing
Two " it is etc. for distinguishing similar object, without for describing specific order or precedence.It should be appreciated that so using
Data can exchange in the appropriate case, so as to embodiments herein described herein.Additionally, term " including " and " tool
Have " and their any deformation, it is intended that covering is non-exclusive to be included, for example, containing series of steps or unit
Process, method, system, product or equipment are not necessarily limited to those steps clearly listed or unit, but may include without clear
It is listing to Chu or for these processes, method, product or other intrinsic steps of equipment or unit.
The embodiment of the invention provides a kind of program writing method.
Fig. 3 is the flow chart of program writing method according to a first embodiment of the present invention, as shown in figure 3, the method includes
Following steps:
Step S102:The first initial address of the first program for having been written into storage region is obtained from reserved area,
Wherein, storage region is the storage region in disposal programmable device, and multiple reserved areas have been reserved in storage region, each
Reserved area is used to be stored in the initial address of the program stored in storage region.
Step S104:Obtain in storage region close to the address that can write the second program after the first program.
Step S106:The second initial address is obtained, wherein, the value of the second initial address meets following condition:It is more than or equal to
The address of the second program can be write and what can be obtained after 1 is revised as in 0 in the first initial address.
Step S108:0 in the first initial address in reserved area is revised as 1 according to the second initial address.
Step S110:The second program is write from the second initial address.
The embodiment has been written into the first starting point of the first program of storage region using the acquisition from reserved area
Location, wherein, storage region is the storage region in disposal programmable device, and multiple reserved areas have been reserved in storage region,
Each reserved area is used to be stored in the initial address of the program stored in storage region;Obtain in storage region close to the
The address that can write the second program after one program;The second initial address is obtained, wherein, the value of the second initial address meets
Following condition:Can after being revised as 1 more than or equal to the address that can write the second program and by 0 in the first initial address
Obtain;0 in the first initial address in reserved area is revised as 1 according to the second initial address;From the second initial address
The second program is write, the step of as a result of 0 in the first initial address is revised as into 1, OTP journeys in correlation technique is solved
The limited problem of sequence initial address burning number of times, and then reached the effect for improving OTP program origin burning number of times.
In One Time Programmable (One Time Programmable, referred to as OTP) program, due to each secondary program
Renewal, be required for record present procedure initial address, so, when updating next time, it is possible to according to record starting
The length gauge of address and program calculates new initial address.Reserved area can be OTP storage region in for recording journey
The specific region of the initial address of sequence, for example, the storage region of the reserved 16words of the beginning part of OTP, in the storage region
During the initial address of middle first time write-in program, the starting of first time write-in program is stored since first in reserved area
Address, in the initial address of second write-in program in the storage region, it is necessary in first obtaining and having been written into storage region
The first program the first initial address, then obtaining can write the address of the second program in storage region, the address need
Will be close to after the first program, the second initial address is the initial address of the second program, and the value of the second initial address meets two
Condition:More than or equal to the address that can write the second program, be possible to write in the address of the second program 0 be modified as 1 can
Obtain.Because the second initial address is required to write the second program, therefore, the second initial address can be more than or equal to energy
The address of the second program is enough write, but can not be less than, if one or more in the first initial address 0 are revised as after 1
The value for obtaining is more than or equal to the address that can write the second program, then can change the first initial address and obtain the second starting point
Location, without the erasing of the first initial address is write into the second initial address again, second is obtained by changing the first initial address
Beginning address scheme, can reuse the storage region of program origin, improve the burning time of OTP program origins
Number.
Alternatively, obtaining the second initial address can be by the following method:Determine or many in the first initial address
Individual 0 is revised as the modified values that can be obtained after 1;Calculate the difference of modified values and the address that the second program can be write;It is determined that poor
Numerical value is the modified values just and corresponding to the difference of minimum in value;Using corresponding modified values as the second initial address.
If 0 in first initial address, then 0 can be revised as 1, but 1 and cannot be modified as 0, therefore, if the first starting
One or more in address 0 are revised as obtaining modified values after 1, also, this modified values be precisely the second initial address then
Just modified values after 1 as the second initial address are modified as using 0.If to have be modified as 0 in the first address and have multiple after 1
Value is met more than the second initial address, then the value minimum with the difference of the second initial address is determined from these modified values, by this
The corresponding modified values of individual minimum value are used as the second initial address.So, due to changing the value for obtaining and the second initial address gap
Minimum, can save memory space, also, when changing next time, can also continue to be modified as 1 by therein 0, to obtain
Three initial addresses, can at utmost utilize the first initial address.In follow-up process, the initial address for newly writing each time
Before, can judge whether previous initial address can be rewritten into the initial address of this new write-in, or be written over
Difference afterwards with the initial address that can write new procedures is smaller, if previous initial address can be rewritten, and will be revised
Value can save storage region space as new initial address, improve modification number of times.
Alternatively, after difference of the modified values with the address that can write the second program is calculated, if difference is negative,
Then the second initial address is write in the storage region after the storage region of the first initial address.
If being revised as the value obtained after 1 less than the address that can write the second program by the 0 of the first initial address,
That is, difference is negative, then do not rewrite the first initial address, but in storage region after the storage region of the first initial address
The second initial address is write, the second initial address can be write with adjacent first initial address, it is also possible to reserve default digit again
Write-in.
Alternatively, obtain in storage region close to the address that can write the second program after the first program it
Afterwards, default invalidation word joint number is obtained, wherein, invalidation word joint number is two journeys in the storage region in disposal programmable device
At most idle byte number between the initial address of sequence;Judge byte idle between the second initial address and the first initial address
Whether number is less than or equal to most free word joint numbers;If idle byte number is small between the second initial address and the first initial address
In equal to most free word joint numbers, then the second program is write from the second initial address;If the second initial address and the first starting
Idle byte number is more than most free word joint numbers between address, then the end of the first initial address is wiped according to the byte number having more
Tail position, writes the second program at position after being erased.
After the address of second program that obtains, if the idle bytes between the first initial address and the second initial address
Number has exceeded most free word joint numbers, then the second initial address can be write in idle bytes, if the byte number of free time is not
Enough write the second initial address, then can be by the erasing of the last bit of the first initial address, position after being erased and idle bytes
Position writes the second initial address.
Alternatively, obtaining the second initial address includes:First initial address is entered with the address that can write the second program
Row or computing, obtain or operation result;Using or operation result value as the second initial address.
For example, after updating for the first time, fw start low=0x12, fw start high=0x00.With
As a example by the program of 100words (800bytes):First time word2 content is 0x12,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00, the initial address more after new procedures is 16 (0x12)+100 (0x64)=116 (0x74), second for the second time
Secondary word2 contents with 0x74's or should be worth, i.e., 00010010 for 0x12 | 01110100=01110110=0x76.
A kind of recording method of new FW initial addresses and length is the embodiment of the invention provides, such that it is able to fixed
In headspace, the number of times of upgrading is lifted.
The embodiment of the present invention additionally provides a kind of preferred embodiment, and the preferred embodiment can be realized in the following way:
Error-checking code (Error Correcting Code, referred to as ECC) enters each word of OTP for verifying burning
Data whether be consistent with original program, for the ripe OTP of design and craft, and do not need ECC functions, Ke Yitong
Register configuration is crossed, turns off ECC.The embodiment of the present invention is applied to turn off the scene of ECC.
Initial address update mode:
Fig. 4 is the flow chart of program writing method according to a second embodiment of the present invention, and the embodiment can be as above-mentioned
The preferred embodiment of first embodiment, as shown in figure 4, the method is comprised the following steps:
Step S401:Obtain the first initial address:First initial address=" byte 1 of the second row word moves to right 8 " and " the
The byte 0 of two row words " or operation result.
Step S402:Judge whether the first initial address is equal to 0.If it is judged that being yes, then step S403 is performed, such as
Fruit judged result is no, then perform step S404.
Step S403:The byte 1 for initializing the row word of byte 0 and second of the second row word is 0x12,0x00.
Step S404:Continue to obtain the first initial address, the first initial address=" the byte m+1 of line n word moves to right 8 "
With " the byte m of line n word " or computing, wherein, the initial value of m and n is n=2, m=0.
Step S405:Whether judge the first initial address=0xFFFF.If it is judged that being yes, then step is performed
S416, if it is judged that being no, then performs step S406.
Step S406:Calculate the second initial address:Second initial address=the first initial address+program size.This implementation
The second initial address in example namely the address that can write the second program in above-described embodiment.
Step S407:Second address is modified, the second address correction value=the second initial address and the first starting point
Location or operation result.In the present embodiment, the second address correction value is the second initial address in above-described embodiment.
Step S408:Whether judge second the-the second initial address of initial address correction value>30.30 can be it is default most
Many free word joint numbers.If it is judged that being yes, then step S409 is performed, if it is judged that being no, then perform step S415.
Step S409:The byte m=0xFF, the byte m+1=0xFF of line n word of line n word are set.
Step S410:Whether judge m=6.
Step S411:The numerical value of n is increased by 1.
Step S412:Judge n whether more than 16.If it is judged that being yes, then process is exited, if it is judged that being no
Then perform step S414.
Step S413:The second initial addresses of the byte m+2=correction value _ least-significant byte of line n word.The byte m+3 of line n word
=the second initial address correction value _ most-significant byte.
Step S414:The second initial addresses of the byte 0=correction value _ least-significant byte of the (n+1)th row word.The word 1=of the (n+1)th row word
Second initial address correction value _ most-significant byte.
Step S415:The second initial addresses of the byte m=correction value _ least-significant byte of line n word, the byte m=of line n word
Two initial address correction values _ most-significant byte.
Step S416:The value of m+2 is assigned to m.
Step S417:Whether judge m>6, if it is judged that being yes, then step S418 is performed, if it is judged that being
It is no, then perform step S404.
Step S418:Then making the value of m=0, n increases by 1.
Step S419:Whether judge n>16, if it is judged that being yes, then exit, if it is judged that being no, then perform
Step S404.
The rule that OTP finds initial address is, since the 3rd word, it is not the byte (bytes) of 0xff to read 2
As initial address, can be without wiping word2 at once, but according to starting for the first time in word2 when second burning
The content of address is updated on word 2.
For example, after updating for the first time, fw start low=0x12, fw start high=0x00.With
As a example by 100words (800bytes) program, first time word2 content be 0x12,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00, the initial address more after new procedures is 16 (0x12)+100 (0x64)=116 (0x74), second for the second time
Secondary word2 contents with 0x74's or should be worth, i.e., 00010010 for 0x12 | 01110100=01110110=0x76.After renewal
Word2 be 0x76,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, so have lost 2 word
(word74, word75), but word3 need not be updated, as long as updating word2 on the original basis can just complete fw startings
The renewal of address, be increased in fixed headspace can be with the number of times of ROMPaq.
Initial address after third time more new procedures is 118 (0x76)+100 (0x64)=218 (0xDA), third time
The content of word2 with 0xDA's or should be worth, i.e., 01110110 for 0x76 | 11011010=11111110=0xFE, after renewal
Word2 be 0xFE, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, so have lost 36 word (word
DA, word FD), but word3 need not be updated, as long as updating word2 on the original basis can just complete fw initial addresses
Renewal, be increased in fixed headspace can be with the number of times of ROMPaq.
Acceptable loss can be set according to the total size of OTP, so that third time is lost as an example, if OTP sizes can only
Receive every time loss be no more than 30 word, then third time more new procedures, it is necessary to will third time update after initial address
(0x00DA) high position (fw start high) respectively forwardly moves two bytes with low level (fw start low), then wipes
Fall former initial address (being write as 0xFF).So on the premise of 30 word of maximum loss, the word2 after third time more new procedures
It is 0xFF, 0xFF, 0xDA, 0x00,0x00,0x00,0x00,0x00,0x00.
It should be noted that can be in such as one group computer executable instructions the step of the flow of accompanying drawing is illustrated
Performed in computer system, and, although logical order is shown in flow charts, but in some cases, can be with not
The order being same as herein performs shown or described step.
A kind of program writing station is the embodiment of the invention provides, the program writing station can be used for performing the present invention in fact
Apply the program writing method of example.
Fig. 5 is the schematic diagram of program writing station according to embodiments of the present invention, as shown in figure 5, the device includes:
First acquisition unit 10, for obtaining the first program for having been written into storage region from reserved area first
Initial address, wherein, storage region is the storage region in disposal programmable device, has been reserved in storage region multiple reserved
Region, each reserved area is used to be stored in the initial address of the program stored in storage region.
Second acquisition unit 20, the second program can be write for obtaining in storage region close to after the first program
Address.
3rd acquiring unit 30, for obtaining the second initial address, wherein, the value of the second initial address meets following bar
Part:It is revised as what can be obtained after 1 more than or equal to the address that can write the second program and by 0 in the first initial address.
Modification unit 40, for being revised as 0 in the first initial address in reserved area according to the second initial address
1。
First writing unit 50, for writing the second program from the second initial address.
Alternatively, the 3rd acquiring unit includes:First determining module, for determining or many in the first initial address
Individual 0 is revised as the modified values that can be obtained after 1;First computing module, for calculating modified values and the second program can be write
The difference of address;Second determining module, for determining that numerical value in difference is the modified values just and corresponding to the difference of minimum;Modification
Module, for using corresponding modified values as the second initial address.
Alternatively, device also includes:Second writing unit, for calculating modified values and the ground that the second program can be write
After the difference of location, if difference is negative, second is write in the storage region after the storage region of the first initial address
Initial address.
Alternatively, device also includes:4th acquiring unit, for obtaining in storage region close to after the first program
The address that can write the second program after, obtain default invalidation word joint number, wherein, invalidation word joint number is can disposably to compile
Byte number at most idle between two initial addresses of program in storage region in journey device;Judging unit, for judging
Whether idle byte number is less than or equal to most free word joint numbers between second initial address and the first initial address;3rd write-in
Unit, most free word joint numbers are less than or equal to for idle byte number between the second initial address and the first initial address
When, the second program is write from the second initial address, idle byte number is more than between the second initial address and the first initial address
During most free word joint numbers, the last bit of the first initial address is wiped according to the byte number having more, write at position after being erased
Enter the second program.
Alternatively, the 3rd acquiring unit includes:Second computing module, by the first initial address with can write the second program
Address carry out or computing, obtain or operation result;Processing module, for using or operation result value as the second starting point
Location.
The embodiment obtains the first journey for having been written into storage region using first acquisition unit 10 from reserved area
First initial address of sequence, wherein, storage region is the storage region in disposal programmable device, is reserved in storage region
Multiple reserved areas, each reserved area is used to be stored in the initial address of the program stored in storage region;Second obtains
Unit 20 is obtained in storage region close to the address that can write the second program after the first program;3rd acquiring unit 30
The second initial address is obtained, wherein, the value of the second initial address meets following condition:More than or equal to the second program can be write
Address and what can be obtained after 1 is revised as in 0 in the first initial address;Modification unit 40 will according to the second initial address
In reserved area in the first initial address 0 is revised as 1;First writing unit 50 writes the second journey from the second initial address
Sequence, so as to burning number of times in OTP program origins is limited in solving the problems, such as correlation technique, and then has reached raising OTP journeys
The effect of sequence initial address burning number of times.
In the above embodiment of the present invention, the description to each embodiment all emphasizes particularly on different fields, and does not have in certain embodiment
The part of detailed description, may refer to the associated description of other embodiment.
Obviously, those skilled in the art should be understood that above-mentioned of the invention each module or each step can be with general
Computing device realize that they can be concentrated on single computing device, or be distributed in multiple computing devices and constituted
Network on, alternatively, the program code that they can be can perform with computing device be realized, it is thus possible to they are stored
Performed by computing device in the storage device, or they be fabricated to each integrated circuit modules respectively, or by they
In multiple modules or step single integrated circuit module is fabricated to realize.So, the present invention is not restricted to any specific
Hardware and software is combined.
The preferred embodiments of the present invention are the foregoing is only, is not intended to limit the invention, for the skill of this area
For art personnel, the present invention can have various modifications and variations.It is all within the spirit and principles in the present invention, made any repair
Change, equivalent, improvement etc., should be included within the scope of the present invention.