CN104850427B - A kind of code upgrade method and device - Google Patents
A kind of code upgrade method and device Download PDFInfo
- Publication number
- CN104850427B CN104850427B CN201510192011.9A CN201510192011A CN104850427B CN 104850427 B CN104850427 B CN 104850427B CN 201510192011 A CN201510192011 A CN 201510192011A CN 104850427 B CN104850427 B CN 104850427B
- Authority
- CN
- China
- Prior art keywords
- upgrade
- file
- code
- upgrade file
- module
- 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
Links
Abstract
The invention discloses a kind of code upgrade methods, comprising: when the file under using target directory is upgraded, identifies the upgrade file under the target directory;Verify whether the upgrade file is completely, if so, being upgraded according to the upgrade file, if it is not, then stopping upgrading;If the upgrade file is that completely, when running the executable file in the upgrade file, whether the upgrade code verified in the executable file is correct, if so, executing the upgrade code.Correspondingly, the invention also discloses a kind of devices.Using the present invention, unit exception caused by exception upgrade file is performed can avoid.
Description
Technical field
The present invention relates to electronic technology field more particularly to a kind of code upgrade method and devices.
Background technique
The online upgrading function of current automobile-used diagnostic equipment code reading card is generally existing and is commonly used.It is being risen online
When grade, if not carrying out validity check to the upgrading data of write device, the file of write device may be one not
The data known, the upgrading data for running the mistake in write device are likely to cause functions of the equipments exception or even equipment damage.
Summary of the invention
The present invention provides a kind of code upgrade method and devices, by verifying to upgrade file, and are executing
The validity that upgrade code is verified before upgrade code can avoid unit exception caused by exception upgrade file is performed.
In a first aspect, the embodiment of the invention discloses a kind of code upgrade methods, this method comprises:
When the file under using target directory is upgraded, the upgrade file under the target directory is identified;
Verify whether the upgrade file is completely, if so, being upgraded according to the upgrade file, if it is not, then
Stop upgrading;
If the upgrade file is completely, when running the executable file in the upgrade file, described in verifying
Whether the upgrade code in executable file is correct, if so, executing the upgrade code.
With reference to first aspect, in the first possible implementation, the upgrade file is respectively corresponding with characteristic value;Institute
State whether the verifying upgrade file is complete, comprising:
The upgrade file is calculated each by the first default hashing algorithm, it is respectively right to obtain the upgrade file
The calculated result answered;
Whether compare the corresponding calculated result of the upgrade file and the corresponding characteristic value of the upgrade file
Unanimously, if so, the upgrade file is complete, if it is not, the then upgrade file damage.
With reference to first aspect, in the second possible implementation, the upgrading in the verifying executable file
Whether code is correct, comprising: calculates the upgrade code by the second default hashing algorithm, obtains the upgrade code
Corresponding calculated result;The upgrade code is corresponding with characteristic value;
Whether consistent compare the corresponding calculated result of upgrade code characteristic value corresponding with the upgrade code, if
It is that then the upgrade code is correctly, if it is not, then the upgrade code is wrong.
The possible implementation of with reference to first aspect the first, in the third possible implementation, in the ratio
When whether the corresponding calculated result of upgrade file and the corresponding characteristic value of the upgrade file are consistent, also wrap
It includes: if comparison result is inconsistent, exporting the first prompt information, the upgrading for prompting comparison result described in user inconsistent
File corruption.
The possible implementation of second with reference to first aspect, in the fourth possible implementation, in the ratio
When whether the corresponding calculated result of upgrade code characteristic value corresponding with the upgrade code is consistent, further includes: if
Comparison result is inconsistent, then exports the second prompt information, for prompting upgrade code mistake described in user.
Second aspect, the embodiment of the invention discloses a kind of code upgrade device, which includes:
Identification module, for when the file under to target directory upgrades, identify under the target directory to
Upgrade file;
First inspection module, for verifying whether the upgrade file is complete;
Upgraded module, for being carried out according to the upgrade file when the output result of first inspection module, which is, is
Upgrading stops upgrading when the output result of first inspection module is no;
Second inspection module, if for the upgrade file being complete, holding in the operation upgrade file
When style of writing part, whether the upgrade code verified in the executable file is correct;
Execution module, for executing the upgrade code when the output result of second inspection module, which is, is.
In conjunction with second aspect, in the first possible implementation, the upgrade file is respectively corresponding with characteristic value;Institute
State the first inspection module, comprising:
First computing module is obtained for calculating the upgrade file each by the first default hashing algorithm
The corresponding calculated result of upgrade file;
First comparison module, for the corresponding calculated result of the upgrade file with the upgrade file respectively
Whether corresponding characteristic value is consistent, if so, the upgrade file is complete, if it is not, the then upgrade file damage.
In conjunction with second aspect, in the second possible implementation, second inspection module, comprising:
Second computing module obtains described for calculating the upgrade code by the second default hashing algorithm
The corresponding calculated result of upgrade code;The upgrade code is corresponding with characteristic value;
Second comparison module is used for the corresponding calculated result of upgrade code spy corresponding with the upgrade code
Whether value indicative is consistent, if so, the upgrade code is correctly, if it is not, then the upgrade code is wrong.
In conjunction with the first possible implementation of second aspect, in the third possible implementation, described device
Further include: the first cue module, in the corresponding calculated result of the first comparison module upgrade file
When whether consistent with the corresponding characteristic value of the upgrade file, if comparison result is inconsistent, output the first prompt letter
Breath, the upgrade file damage for prompting comparison result described in user inconsistent.
In conjunction with second of possible implementation of second aspect, in the fourth possible implementation, described device
Further include: the second cue module, in the corresponding calculated result of the second comparison module upgrade code and institute
State the corresponding characteristic value of upgrade code it is whether consistent when, if comparison result is inconsistent, the second prompt information is exported, for mentioning
Show upgrade code mistake described in user.
Implement the present invention, by verifying to the integrality of upgrade file, if upgrade file is correct in upgrading
It is complete, then continue to upgrade, and when running the executable file in the upgrade file, to the upgrading in executable file
Code is verified, if the code error in executable file, the executable file out of service can avoid abnormal rise
Unit exception caused by grade file is performed.
Detailed description of the invention
It, below will be to attached drawing needed in present invention description in order to illustrate more clearly of technical solution of the present invention
It is briefly described, it should be apparent that, drawings in the following description are some embodiments of the invention, skill common for this field
For art personnel, without creative efforts, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is the flow chart of the first embodiment of code upgrade method provided by the invention;
Fig. 2 is the flow chart of the second embodiment of code upgrade method provided by the invention;
Fig. 3 is the flow chart of the 3rd embodiment of code upgrade method provided by the invention;
Fig. 4 is the structural schematic diagram of the first embodiment of code upgrade device provided by the invention;
Fig. 5 is the structural schematic diagram of the second embodiment of code upgrade device provided by the invention;
Fig. 6 is the structural schematic diagram of the 3rd embodiment of code upgrade device provided by the invention;
Fig. 7 is the structural schematic diagram of the fourth embodiment of code upgrade device provided by the invention.
Specific embodiment
Below in conjunction with drawings and examples of the invention, the technical solution in the present invention is clearly and completely retouched
It states, it is clear that described embodiments are some of the embodiments of the present invention, instead of all the embodiments.Based in the present invention
Embodiment, every other embodiment obtained by those of ordinary skill in the art without making creative efforts, all
Belong to the scope of protection of the invention.
Fig. 1 is the flow chart of the first embodiment of code upgrade method provided in an embodiment of the present invention, this method comprises:
Step S101: when the file under using target directory is upgraded, the upgrading under the target directory is identified
File.
Specifically, the target directory can be the catalogue in remote server, updating apparatus is connected by network communication,
Such as Wi-Fi, it is connected with remote server, downloads the upgrade file under the target directory in remote server.The target mesh
The catalogue being also possible on local host is recorded, updating apparatus is by locality connection, for example, USB connection or serial ports connection, obtain master
The upgrading data that machine is sent.
In the specific implementation, the upgrading data under the target directory can be packaged into upgrading data packet.Updating apparatus is from described
When target directory downloads upgrading data packet, the upgrade file in the upgrading data packet may recognize that, to verify the upgrading
Whether file is complete upgrade file.
Step S103: verify whether the upgrade file is complete.
Specifically, updating apparatus can verify that the institute downloaded to after downloading to the upgrade file from the target directory
State whether upgrade file is complete upgrade file.
In the embodiment of the present invention, updating apparatus can by Message Digest 5 (Message Digest Algorithm) come
Verify the integrality of upgrade file.In the specific implementation, the provider of upgrading data can calculate upgrade file by eap-message digest
Method obtains the informative abstract of fixed digit, and the informative abstract of generation is hidden in upgrade file.Updating apparatus is downloading to
After upgrade file, the upgrade file downloaded to can be handled by the eap-message digest that the upgrading data providing uses.Such as
The informative abstract that the upgrade file that fruit downloads to is calculated is consistent with the informative abstract hidden in upgrade file, then updating apparatus
It can determine that the upgrade file downloaded to is that completely, there is no damages in downloading process.It should be noted that carrying out file
In the verification process of integrality, the embodiment of the present invention can be by the corresponding information of each of upgrading data packet upgrade file
Abstract can also pluck each of upgrading data packet function (2 or 2 or more a upgrade files) corresponding information
It wants, it can also be by the corresponding informative abstract of entire upgrading data packet, here with no restriction.
In the embodiment of the present invention, updating apparatus can also pass through cyclic redundancy check code (Cyclic Redundancy
Check, CRC) verify whether the upgrade file downloaded to is complete.In the specific implementation, the provider of upgrading data can be with
Information field is generated according to the upgrade file, and CRC code is generated according to the information field, later together by upgrade file
With CRC code as upgrading data.Updating apparatus is after receiving the upgrading data downloaded to, according to information field and CRC code
Between the rule that is followed test, to determine in upgrade file transmission whether malfunction.It should be noted that complete carrying out file
In the verification process of whole property, each of upgrading data packet upgrade file can be corresponded to a CRC code by the embodiment of the present invention,
Can also be by each of upgrading data packet function (2 or 2 or more a upgrade files) corresponding CRC code, it can be with
By the corresponding CRC code of entire upgrading data packet, here with no restriction.
It should be noted that updating apparatus can also go to judge the integrality of the upgrade file by other methods of inspection, this
Inventive embodiments are with no restriction.
Specifically, if the upgrade file is complete, that is, without going out during downloading the upgrade file
Mistake thens follow the steps S105, otherwise, executes step S107, in practical application, other operations can also be performed, do not limit here
System.
Step S105: upgraded according to the upgrade file.
Specifically, if the upgrade file in transmission process there is no damage, the upgrading that updating apparatus receives
File is completely that then the upgrade file downloaded to can be written in preset memory to complete to upgrade by updating apparatus.
Step S107: stop upgrading.
Specifically, that is, described upgrade file is being transmitted across if the upgrade file that updating apparatus receives is not completely
It is damaged in journey, then updating apparatus can stop for the upgrade file being written in preset memory immediately, stop upgrading.
Step S109 verifies the liter in the executable file when running the executable file in the upgrade file
Whether grade code is correct.
Optionally, before executing step S109, updating apparatus can receive operating instruction, to trigger the operation upgrading
Executable file in file.In the specific implementation, the operating instruction, which can be the user on user interface, inputs generation
Instruction, the operating instruction is also possible to the physical button on updating apparatus and is pressed the instruction of generation, here with no restriction.
In the embodiment of the present invention, updating apparatus can by Message Digest 5 (Message Digest Algorithm) come
Verify the correctness of the upgrade code.In the specific implementation, the provider of the upgrade code can lead to the upgrade code
It crosses Message Digest 5 and obtains the informative abstract of fixed digit, and the informative abstract of generation is hidden in the upgrade code.
Before running the upgrade code, the Message Digest 5 meter that the provider of the upgrade code uses is can be used in updating apparatus
The corresponding informative abstract of the upgrade code is calculated, if the letter hidden in the informative abstract being calculated and the upgrade code
Breath abstract is consistent, then can determine that the upgrade code is correct.
In the embodiment of the present invention, updating apparatus can also pass through cyclic redundancy check code (Cyclic Redundancy
Check, CRC) verify whether the upgrade code is correct.In the specific implementation, the provider of the upgrade code can be with
Information field is generated according to the upgrade code, and CRC code is generated according to the information field.Updating apparatus is described in the operation
It before upgrade code, is tested according to the rule followed between information field and CRC code, is with the determination upgrade code
No is correct.
Specifically, if the upgrade code is correctly, to can determine that and upgraded according to the upgrade file
In the process, generate mistake for no during the upgrade code write-in preset memory in the executable file, i.e., it is described
Upgrade code is that correctly, otherwise executing step S111 then can determine that and mistake has occurred in escalation process, terminates current operation.
Step S111: the upgrade code is executed.
Implement the embodiment of the present invention, by verifying to the integrality of upgrade file, if upgrade file in upgrading
Be it is correctly complete, then preset memory is written into upgrade file to complete to upgrade, and in running the upgrade file
When executable file, the upgrade code in executable file is verified, if the code in executable file is correct, is transported
The row executable file is, it can be achieved that carry out correct effective upgrading to updating apparatus.
Fig. 2 is the flow chart of the second embodiment of code upgrade method provided in an embodiment of the present invention.The embodiment of Fig. 2 into
The validation verification method that upgrade file provided in an embodiment of the present invention is described in detail of one step.Do not have in the embodiment of Fig. 2
The content referred to please refers to content described in Fig. 1 embodiment.This method comprises:
Step S201: when the file under using target directory is upgraded, the upgrading under the target directory is identified
File.
Specifically, the target directory can be the catalogue in remote server, updating apparatus is connected by network communication,
Such as Wi-Fi, it is connected with remote server, downloads the upgrade file under the target directory in remote server.The target mesh
The catalogue being also possible on local host is recorded, updating apparatus is by locality connection, for example, USB connection or serial ports connection, obtain master
The upgrading data that machine is sent.
In the specific implementation, the upgrading data under the target directory can be packaged into upgrading data packet.Updating apparatus is from described
When target directory downloads upgrading data packet, the upgrade file in the upgrading data packet may recognize that, to verify the upgrading
Whether file is complete upgrade file.
Step S203: the upgrade file is calculated each by the first default hashing algorithm, obtains the upgrading
The corresponding calculated result of file.
Specifically, the first default hashing algorithm is the provider of upgrading data and the hash that updating apparatus is made an appointment
Algorithm, such as MD5 algorithm.Upgrade data provider by the described first default hashing algorithm by the upgrade file generate with
Corresponding characteristic value, and the corresponding characteristic value of the upgrade file is hidden in the upgrade file.It should be noted that
The first default hashing algorithm can also be hidden in the upgrade file.
Specifically, updating apparatus can be by the upgrading received text when updating apparatus downloads to the upgrade file
Part carries out the calculating of the described first default hashing algorithm, obtains calculated result.
Preferably, in the embodiment of the present invention, the provider for upgrading data can upgrade each of upgrading data packet
File carries out the hash operations of the primary first default hashing algorithm, that is, the corresponding hash feature of each upgrade file
Value;Correspondingly, updating apparatus needs default according to described first to each upgrade file after downloading to the upgrade file
Hashing algorithm carries out a hash operations, the corresponding calculated result of each upgrade file is obtained, to more each upgrade file
Calculated result whether in each upgrade file hide hash characteristic value it is consistent.
It should be noted that the function packet that the embodiment of the present invention can also update each of upgrading data packet (includes 2
A or 2 or more upgrade files) a corresponding hash characteristic value, then, updating apparatus needs the function to each update
Packet carries out a hash operations according to the described first default hashing algorithm, obtains the corresponding calculating knot of function packet of each update
Fruit, the calculated result of the function packet to more each update whether with the hash characteristic value hidden in the function packet of each update
Unanimously.Entire upgrading data packet can also be corresponded to a hash characteristic value by the embodiment of the present invention, then, updating apparatus only needs
Hash operations are carried out according to the described first default hashing algorithm to entire upgrading data packet.
It will be appreciated that since the feature of hashing algorithm is, it can be achieved that by biggish information to be verified, such as upgrading text
Part, corresponding to reduce the use of storage resource at lesser hash characteristic value, the very applicable limited equipment of storage resource, example
Such as automobile-used diagnostic equipment code reading card.
Step S205: the corresponding calculated result of upgrade file and the corresponding spy of the upgrade file
Whether value indicative is consistent.
Specifically, the corresponding characteristic value of upgrade file is respectively stored in the first default position of the upgrade file
Place is set, for example, the last line of file.Example is only a kind of implementation of the embodiment of the present invention, can be in actual use
Difference should not constitute restriction.
After executing step S203, updating apparatus may compare the corresponding calculated result of the upgrade file with it is described
Whether the corresponding characteristic value of upgrade file is consistent.If comparison result is consistent, that is, the downloading process of the upgrade file does not have
There is error, then follow the steps S205, otherwise, executes step S207, in practical application, other operations can also be performed, here not
It is restricted.
Step S207: the upgrade file is completely, to be upgraded according to the upgrade file.
Specifically, if the upgrade file in transmission process there is no damage, the upgrading that updating apparatus receives
File is completely that then the upgrade file downloaded to can be written in preset memory to complete to upgrade by updating apparatus.
Step S209: the upgrade file damage stops upgrading.
Specifically, that is, described upgrade file is being transmitted across if the upgrade file that updating apparatus receives is not completely
It is damaged in journey, then updating apparatus can stop for the upgrade file being written in preset memory immediately, stop upgrading.
In addition, that is, described upgrade file is in transmission process if the upgrade file that updating apparatus receives is not completely
In damaged, also exportable first prompt information of updating apparatus, the liter for prompting comparison result described in user inconsistent
Grade file corruption.
Implement the embodiment of the present invention, the integrality of the upgrade file is verified by hashing algorithm, it can be achieved that using compared with
Small storage resource stores the corresponding characteristic value of the upgrade file, simply and effectively demonstrates the upgrade file and is downloading
Whether damage in the process, if the upgrade file damages, stop upgrading immediately, can avoid the ascending series of mistake
According to write-in preset memory.
Fig. 3 is the flow chart of the 3rd embodiment of code upgrade method provided in an embodiment of the present invention.The embodiment of Fig. 3 into
The validation verification method that executable upgrade code provided in an embodiment of the present invention is described in detail of one step.The implementation of Fig. 3
The content not referred in example please refers to content described in Fig. 1 embodiment.This method comprises:
Step S301: upgraded according to upgrade file.
Specifically, if the upgrade file in transmission process there is no damage, the upgrading that updating apparatus receives
File be it is complete, then the upgrade file downloaded to can be written in preset memory to complete to upgrade by updating apparatus, with
Make the executable file in updating apparatus operation preset memory.
Step S303: the upgrade code is calculated by the second default hashing algorithm, obtains the upgrade code
Corresponding calculated result.
Specifically, the second default hashing algorithm is that the provider of the upgrade code and updating apparatus are made an appointment
Hashing algorithm, such as MD5 algorithm.The provider of the upgrade code is by the described second default hashing algorithm by the upgrading generation
Code generates corresponding characteristic value, and the corresponding characteristic value of the upgrade code is hidden in the upgrade code.It needs
To be illustrated, the second default hashing algorithm can also be hidden in the upgrade code.
Specifically, the upgrade code can be carried out institute by updating apparatus before updating apparatus runs the upgrade code
The calculating for stating the second default hashing algorithm, obtains calculated result.
Preferably, the provider of the upgrade code can be by the corresponding hash feature of the upgrade code of a more new function
Value is hidden in the more new function;Correspondingly, the more new function write-in updating apparatus the preset memory it
Afterwards, before updating apparatus runs the more new function, updating apparatus needs the upgrade code to the more new function according to institute
It states the second default hashing algorithm and carries out a hash operations, obtain calculated result, the upgrading generation to the relatively more described more new function
Whether the calculated result of code and the hash characteristic value hidden in the more new function are consistent.
It should be noted that entire upgrade code can also be corresponded to a hash characteristic value by the provider of the upgrade code,
It is hidden in the upgrade code.More acurrate in order to position, the provider of the upgrade code can also be by the upgrade code
The corresponding hash characteristic value of every line code.
It will be appreciated that since the feature of hashing algorithm is, it can be achieved that by biggish information to be verified, such as it is described executable
Upgrade code in file, it is corresponding at lesser hash characteristic value, the use of storage resource can be reduced, very applicable storage resource
Limited equipment, such as automobile-used diagnostic equipment code reading card.
Step S305: whether the corresponding calculated result of upgrade code characteristic value corresponding with the upgrade code
Unanimously.
Specifically, the corresponding characteristic value of the upgrade code is stored in the second predetermined position in the upgrade code,
For example, the first row of the upgrade code.Example is only a kind of implementation of the embodiment of the present invention, can be in actual use
Difference should not constitute restriction.After executing step S303, updating apparatus may compare the corresponding calculated result of the upgrade code
Whether characteristic value corresponding with the upgrade code is consistent.If comparison result is consistent, that is, the upgrading in the executable file
Code does not have mistake, thens follow the steps S307, otherwise, then can determine that the upgrade code is wrong, executes step S309.
Step S307: the upgrade code is correctly, to execute the upgrade code.
Step S309: the upgrade code is wrong, the stopping execution upgrade code.
Specifically, updating apparatus can also export second if mistake has occurred in the upgrade code in escalation process
Prompt information, for prompting upgrade code mistake described in user.
Implement the embodiment of the present invention and verifies the upgrade code by hashing algorithm before running upgrade code
Correctness is simply and effectively verified, it can be achieved that stored the corresponding characteristic value of the upgrade code using lesser storage resource
Whether the upgrade code damages, if the upgrade code damages, refuses to run the upgrade code, can keep away
Exempt from equipment damage caused by the code because of run-time error.
Referring to fig. 4, be device provided by the invention first embodiment structural schematic diagram, code liter as shown in Figure 4
Stage arrangement 40 can include: identification module 401, the first inspection module 403, upgraded module 405 and are held second inspection module 407
Row module 409.Wherein:
Identification module 401, for identifying under the target directory when the file under to target directory upgrades
File to be upgraded;
First inspection module 403, for verifying whether the upgrade file is complete;
Upgraded module 405, for when the output result of the first inspection module 403 be when, according to the upgrade file into
Row upgrading stops upgrading when the output result of first inspection module is no;
Second inspection module 407, if for the upgrade file be it is complete, run in the upgrade file can
When executing file, whether the upgrade code verified in the executable file is correct;
Execution module 409, for executing the upgrade code when the output result of the second inspection module 407, which is, is.
In the embodiment of the present invention, the first inspection module 403 can also further include: the first computing module as shown in Figure 5
4031 and first comparison module 4033.Wherein:
First computing module 4031, for the upgrade file to be calculated each by the first default hashing algorithm,
Obtain the corresponding calculated result of the upgrade file;
First comparison module 4033, for the corresponding calculated result of the upgrade file and the upgrade file
Whether corresponding characteristic value is consistent, if so, the upgrade file is complete, if it is not, the then upgrade file damage.
Specifically, the upgrade file is respectively corresponding with characteristic value.The first default hashing algorithm is upgrading data
The hashing algorithm that provider and updating apparatus are made an appointment, such as MD5 algorithm.The provider for upgrading data is pre- by described first
If the upgrade file is generated corresponding characteristic value by hashing algorithm, and the corresponding characteristic value of the upgrade file is hidden
It ensconces in the upgrade file.It should be noted that the first default hashing algorithm can also be hidden in the upgrade file.
In the specific implementation, the corresponding characteristic value of upgrade file can respectively be stored in the first default position of the upgrade file
Place is set, for example, file last line.Example is only a kind of implementation of the embodiment of the present invention, can not in actual use
Together, restriction should not be constituted.
In the embodiment of the present invention, the second inspection module 407 can also further include: the second computing module as shown in Figure 5
4071 and second comparison module 4073.Wherein:
Second computing module 4071 is obtained for calculating the upgrade code by the second default hashing algorithm
The corresponding calculated result of the upgrade code;The upgrade code is corresponding with characteristic value;
Second comparison module 4073, it is corresponding with the upgrade code for the corresponding calculated result of the upgrade code
Characteristic value it is whether consistent, if so, the upgrade code be correctly, if it is not, then the upgrade code is wrong.
Specifically, the second default hashing algorithm is that the provider of the upgrade code and updating apparatus are made an appointment
Hashing algorithm, such as MD5 algorithm.The provider of the upgrade code is by the described second default hashing algorithm by the upgrading generation
Code generates corresponding characteristic value, and the corresponding characteristic value of the upgrade code is hidden in the upgrade code.It needs
To be illustrated, the second default hashing algorithm can also be hidden in the upgrade code.In the specific implementation, the upgrading generation
The corresponding characteristic value of code is stored in the second predetermined position in the upgrade code, for example, the first row of code.Example is only
It is a kind of implementation of the embodiment of the present invention, can be different in actual use, restriction should not be constituted.
Further, code upgrade device 40 can also include: trigger module, if the trigger module is used for the liter
Grade file is complete, reception operating instruction;The operating instruction is responded, triggering runs the executable text in the upgrade file
Part.
It is the structural schematic diagram of the 3rd embodiment of code upgrade device provided by the invention referring to Fig. 6.As shown in fig. 6,
Code upgrade device 40 include identification module 401, the first inspection module 403, upgraded module 405, the second inspection module 407 with
And outside execution module 409, it may also include that the first cue module 411 and the second cue module 413.Wherein:
First cue module 411, in the corresponding calculating of upgrade file of the first comparison module 4033
Whether when as a result consistent with the corresponding characteristic value of the upgrade file, if comparison result is inconsistent, output first is mentioned
Show information, the upgrade file damage for prompting comparison result described in user inconsistent.
Second cue module 413, in the corresponding calculated result of the second comparison module 4073 upgrade code
When whether corresponding with upgrade code characteristic value is consistent, if comparison result is inconsistent, the second prompt information is exported, is used
The upgrade code mistake described in prompt user.
It is the structural schematic diagram of the fourth embodiment of code upgrade device provided by the invention referring to Fig. 7.Wherein, such as Fig. 7
Shown, which may include: at least one processor 1001, such as CPU, at least one bus 1002, at least one is defeated
Enter device 1003, at least one output device 1004, memory 1005.Wherein, bus 1002 is for realizing between these components
Communication connection;Input unit 1003 may include touch screen (Touch Screen), and optional input unit 1003 can also wrap
Keyboard (Keyboard) or other physical buttons are included, for example, volume key;Output device 1004 may include display screen
(Display);Memory 1005 can be high speed RAM memory, be also possible to non-labile memory (non-volatile
Memory), a for example, at least magnetic disk storage, memory 1005 optionally can also be that at least one is located remotely from aforementioned place
Manage the storage device of device 1001.As shown in fig. 7, as may include operation in a kind of memory 1005 of computer storage medium
System, network communication module, Subscriber Interface Module SIM and code verification program.
In code upgrade device 100 shown in Fig. 7, processor 1001 can call the code stored in memory 1005
Verifying, and execute following operation:
When the file under using target directory is upgraded, the upgrade file under the target directory is identified;
Verify whether the upgrade file is completely, if so, being upgraded according to the upgrade file, if it is not, then
Stop upgrading;
If the upgrade file is completely, when running the executable file in the upgrade file, described in verifying
Whether the upgrade code in executable file is correct, if so, executing the upgrade code.
Specifically, if the upgrade file is that completely, processor 1001 can also pass through input unit 1003 and receive fortune
Row instruction, to trigger the executable file run in the upgrade file.
Further, the upgrade file is respectively corresponding with characteristic value.Processor 1001 executes the verifying upgrading
Whether file is that complete step may particularly include:
Processor 1001 calculates the upgrade file each by the first default hashing algorithm, obtains the upgrading
The corresponding calculated result of file;
The 1001 corresponding calculated result of the upgrade file of processor and the upgrade file are corresponding
Whether characteristic value is consistent, if so, the upgrade file is complete, if it is not, the then upgrade file damage.
Specifically, the upgrade file is respectively corresponding with characteristic value.The first default hashing algorithm is upgrading data
The hashing algorithm that provider and updating apparatus are made an appointment, such as MD5 algorithm.The provider for upgrading data is pre- by described first
If the upgrade file is generated corresponding characteristic value by hashing algorithm, and the corresponding characteristic value of the upgrade file is hidden
It ensconces in the upgrade file.It should be noted that the first default hashing algorithm can also be hidden in the upgrade file.
In the specific implementation, the corresponding characteristic value of upgrade file can respectively be stored in the first default position of the upgrade file
Place is set, for example, file last line.Example is only a kind of implementation of the embodiment of the present invention, can not in actual use
Together, restriction should not be constituted.
In the specific implementation, in the 1001 corresponding calculated result of the upgrade file of processor and upgrading text
When whether the corresponding characteristic value of part is consistent, if comparison result is inconsistent, processor 1001 can pass through output device
1004 the first prompt informations of output, the upgrade file damage for prompting comparison result described in user inconsistent.
Further, whether the upgrade code that processor 1001 executes in the verifying executable file is correct
Step can include:
Processor 1001 calculates the upgrade code by the second default hashing algorithm, obtains the upgrade code
Corresponding calculated result;The upgrade code is corresponding with characteristic value;
The corresponding calculated result of the upgrade code of processor 1001 characteristic value corresponding with the upgrade code is
It is no consistent, if so, the upgrade code is correctly, if it is not, then the upgrade code is wrong.
Specifically, the second default hashing algorithm is that the provider of the upgrade code and updating apparatus are made an appointment
Hashing algorithm, such as MD5 algorithm.The provider of the upgrade code is by the described second default hashing algorithm by the upgrading generation
Code generates corresponding characteristic value, and the corresponding characteristic value of the upgrade code is hidden in the upgrade code.It needs
To be illustrated, the second default hashing algorithm can also be hidden in the upgrade code.In the specific implementation, the upgrading generation
The corresponding characteristic value of code is stored in the second predetermined position in the upgrade code, for example, the first row of code.Example is only
It is a kind of implementation of the embodiment of the present invention, can be different in actual use, restriction should not be constituted.
In the specific implementation, in processor 1001 in the corresponding calculated result of the upgrade code and the upgrade code
When whether corresponding characteristic value is consistent, if comparison result is inconsistent, processor 1001 can be defeated by output device 1004
Second prompt information out, for prompting upgrade code mistake described in user.
It will be appreciated that processor 1001 can also be with reference to the tool in above-mentioned Fig. 1 to Fig. 3 embodiment of the method the step of execution
Body implementation, which is not described herein again.
It should be noted that code upgrade device 100 can be individual control device in practical application, such as automobile-used examine
Disconnected instrument code reading card, code upgrade device 100 can also be integrated in other smart machines, for example, mobile phone, tablet computer etc..
In conclusion implementing the embodiment of the present invention, by verifying to the integrality of upgrade file, such as in upgrading
Fruit upgrade file be it is correctly complete, then continue to upgrade, and when running the executable file in the upgrade file, to can
The upgrade code executed in file is verified, out of service described executable if the code error in executable file
File can avoid unit exception caused by exception upgrade file is performed.
Module or submodule in all embodiments of the invention can pass through universal integrated circuit, such as CPU (Central
Processing Unit, central processing unit), or pass through ASIC (Application Specific Integrated
Circuit, specific integrated circuit) Lai Shixian.
The step of method of the embodiment of the present invention, sequentially can be adjusted according to actual needs, merges or delete.This hair
The module of the device of bright embodiment can be integrated according to actual needs, further division or deletion.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with
Relevant hardware is instructed to complete by computer program, the program can be stored in a computer-readable storage medium
In, the program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, the storage medium can be magnetic
Dish, CD, read-only memory (Read-Only Memory, ROM) or random access memory (Random Access
Memory, RAM) etc..
The above disclosure is only the preferred embodiments of the present invention, cannot limit the right model of the present invention with this certainly
It encloses, therefore equivalent changes made in accordance with the claims of the present invention, is still within the scope of the present invention.
Claims (8)
1. a kind of code upgrade method characterized by comprising
When the file under using target directory is upgraded, the upgrade file under the target directory is identified;
The upgrade file is calculated each by the first default hashing algorithm, it is corresponding to obtain the upgrade file
Whether calculated result, the corresponding calculated result of upgrade file and the corresponding characteristic value of the upgrade file
Unanimously;Alternatively,
The upgrade file of different function is passed through the described first default hashing algorithm to calculate respectively, obtains the different function
The corresponding calculated result of upgrade file, the corresponding calculated result of the upgrade file of the different function and institute
Whether the corresponding characteristic value of upgrade file for stating different function is consistent;Alternatively,
The whole upgrade files that will identify that are calculated by the described first default hashing algorithm, obtain all upgrading texts
The characteristic value of the calculated result of part, the calculated result of the whole upgrade files and whole upgrade files whether one
It causes;If so, the upgrade file is complete, if it is not, the then upgrade file damage;
If so, being upgraded according to the upgrade file, if it is not, then stopping upgrading;
If the upgrade file is complete, operation of the reception to trigger the executable file in the operation upgrade file
Whether instruction, and when running the executable file in the upgrade file verifies upgrade code in the executable file
Correctly, if so, executing the upgrade code.
2. the method as described in claim 1, which is characterized in that whether the upgrade code in the verifying executable file
Correctly, comprising: the upgrade code is calculated by the second default hashing algorithm, obtains the corresponding meter of the upgrade code
Calculate result;The upgrade code is corresponding with characteristic value;
Whether consistent compare the corresponding calculated result of upgrade code characteristic value corresponding with the upgrade code, if so,
The upgrade code is correctly, if it is not, then the upgrade code is wrong.
3. the method as described in claim 1, which is characterized in that in the corresponding calculating knot of the upgrade file
When whether fruit and the corresponding characteristic value of the upgrade file are consistent, further includes: if comparison result is inconsistent, export the
One prompt information, the upgrade file damage for prompting comparison result described in user inconsistent.
4. method according to claim 2, which is characterized in that the corresponding calculated result of the upgrade code with
When whether the corresponding characteristic value of the upgrade code is consistent, further includes: if comparison result is inconsistent, output the second prompt letter
Breath, for prompting upgrade code mistake described in user.
5. a kind of code upgrade device characterized by comprising
Identification module, for identifying to be upgraded under the target directory when the file under to target directory upgrades
File;
First inspection module, first inspection module include the first computing module and the first comparison module, and described first calculates
It is respectively right to obtain the upgrade file for calculating the upgrade file each by the first default hashing algorithm for module
The calculated result answered, first comparison module is for the corresponding calculated result of the upgrade file and the upgrading
Whether the corresponding characteristic value of file is consistent;Alternatively,
First computing module is used to respectively pass through the upgrade file of different function the described first default hashing algorithm and carries out
Calculate, obtain the corresponding calculated result of upgrade file of the different function, first comparison module relatively it is described not
The corresponding calculated result of the upgrade file of congenerous and the corresponding characteristic value of upgrade file of the different function are
It is no consistent;Alternatively,
Based on whole upgrade files of first computing module by will identify that are carried out by the described first default hashing algorithm
It calculates, obtains the calculated result of whole upgrade files, the calculating of first comparison module whole upgrade files
As a result whether consistent with the characteristic value of whole upgrade files;If so, the upgrade file is completely, if it is not, then institute
State upgrade file damage;
Upgraded module, for being upgraded according to the upgrade file when the output result of first inspection module, which is, is,
When the output result of first inspection module is no, stop upgrading;
Second inspection module, if being completely, to receive to trigger in the operation upgrade file for the upgrade file
The operating instruction of executable file verify the executable text and when running the executable file in the upgrade file
Whether the upgrade code in part is correct;
Execution module, for executing the upgrade code when the output result of second inspection module, which is, is.
6. device as claimed in claim 5, which is characterized in that second inspection module, comprising:
Second computing module obtains the upgrading for calculating the upgrade code by the second default hashing algorithm
The corresponding calculated result of code;The upgrade code is corresponding with characteristic value;
Second comparison module is used for the corresponding calculated result of upgrade code characteristic value corresponding with the upgrade code
It is whether consistent, if so, the upgrade code is correctly, if it is not, then the upgrade code is wrong.
7. device as claimed in claim 5, which is characterized in that further include: the first cue module, for comparing described first
Whether the corresponding calculated result of the module upgrade file and the corresponding characteristic value of the upgrade file are consistent
When, if comparison result is inconsistent, the first prompt information is exported, the upgrading for prompting comparison result described in user inconsistent
File corruption.
8. device as claimed in claim 6, which is characterized in that further include: the second cue module, for comparing described second
When whether the corresponding calculated result of module upgrade code characteristic value corresponding with the upgrade code is consistent, if than
It is inconsistent compared with result, then the second prompt information is exported, for prompting upgrade code mistake described in user.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510192011.9A CN104850427B (en) | 2015-04-22 | 2015-04-22 | A kind of code upgrade method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510192011.9A CN104850427B (en) | 2015-04-22 | 2015-04-22 | A kind of code upgrade method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104850427A CN104850427A (en) | 2015-08-19 |
CN104850427B true CN104850427B (en) | 2019-08-30 |
Family
ID=53850085
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510192011.9A Active CN104850427B (en) | 2015-04-22 | 2015-04-22 | A kind of code upgrade method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104850427B (en) |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105550276A (en) * | 2015-12-10 | 2016-05-04 | 广东欧珀移动通信有限公司 | Method and apparatus for judging completeness of audio upgrading file in network |
CN107273152A (en) * | 2017-05-26 | 2017-10-20 | 安徽贵博新能科技有限公司 | The solution that a kind of anti-locking system ECU software is upgraded by mistake |
CN107688463B (en) * | 2017-09-21 | 2020-08-18 | 杭州全维技术股份有限公司 | Method for packaging version file of embedded equipment |
CN109669709B (en) * | 2018-11-26 | 2022-04-08 | 杭州溪塔科技有限公司 | Data migration method and data migration system for block chain upgrading |
CN111176685A (en) * | 2019-12-27 | 2020-05-19 | 深圳市优必选科技股份有限公司 | Upgrading method and device |
CN112506543B (en) * | 2020-12-07 | 2023-07-14 | 天津津航计算技术研究所 | Multi-device software upgrading management method and system |
CN112596800A (en) * | 2020-12-26 | 2021-04-02 | 苏州浪潮智能科技有限公司 | U-Boot image upgrading and checking method and device and electronic equipment |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1487740A (en) * | 2002-09-30 | 2004-04-07 | 北京中视联数字系统有限公司 | Software downloading method in digital TV broadcast |
CN101409636A (en) * | 2008-11-20 | 2009-04-15 | 山东山大新元易通信息科技有限公司 | Safety on-line upgrade method for networking equipment firmware |
CN101436141A (en) * | 2008-11-21 | 2009-05-20 | 深圳创维数字技术股份有限公司 | Firmware upgrading and encapsulating method and device based on digital signing |
CN101984406A (en) * | 2010-11-01 | 2011-03-09 | 中兴通讯股份有限公司 | Method and system for upgrading terminal through wireless local area network |
CN102045201A (en) * | 2010-12-27 | 2011-05-04 | 北京锐安科技有限公司 | Automatic upgrading method and system of intranet server cluster |
CN102214112A (en) * | 2011-06-03 | 2011-10-12 | 无锡商埃曲信息科技有限公司 | Set top box upgrading method and system |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB2416046A (en) * | 2004-05-20 | 2006-01-11 | Symbian Software Ltd | Automated software update |
CN102736929A (en) * | 2012-08-03 | 2012-10-17 | 太原理工大学 | Remote on-line upgrade method for terminal controller software of hydraulic support electrohydraulic control system |
CN103685554A (en) * | 2013-12-25 | 2014-03-26 | 浙江云巢科技有限公司 | Upgrading method, device and system |
CN103957244A (en) * | 2014-04-21 | 2014-07-30 | 惠州市新思为电子科技有限公司 | Remote program upgrading method and server |
CN104166565B (en) * | 2014-08-11 | 2017-10-17 | 成都瑞博慧窗信息技术有限公司 | A kind of intelligent display terminal firmware upgrade method |
CN104166564B (en) * | 2014-08-11 | 2017-10-27 | 成都瑞博慧窗信息技术有限公司 | A kind of display terminal method for updating program |
-
2015
- 2015-04-22 CN CN201510192011.9A patent/CN104850427B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1487740A (en) * | 2002-09-30 | 2004-04-07 | 北京中视联数字系统有限公司 | Software downloading method in digital TV broadcast |
CN101409636A (en) * | 2008-11-20 | 2009-04-15 | 山东山大新元易通信息科技有限公司 | Safety on-line upgrade method for networking equipment firmware |
CN101436141A (en) * | 2008-11-21 | 2009-05-20 | 深圳创维数字技术股份有限公司 | Firmware upgrading and encapsulating method and device based on digital signing |
CN101984406A (en) * | 2010-11-01 | 2011-03-09 | 中兴通讯股份有限公司 | Method and system for upgrading terminal through wireless local area network |
CN102045201A (en) * | 2010-12-27 | 2011-05-04 | 北京锐安科技有限公司 | Automatic upgrading method and system of intranet server cluster |
CN102214112A (en) * | 2011-06-03 | 2011-10-12 | 无锡商埃曲信息科技有限公司 | Set top box upgrading method and system |
Also Published As
Publication number | Publication date |
---|---|
CN104850427A (en) | 2015-08-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104850427B (en) | A kind of code upgrade method and device | |
US11036507B2 (en) | Processor testing using pairs of counter incrementing and branch instructions | |
CN107783776B (en) | Processing method and device of firmware upgrade package and electronic equipment | |
CN105302711B (en) | Application restoration method and device and terminal | |
KR20130027158A (en) | Apparatus and method for management of optimized virtualization module in embedded system | |
CN106843976B (en) | Method and apparatus for generating image file | |
CN107832065A (en) | Firmware upgrade method, water purifier, upgrade-system and readable storage medium storing program for executing | |
CN107967424A (en) | A kind of verification method of plug-in unit, device, terminal device and storage medium | |
CN105045671B (en) | The method for upgrading system and device of a kind of intelligent terminal | |
CN110659210A (en) | Information acquisition method and device, electronic equipment and storage medium | |
CN109543409B (en) | Method, device and equipment for detecting malicious application and training detection model | |
CN106709281A (en) | Patch releasing and obtaining method and device | |
CN108196975B (en) | Data verification method and device based on multiple checksums and storage medium | |
KR20140048094A (en) | Method for programming a mobile terminal chip | |
CN108089870A (en) | For repairing the method and apparatus of application | |
CN113467784A (en) | Application program processing method and device and computer readable storage medium | |
CN110889116A (en) | Advertisement blocking method and device and electronic equipment | |
CN109495798A (en) | ONU method for upgrading system, device, equipment and computer readable storage medium | |
CN110633196A (en) | Automatic use case execution method and device of application program | |
CN112199270B (en) | Program testing method, device, equipment and medium | |
CN113568834A (en) | SDK code compatibility detection method, device, computer equipment and medium | |
CN108345461B (en) | Application updating method and device and computer readable storage medium | |
CN111506299B (en) | Front-end data verification method and device and computer equipment | |
CN109408120A (en) | Os starting optimization | |
CN112527336B (en) | Operating system software installation method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
EXSB | Decision made by sipo to initiate substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |