CN104850427A - Method and device for upgrading code - Google Patents

Method and device for upgrading code Download PDF

Info

Publication number
CN104850427A
CN104850427A CN201510192011.9A CN201510192011A CN104850427A CN 104850427 A CN104850427 A CN 104850427A CN 201510192011 A CN201510192011 A CN 201510192011A CN 104850427 A CN104850427 A CN 104850427A
Authority
CN
China
Prior art keywords
upgrade
file
code
described upgrade
upgrade file
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.)
Granted
Application number
CN201510192011.9A
Other languages
Chinese (zh)
Other versions
CN104850427B (en
Inventor
刘均
李剑锋
邓芳鸿
张明虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Launch Technology Co Ltd
Original Assignee
Shenzhen Launch Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Launch Technology Co Ltd filed Critical Shenzhen Launch Technology Co Ltd
Priority to CN201510192011.9A priority Critical patent/CN104850427B/en
Publication of CN104850427A publication Critical patent/CN104850427A/en
Application granted granted Critical
Publication of CN104850427B publication Critical patent/CN104850427B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a method for upgrading a code, comprising the steps as follows: recognizing an upgrade file under a target directory when using a file under the target directory to upgrade; verifying whether the upgrade file is integrated, upgrading according to the upgrade file if the upgrade file is integrated, otherwise stopping upgrading; verifying whether an upgrade code in an executable file is correct when operating the executable file in the upgrade file if the upgrade file is integrated, and executing the upgrade code if the upgrade code is correct. Correspondingly, the invention further discloses a device. The method and the device can be used for avoiding unit exception brought by the condition that an abnormal upgrade file is executed.

Description

A kind of code upgrade method and device
Technical field
The present invention relates to electronic technology field, particularly relate to a kind of code upgrade method and device.
Background technology
The online upgrading function of current automobile-used diagnostic equipment code reading card is ubiquity and often uses.When carrying out online upgrading, if do not carry out validity check to the upgrade data of write device, so the file of write device may be unknown data, and the upgrade data running the mistake in write device likely causes functions of the equipments abnormal, even device damage.
Summary of the invention
The invention provides a kind of code upgrade method and device, by verifying upgrade file, and performing the validity verifying upgrade code before upgrade code, abnormal upgrade file can be avoided to be performed and the unit exception that causes.
First aspect, the embodiment of the invention discloses a kind of code upgrade method, the method comprises:
When utilizing the file under target directory to upgrade, identify the upgrade file under described target directory;
Verify whether described upgrade file is complete, if so, then upgrades according to described upgrade file, if not, then stop upgrading;
If described upgrade file is complete, when running the executable file in described upgrade file, verifying that whether the upgrade code in described executable file is correct, if so, then performing described upgrade code.
In conjunction with first aspect, in the implementation that the first is possible, described upgrade file is separately to having eigenwert; Whether the described upgrade file of described checking is complete, comprising:
Described upgrade file is preset hashing algorithm each via first calculate, obtain each self-corresponding result of calculation of described upgrade file;
Whether characteristic of correspondence value is consistent separately for each self-corresponding result of calculation of more described upgrade file and described upgrade file, and if so, then described upgrade file is complete, and if not, then described upgrade file damages.
In conjunction with first aspect, in the implementation that the second is possible, whether the upgrade code in the described executable file of described checking is correct, comprising: described upgrade code is preset hashing algorithm by second and calculates, obtain the result of calculation that described upgrade code is corresponding; Described upgrade code is to having eigenwert;
Whether the result of calculation that more described upgrade code is corresponding is consistent with described upgrade code characteristic of correspondence value, and if so, then described upgrade code is correct, and if not, then described upgrade code is wrong.
In conjunction with the first possible implementation of first aspect, in the implementation that the third is possible, when whether characteristic of correspondence value is consistent separately with described upgrade file for each self-corresponding result of calculation of described upgrade file, also comprise: if comparative result is inconsistent, then export the first information, damage for the upgrade file of pointing out comparative result described in user inconsistent.
In conjunction with the implementation that the second of first aspect is possible, in the 4th kind of possible implementation, when whether the result of calculation that described upgrade code is corresponding is consistent with described upgrade code characteristic of correspondence value, also comprise: if comparative result is inconsistent, then export the second information, for pointing out upgrade code mistake described in user.
Second aspect, the embodiment of the invention discloses a kind of code upgrade device, this device comprises:
Identification module, for when upgrading to the file under target directory, identifies the file to be upgraded under described target directory;
First inspection module, for verifying whether described upgrade file is complete;
Upgraded module, for when the Output rusults of described first inspection module is for being, upgrades according to described upgrade file, when the Output rusults of described first inspection module is no, stops upgrading;
Second inspection module, if be complete for described upgrade file, when running the executable file in described upgrade file, verifies that whether the upgrade code in described executable file is correct;
Execution module, for when the Output rusults of described second inspection module is for being, performs described upgrade code.
In conjunction with second aspect, in the implementation that the first is possible, described upgrade file is separately to having eigenwert; Described first inspection module, comprising:
First computing module, calculates for described upgrade file is preset hashing algorithm each via first, obtains each self-corresponding result of calculation of described upgrade file;
First comparison module, for each self-corresponding result of calculation of more described upgrade file, whether characteristic of correspondence value is consistent separately with described upgrade file, and if so, then described upgrade file is complete, and if not, then described upgrade file damages.
In conjunction with second aspect, in the implementation that the second is possible, described second inspection module, comprising:
Second computing module, calculates for described upgrade code is preset hashing algorithm by second, obtains the result of calculation that described upgrade code is corresponding; Described upgrade code is to having eigenwert;
Second comparison module, whether the result of calculation corresponding for more described upgrade code is consistent with described upgrade code characteristic of correspondence value, and if so, then described upgrade code is correct, and if not, then described upgrade code is wrong.
In conjunction with the first possible implementation of second aspect, in the implementation that the third is possible, described device also comprises: the first reminding module, for when whether characteristic of correspondence value is consistent separately with described upgrade file for each self-corresponding result of calculation of the more described upgrade file of described first comparison module, if comparative result is inconsistent, then export the first information, damage for the upgrade file of pointing out comparative result described in user inconsistent.
In conjunction with the implementation that the second of second aspect is possible, in the 4th kind of possible implementation, described device also comprises: the second reminding module, time whether consistent with described upgrade code characteristic of correspondence value for the result of calculation corresponding at the more described upgrade code of described second comparison module, if comparative result is inconsistent, then export the second information, for pointing out upgrade code mistake described in user.
Implement the present invention, by when upgrading, the integrality of upgrade file is verified, if upgrade file is correct complete, then continue upgrading, and when running the executable file in described upgrade file, upgrade code in executable file is verified, if the code error in executable file, then described executable file out of service, can avoid abnormal upgrade file to be performed and the unit exception caused.
Accompanying drawing explanation
In order to be illustrated more clearly in technical scheme of the present invention, below the accompanying drawing used required in describing the present invention is briefly described, apparently, accompanying drawing in the following describes is some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Fig. 1 is the process flow diagram of the first embodiment of code upgrade method provided by the invention;
Fig. 2 is the process flow diagram of the second embodiment of code upgrade method provided by the invention;
Fig. 3 is the process flow diagram of the 3rd embodiment of code upgrade method provided by the invention;
Fig. 4 is the structural representation of the first embodiment of code upgrade device provided by the invention;
Fig. 5 is the structural representation of the second embodiment of code upgrade device provided by the invention;
Fig. 6 is the structural representation of the 3rd embodiment of code upgrade device provided by the invention;
Fig. 7 is the structural representation of the 4th embodiment of code upgrade device provided by the invention.
Embodiment
Below in conjunction with drawings and Examples of the present invention, be clearly and completely described the technical scheme in the present invention, obviously, described embodiment is the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
Fig. 1 is the process flow diagram of the first embodiment of the code upgrade method that the embodiment of the present invention provides, and the method comprises:
Step S101: when utilizing the file under target directory to upgrade, identifies the upgrade file under described target directory.
Concrete, described target directory can be the catalogue on far-end server, and updating apparatus is connected by network service, such as Wi-Fi, is connected with far-end server, downloads the upgrade file under the target directory on far-end server.Described target directory also can be the catalogue on local host, and updating apparatus is connected by local, and such as, USB connects or serial ports connects, and obtains the upgrade data that main frame sends.
In specific implementation, the upgrade data under described target directory can be packaged into upgrading data packet.When updating apparatus downloads upgrading data packet from described target directory, identifiable design goes out the upgrade file in described upgrading data packet, in order to verify whether described upgrade file is complete upgrade file.
Step S103: verify whether described upgrade file is complete.
Concrete, after downloading to described upgrade file from described target directory, updating apparatus can verify whether the described upgrade file downloaded to is complete upgrade file.
In the embodiment of the present invention, updating apparatus verifies the integrality of upgrade file by Message Digest 5 (Message Digest Algorithm).In specific implementation, upgrade file can be fixed the informative abstract of figure place by the provider of upgrade data by Message Digest 5, and the informative abstract of generation is hidden in upgrade file.Updating apparatus is after downloading to upgrade file, and the eap-message digest that can be used by described upgrade data provider processes the upgrade file downloaded to.If the informative abstract that the upgrade file downloaded to calculates is consistent with the informative abstract hidden in upgrade file, then updating apparatus can judge that the upgrade file downloaded to is complete, is not damaged in downloading process.Needs illustrate, in the proof procedure carrying out file integrality, the embodiment of the present invention can by each upgrade file correspondence informative abstract in upgrading data packet, also can by corresponding for each function (upgrade files of more than 2 or 2) in a upgrading data packet informative abstract, by corresponding for a whole upgrading data packet informative abstract, can also not be restricted here.
In the embodiment of the present invention, by cyclic redundancy check (CRC) code (Cyclic RedundancyCheck, CRC), updating apparatus also verifies whether the upgrade file downloaded to is complete.In specific implementation, the provider of upgrade data according to described upgrade file information generated field, and can generate CRC code according to described information field, afterwards together using upgrade file and CRC code as upgrade data.Updating apparatus is after receiving the upgrade data downloaded to, and the rule according to following between information field and CRC code is tested, to determine whether upgrade file makes mistakes in transmitting.Needs illustrate, in the proof procedure carrying out file integrality, the embodiment of the present invention can by each upgrade file correspondence CRC code in upgrading data packet, also can by corresponding for each function (upgrade files of more than 2 or 2) in a upgrading data packet CRC code, by corresponding for a whole upgrading data packet CRC code, can also not be restricted here.
Needs illustrate, updating apparatus also goes by other methods of inspection the integrality judging described upgrade file, and the embodiment of the present invention is not restricted.
Concrete, if described upgrade file is complete, that is, do not make mistakes in the process downloading described upgrade file, then perform step S105, otherwise, perform step S107, in practical application, other operations can also be performed, be not restricted here.
Step S105: upgrade according to described upgrade file.
Concrete, if described upgrade file is not damaged in transmitting procedure, the upgrade file that updating apparatus receives is complete, then the upgrade file downloaded to can be written in preset memory and carry out upgrading by updating apparatus.
Step S107: stop upgrading.
Concrete, if the upgrade file that updating apparatus receives is not complete, namely described upgrade file there occurs damage in transmitting procedure, then updating apparatus can stop described upgrade file to be written in preset memory immediately, stops upgrading.
Step S109, when running the executable file in described upgrade file, verifies that whether the upgrade code in described executable file is correct.
Optionally, before execution step S109, updating apparatus can receive operating instruction, in order to trigger the executable file run in described upgrade file.In specific implementation, described operating instruction can be the instruction that user on User Interface inputs generation, and described operating instruction also can be that the physical button on updating apparatus is pressed the instruction produced, and is not restricted here.
In the embodiment of the present invention, updating apparatus verifies the correctness of described upgrade code by Message Digest 5 (Message Digest Algorithm).In specific implementation, described upgrade code can be fixed the informative abstract of figure place by the provider of described upgrade code by Message Digest 5, and the informative abstract of generation is hidden in described upgrade code.Before the described upgrade code of operation, the Message Digest 5 that updating apparatus can adopt the provider of described upgrade code to adopt calculates informative abstract corresponding to described upgrade code, if the informative abstract calculated is consistent with the informative abstract hidden in described upgrade code, then can judge that described upgrade code is correct.
In the embodiment of the present invention, by cyclic redundancy check (CRC) code (Cyclic RedundancyCheck, CRC), updating apparatus also verifies whether described upgrade code is correct.In specific implementation, the provider of described upgrade code according to described upgrade code information generated field, and can generate CRC code according to described information field.Updating apparatus is before the described upgrade code of operation, and the rule according to following between information field and CRC code is tested, to determine whether described upgrade code is correct.
Concrete, if described upgrade code is correct, then can judge in the process of carrying out upgrading according to described upgrade file, mistake is not produced by the process of the upgrade code write preset memory in described executable file, namely described upgrade code is correct, performs step S111, otherwise, then can judge to there occurs mistake in escalation process, terminate current operation.
Step S111: perform described upgrade code.
Implement the embodiment of the present invention, by when upgrading, the integrality of upgrade file is verified, if upgrade file is correct complete, then upgrade file is write preset memory to complete upgrading, and when running the executable file in described upgrade file, upgrade code in executable file is verified, if the code in executable file is correct, then run described executable file, can realize carrying out correct effective upgrading to updating apparatus.
Fig. 2 is the process flow diagram of the second embodiment of the code upgrade method that the embodiment of the present invention provides.The embodiment of Fig. 2 further describes the validation verification method of the upgrade file that the embodiment of the present invention provides in detail.The content do not mentioned in the embodiment of Fig. 2 please refer to the content described in Fig. 1 embodiment.The method comprises:
Step S201: when utilizing the file under target directory to upgrade, identifies the upgrade file under described target directory.
Concrete, described target directory can be the catalogue on far-end server, and updating apparatus is connected by network service, such as Wi-Fi, is connected with far-end server, downloads the upgrade file under the target directory on far-end server.Described target directory also can be the catalogue on local host, and updating apparatus is connected by local, and such as, USB connects or serial ports connects, and obtains the upgrade data that main frame sends.
In specific implementation, the upgrade data under described target directory can be packaged into upgrading data packet.When updating apparatus downloads upgrading data packet from described target directory, identifiable design goes out the upgrade file in described upgrading data packet, in order to verify whether described upgrade file is complete upgrade file.
Step S203: described upgrade file is preset hashing algorithm each via first and calculates, obtain each self-corresponding result of calculation of described upgrade file.
Concrete, described first presets provider that hashing algorithm is upgrade data and the hashing algorithm that updating apparatus is made an appointment, such as MD5 algorithm.The provider of upgrade data presets hashing algorithm by described first and described upgrade file is generated the eigenwert corresponded, and described upgrade file characteristic of correspondence value is hidden in described upgrade file.Needs illustrate, described first presets hashing algorithm also can be hidden in described upgrade file.
Concrete, when updating apparatus downloads to described upgrade file, the described upgrade file received can be carried out the calculating that described first presets hashing algorithm by updating apparatus, draws result of calculation.
Preferably, in the embodiment of the present invention, each upgrade file in upgrading data packet can be carried out once the hash operations that described first presets hashing algorithm by the provider of upgrade data, that is, the corresponding hash eigenwert of each upgrade file; Accordingly, after downloading to described upgrade file, updating apparatus needs to preset hashing algorithm to each upgrade file according to described first and carries out a hash operations, obtain the result of calculation that each upgrade file is corresponding, whether consistent with the hash eigenwert hidden in each upgrade file in order to the result of calculation comparing each upgrade file.
Needs illustrate, the corresponding hash eigenwert of the function bag (comprising the upgrade file of more than 2 or 2) that each in upgrading data packet also can upgrade by the embodiment of the present invention, so, updating apparatus needs to preset hashing algorithm to each function bag upgraded according to described first and carries out a hash operations, obtain the result of calculation that each function bag upgraded is corresponding, whether consistent with the hash eigenwert hidden in the function bag that each upgrades in order to the result of calculation comparing the function bag that each upgrades.The embodiment of the present invention can also by corresponding for a whole upgrading data packet hash eigenwert, and so, updating apparatus only needs to preset hashing algorithm to whole upgrading data packet according to described first and carries out a hash operations.
Will be understood that, due to the feature of hashing algorithm, can realize larger information to be verified, such as described upgrade file, the hash eigenwert that corresponding one-tenth is less, can reduce the use of storage resources, very be suitable for the equipment that storage resources is limited, such as automobile-used diagnostic equipment code reading card.
Step S205: whether characteristic of correspondence value is consistent separately for each self-corresponding result of calculation of more described upgrade file and described upgrade file.
Concrete, described upgrade file separately characteristic of correspondence value is stored in the first predetermined position of described upgrade file separately, such as, and last column of file.Example is only a kind of implementation of the embodiment of the present invention, can be different in actual use, should not form restriction.
Execution step S203 after, updating apparatus can each self-corresponding result of calculation of more described upgrade file whether characteristic of correspondence value consistent separately with described upgrade file.If comparative result is consistent, that is, the downloading process of described upgrade file is not made mistakes, then perform step S205, otherwise, perform step S207, in practical application, other operations can also be performed, be not restricted here.
Step S207: described upgrade file is complete, upgrades according to described upgrade file.
Concrete, if described upgrade file is not damaged in transmitting procedure, the upgrade file that updating apparatus receives is complete, then the upgrade file downloaded to can be written in preset memory and carry out upgrading by updating apparatus.
Step S209: described upgrade file damages, stops upgrading.
Concrete, if the upgrade file that updating apparatus receives is not complete, namely described upgrade file there occurs damage in transmitting procedure, then updating apparatus can stop described upgrade file to be written in preset memory immediately, stops upgrading.
In addition, if the upgrade file that updating apparatus receives is not complete, namely described upgrade file there occurs damage in transmitting procedure, and updating apparatus is exportable first information also, damages for the upgrade file of pointing out comparative result described in user inconsistent.
Implement the embodiment of the present invention, the integrality of described upgrade file is verified by hashing algorithm, can realize utilizing less storage resources to store described upgrade file characteristic of correspondence value, demonstrate described upgrade file simply and effectively whether to occur damaging in downloading process, if damaging appears in described upgrade file, then stop upgrading immediately, can avoid the upgrade data of mistake write preset memory.
Fig. 3 is the process flow diagram of the 3rd embodiment of the code upgrade method that the embodiment of the present invention provides.The embodiment of Fig. 3 further describes the validation verification method of the executable upgrade code that the embodiment of the present invention provides in detail.The content do not mentioned in the embodiment of Fig. 3 please refer to the content described in Fig. 1 embodiment.The method comprises:
Step S301: upgrade according to upgrade file.
Concrete, if described upgrade file is not damaged in transmitting procedure, the upgrade file that updating apparatus receives is complete, then the upgrade file downloaded to can be written in preset memory and carry out upgrading by updating apparatus, to make the executable file in updating apparatus operation preset memory.
Step S303: described upgrade code is preset hashing algorithm by second and calculates, obtain the result of calculation that described upgrade code is corresponding.
Concrete, described second presets provider that hashing algorithm is described upgrade code and the hashing algorithm that updating apparatus is made an appointment, such as MD5 algorithm.The provider of described upgrade code presets hashing algorithm by described second and described upgrade code is generated the eigenwert corresponded, and described upgrade code characteristic of correspondence value is hidden in described upgrade code.Needs illustrate, described second presets hashing algorithm also can be hidden in described upgrade code.
Concrete, before updating apparatus runs described upgrade code, described upgrade code can be carried out the calculating that described second presets hashing algorithm by updating apparatus, draws result of calculation.
Preferably, the provider of described upgrade code can by the corresponding hash eigenwert of upgrade code of a more New function, described in being hidden in more in New function; Accordingly, after the described preset memory of described more New function write updating apparatus, described in running at updating apparatus more before New function, updating apparatus needs to preset hashing algorithm to the upgrade code of described more New function according to described second and carries out a hash operations, draw result of calculation, in order to more whether the result of calculation of the upgrade code of New function is consistent with the hash eigenwert hidden in described more New function described in relatively.
Needs illustrate, the provider of described upgrade code also by corresponding for a whole upgrade code hash eigenwert, can be hidden in described upgrade code.More accurate in order to locate, the provider of described upgrade code also can by corresponding for every line code of a described upgrade code hash eigenwert.
Will be understood that, due to the feature of hashing algorithm, can realize larger information to be verified, such as, upgrade code in described executable file, the hash eigenwert that corresponding one-tenth is less, can reduce the use of storage resources, very be suitable for the equipment that storage resources is limited, such as automobile-used diagnostic equipment code reading card.
Step S305: whether the result of calculation that more described upgrade code is corresponding is consistent with described upgrade code characteristic of correspondence value.
Concrete, described upgrade code characteristic of correspondence value is stored in the second predetermined position in described upgrade code, such as, and the first row of described upgrade code.Example is only a kind of implementation of the embodiment of the present invention, can be different in actual use, should not form restriction.After execution step S303, updating apparatus can result of calculation corresponding to more described upgrade code whether consistent with described upgrade code characteristic of correspondence value.If comparative result is consistent, that is, the upgrade code in described executable file does not have mistake, then perform step S307, otherwise, then can judge that described upgrade code is wrong, perform step S309.
Step S307: described upgrade code is correct, performs described upgrade code.
Step S309: described upgrade code is wrong, stops performing described upgrade code.
Concrete, if described upgrade code there occurs mistake in escalation process, updating apparatus can also export the second information, for pointing out upgrade code mistake described in user.
Implement the embodiment of the present invention, before operation upgrade code, the correctness of described upgrade code is verified by hashing algorithm, can realize utilizing less storage resources to store described upgrade code characteristic of correspondence value, demonstrate described upgrade code simply and effectively whether to occur damaging, if damaging appears in described upgrade code, then refusal runs described upgrade code, can avoid the device damage caused because of the code of run-time error.
See Fig. 4, be the structural representation of the first embodiment of device provided by the invention, code upgrade device 40 as shown in Figure 4 can comprise: identification module 401, the first inspection module 403, upgraded module 405, the second inspection module 407 and execution module 409.Wherein:
Identification module 401, for when upgrading to the file under target directory, identifies the file to be upgraded under described target directory;
First inspection module 403, for verifying whether described upgrade file is complete;
Upgraded module 405, for when the Output rusults of the first inspection module 403 is for being, upgrades according to described upgrade file, when the Output rusults of described first inspection module is no, stops upgrading;
Second inspection module 407, if be complete for described upgrade file, when running the executable file in described upgrade file, verifies that whether the upgrade code in described executable file is correct;
Execution module 409, for when the Output rusults of the second inspection module 407 is for being, performs described upgrade code.
In the embodiment of the present invention, the first inspection module 403 also can further comprise as shown in Figure 5: the first computing module 4031 and the first comparison module 4033.Wherein:
First computing module 4031, calculates for described upgrade file is preset hashing algorithm each via first, obtains each self-corresponding result of calculation of described upgrade file;
First comparison module 4033, for each self-corresponding result of calculation of more described upgrade file, whether characteristic of correspondence value is consistent separately with described upgrade file, and if so, then described upgrade file is complete, and if not, then described upgrade file damages.
Concrete, described upgrade file is separately to having eigenwert.Described first to preset hashing algorithm be the hashing algorithm that the provider of upgrade data and updating apparatus are made an appointment, such as MD5 algorithm.The provider of upgrade data presets hashing algorithm by described first and described upgrade file is generated the eigenwert corresponded, and described upgrade file characteristic of correspondence value is hidden in described upgrade file.Needs illustrate, described first presets hashing algorithm also can be hidden in described upgrade file.In specific implementation, described upgrade file separately characteristic of correspondence value can be stored in the first predetermined position of described upgrade file separately, such as, and file last column.Example is only a kind of implementation of the embodiment of the present invention, can be different in actual use, should not form restriction.
In the embodiment of the present invention, the second inspection module 407 also can further comprise as shown in Figure 5: the second computing module 4071 and the second comparison module 4073.Wherein:
Second computing module 4071, calculates for described upgrade code is preset hashing algorithm by second, obtains the result of calculation that described upgrade code is corresponding; Described upgrade code is to having eigenwert;
Second comparison module 4073, whether the result of calculation corresponding for more described upgrade code is consistent with described upgrade code characteristic of correspondence value, and if so, then described upgrade code is correct, and if not, then described upgrade code is wrong.
Concrete, described second presets provider that hashing algorithm is described upgrade code and the hashing algorithm that updating apparatus is made an appointment, such as MD5 algorithm.The provider of described upgrade code presets hashing algorithm by described second and described upgrade code is generated the eigenwert corresponded, and described upgrade code characteristic of correspondence value is hidden in described upgrade code.Needs illustrate, described second presets hashing algorithm also can be hidden in described upgrade code.In specific implementation, described upgrade code characteristic of correspondence value is stored in the second predetermined position in described upgrade code, such as, and the first row of code.Example is only a kind of implementation of the embodiment of the present invention, can be different in actual use, should not form restriction.
Further, code upgrade device 40 can also comprise: trigger module, if it is complete that described trigger module is used for described upgrade file, receives operating instruction; Respond described operating instruction, trigger the executable file run in described upgrade file.
See Fig. 6, it is the structural representation of the 3rd embodiment of code upgrade device provided by the invention.As shown in Figure 6, code upgrade device 40 is comprising identification module 401, the first inspection module 403, upgraded module 405, outside the second inspection module 407 and execution module 409, also can comprise: the first reminding module 411 and the second reminding module 413.Wherein:
First reminding module 411, for when whether characteristic of correspondence value is consistent separately with described upgrade file for each self-corresponding result of calculation of the more described upgrade file of the first comparison module 4033, if comparative result is inconsistent, then export the first information, damage for the upgrade file of pointing out comparative result described in user inconsistent.
Second reminding module 413, time whether consistent with described upgrade code characteristic of correspondence value for the result of calculation corresponding at the more described upgrade code of the second comparison module 4073, if comparative result is inconsistent, then export the second information, for pointing out upgrade code mistake described in user.
See Fig. 7, it is the structural representation of the 4th embodiment of code upgrade device provided by the invention.Wherein, as shown in Figure 7, this device 100 can comprise: at least one processor 1001, such as CPU, at least one bus 1002, at least one input media 1003, at least one output unit 1004, storer 1005.Wherein, bus 1002 is for realizing the communication connection between these assemblies; Input media 1003 can comprise touch-screen (Touch Screen), and optional input media 1003 can also comprise keyboard (Keyboard), or other physical buttons, such as, and volume key; Output unit 1004 can comprise display screen (Display); Storer 1005 can be high-speed RAM storer, also can be non-labile storer (non-volatilememory), such as at least one magnetic disk memory, storer 1005 can also be optionally that at least one is positioned at the memory storage away from aforementioned processor 1001.As shown in Figure 7, operating system, network communication module, Subscriber Interface Module SIM and code verification program can be comprised as in a kind of storer 1005 of computer-readable storage medium.
In the code upgrade device 100 shown in Fig. 7, processor 1001 can call the code verification stored in storer 1005, and performs following operation:
When utilizing the file under target directory to upgrade, identify the upgrade file under described target directory;
Verify whether described upgrade file is complete, if so, then upgrades according to described upgrade file, if not, then stop upgrading;
If described upgrade file is complete, when running the executable file in described upgrade file, verifying that whether the upgrade code in described executable file is correct, if so, then performing described upgrade code.
Concrete, if described upgrade file is complete, processor 1001 also receives operating instruction by input media 1003, in order to trigger the executable file run in described upgrade file.
Further, described upgrade file is separately to having eigenwert.Whether processor 1001 performs the described upgrade file of described checking is that complete step can specifically comprise:
Described upgrade file is preset hashing algorithm each via first and is calculated by processor 1001, obtains each self-corresponding result of calculation of described upgrade file;
Whether characteristic of correspondence value is consistent separately for each self-corresponding result of calculation of the more described upgrade file of processor 1001 and described upgrade file, and if so, then described upgrade file is complete, and if not, then described upgrade file damages.
Concrete, described upgrade file is separately to having eigenwert.Described first to preset hashing algorithm be the hashing algorithm that the provider of upgrade data and updating apparatus are made an appointment, such as MD5 algorithm.The provider of upgrade data presets hashing algorithm by described first and described upgrade file is generated the eigenwert corresponded, and described upgrade file characteristic of correspondence value is hidden in described upgrade file.Needs illustrate, described first presets hashing algorithm also can be hidden in described upgrade file.In specific implementation, described upgrade file separately characteristic of correspondence value can be stored in the first predetermined position of described upgrade file separately, such as, and file last column.Example is only a kind of implementation of the embodiment of the present invention, can be different in actual use, should not form restriction.
In specific implementation, when whether characteristic of correspondence value is consistent separately with described upgrade file for each self-corresponding result of calculation of the more described upgrade file of processor 1001, if comparative result is inconsistent, then processor 1001 can export the first information by output unit 1004, damages for the upgrade file of pointing out comparative result described in user inconsistent.
Further, the step that whether correct processor 1001 perform upgrade code in the described executable file of described checking can comprise:
Described upgrade code is preset hashing algorithm by second and is calculated by processor 1001, obtains the result of calculation that described upgrade code is corresponding; Described upgrade code is to having eigenwert;
Whether the result of calculation that the more described upgrade code of processor 1001 is corresponding is consistent with described upgrade code characteristic of correspondence value, and if so, then described upgrade code is correct, and if not, then described upgrade code is wrong.
Concrete, described second presets provider that hashing algorithm is described upgrade code and the hashing algorithm that updating apparatus is made an appointment, such as MD5 algorithm.The provider of described upgrade code presets hashing algorithm by described second and described upgrade code is generated the eigenwert corresponded, and described upgrade code characteristic of correspondence value is hidden in described upgrade code.Needs illustrate, described second presets hashing algorithm also can be hidden in described upgrade code.In specific implementation, described upgrade code characteristic of correspondence value is stored in the second predetermined position in described upgrade code, such as, and the first row of code.Example is only a kind of implementation of the embodiment of the present invention, can be different in actual use, should not form restriction.
In specific implementation, at processor 1001 when whether the result of calculation that more described upgrade code is corresponding is consistent with described upgrade code characteristic of correspondence value, if comparative result is inconsistent, then processor 1001 can export the second information by output unit 1004, for pointing out upgrade code mistake described in user.
Will be understood that, the step that processor 1001 performs with reference to the specific implementation in above-mentioned Fig. 1 to Fig. 3 embodiment of the method, can also repeat no more here.
Needs illustrate, in practical application, code upgrade device 100 can be independent control device, such as automobile-used diagnostic equipment code reading card, and code upgrade device 100 can also be integrated in other smart machines, such as, and mobile phone, panel computer etc.
In sum, implement the embodiment of the present invention, by when upgrading, the integrality of upgrade file is verified, if upgrade file is correct complete, then continue upgrading, and when running the executable file in described upgrade file, the upgrade code in executable file is verified, if the code error in executable file, then described executable file out of service, can avoid abnormal upgrade file to be performed and the unit exception caused.
Module in all embodiments of the present invention or submodule, universal integrated circuit can be passed through, such as CPU (Central Processing Unit, central processing unit), or realized by ASIC (Application SpecificIntegrated Circuit, special IC).
The sequence of steps of the method for the embodiment of the present invention can carry out adjusting, merge or deleting according to actual needs.The module of the device of the embodiment of the present invention can carry out integrating according to actual needs, Further Division or delete.
One of ordinary skill in the art will appreciate that all or part of flow process realized in above-described embodiment method, that the hardware that can carry out instruction relevant by computer program has come, described program can be stored in a computer read/write memory medium, this program, when performing, can comprise the flow process of the embodiment as above-mentioned each side method.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc.
Above disclosedly be only present pre-ferred embodiments, certainly can not limit the interest field of the present invention with this, therefore according to the equivalent variations that the claims in the present invention are done, still belong to the scope that the present invention is contained.

Claims (10)

1. a code upgrade method, is characterized in that, comprising:
When utilizing the file under target directory to upgrade, identify the upgrade file under described target directory;
Verify whether described upgrade file is complete, if so, then upgrades according to described upgrade file, if not, then stop upgrading;
If described upgrade file is complete, when running the executable file in described upgrade file, verifying that whether the upgrade code in described executable file is correct, if so, then performing described upgrade code.
2. the method for claim 1, is characterized in that, described upgrade file is separately to having eigenwert; Whether the described upgrade file of described checking is complete, comprising:
Described upgrade file is preset hashing algorithm each via first calculate, obtain each self-corresponding result of calculation of described upgrade file;
Whether characteristic of correspondence value is consistent separately for each self-corresponding result of calculation of more described upgrade file and described upgrade file, and if so, then described upgrade file is complete, and if not, then described upgrade file damages.
3. the method for claim 1, is characterized in that, whether the upgrade code in the described executable file of described checking is correct, comprising: described upgrade code is preset hashing algorithm by second and calculates, obtain the result of calculation that described upgrade code is corresponding; Described upgrade code is to having eigenwert;
Whether the result of calculation that more described upgrade code is corresponding is consistent with described upgrade code characteristic of correspondence value, and if so, then described upgrade code is correct, and if not, then described upgrade code is wrong.
4. method as claimed in claim 2, it is characterized in that, when whether characteristic of correspondence value is consistent separately with described upgrade file for each self-corresponding result of calculation of described upgrade file, also comprise: if comparative result is inconsistent, then export the first information, damage for the upgrade file of pointing out comparative result described in user inconsistent.
5. method as claimed in claim 3, it is characterized in that, when whether the result of calculation that described upgrade code is corresponding is consistent with described upgrade code characteristic of correspondence value, also comprise: if comparative result is inconsistent, then export the second information, for pointing out upgrade code mistake described in user.
6. a code upgrade device, is characterized in that, comprising:
Identification module, for when upgrading to the file under target directory, identifies the file to be upgraded under described target directory;
First inspection module, for verifying whether described upgrade file is complete;
Upgraded module, for when the Output rusults of described first inspection module is for being, upgrades according to described upgrade file, when the Output rusults of described first inspection module is no, stops upgrading;
Second inspection module, if be complete for described upgrade file, when running the executable file in described upgrade file, verifies that whether the upgrade code in described executable file is correct;
Execution module, for when the Output rusults of described second inspection module is for being, performs described upgrade code.
7. device as claimed in claim 6, it is characterized in that, described upgrade file is separately to having eigenwert; Described first inspection module, comprising:
First computing module, calculates for described upgrade file is preset hashing algorithm each via first, obtains each self-corresponding result of calculation of described upgrade file;
First comparison module, for each self-corresponding result of calculation of more described upgrade file, whether characteristic of correspondence value is consistent separately with described upgrade file, and if so, then described upgrade file is complete, and if not, then described upgrade file damages.
8. device as claimed in claim 6, it is characterized in that, described second inspection module, comprising:
Second computing module, calculates for described upgrade code is preset hashing algorithm by second, obtains the result of calculation that described upgrade code is corresponding; Described upgrade code is to having eigenwert;
Second comparison module, whether the result of calculation corresponding for more described upgrade code is consistent with described upgrade code characteristic of correspondence value, and if so, then described upgrade code is correct, and if not, then described upgrade code is wrong.
9. device as claimed in claim 7, it is characterized in that, also comprise: the first reminding module, for when whether characteristic of correspondence value is consistent separately with described upgrade file for each self-corresponding result of calculation of the more described upgrade file of described first comparison module, if comparative result is inconsistent, then export the first information, damage for the upgrade file of pointing out comparative result described in user inconsistent.
10. device as claimed in claim 8, it is characterized in that, also comprise: the second reminding module, time whether consistent with described upgrade code characteristic of correspondence value for the result of calculation corresponding at the more described upgrade code of described second comparison module, if comparative result is inconsistent, then export the second information, for pointing out upgrade code mistake described in user.
CN201510192011.9A 2015-04-22 2015-04-22 A kind of code upgrade method and device Active CN104850427B (en)

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 true CN104850427A (en) 2015-08-19
CN104850427B 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)

Cited By (7)

* Cited by examiner, † Cited by third party
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
CN107688463A (en) * 2017-09-21 2018-02-13 杭州全维技术股份有限公司 A kind of method of embedded device version file packing
CN109669709A (en) * 2018-11-26 2019-04-23 杭州秘猿科技有限公司 A kind of data migration method and data mover system of the upgrading of block chain
CN111176685A (en) * 2019-12-27 2020-05-19 深圳市优必选科技股份有限公司 Upgrading method and device
CN112506543A (en) * 2020-12-07 2021-03-16 天津津航计算技术研究所 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 (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1487740A (en) * 2002-09-30 2004-04-07 北京中视联数字***有限公司 Software downloading method in digital TV broadcast
CN1965295A (en) * 2004-05-20 2007-05-16 西姆毕恩软件有限公司 Method for release management
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
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
CN104166564A (en) * 2014-08-11 2014-11-26 成都瑞博慧窗信息技术有限公司 Display terminal program updating method
CN104166565A (en) * 2014-08-11 2014-11-26 成都瑞博慧窗信息技术有限公司 Intelligent display terminal firmware updating method

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1487740A (en) * 2002-09-30 2004-04-07 北京中视联数字***有限公司 Software downloading method in digital TV broadcast
CN1965295A (en) * 2004-05-20 2007-05-16 西姆毕恩软件有限公司 Method for release management
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
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
CN104166564A (en) * 2014-08-11 2014-11-26 成都瑞博慧窗信息技术有限公司 Display terminal program updating method
CN104166565A (en) * 2014-08-11 2014-11-26 成都瑞博慧窗信息技术有限公司 Intelligent display terminal firmware updating method

Cited By (10)

* Cited by examiner, † Cited by third party
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
CN107688463A (en) * 2017-09-21 2018-02-13 杭州全维技术股份有限公司 A kind of method of embedded device version file packing
CN107688463B (en) * 2017-09-21 2020-08-18 杭州全维技术股份有限公司 Method for packaging version file of embedded equipment
CN109669709A (en) * 2018-11-26 2019-04-23 杭州秘猿科技有限公司 A kind of data migration method and data mover system of the upgrading of block chain
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
CN112506543A (en) * 2020-12-07 2021-03-16 天津津航计算技术研究所 Multi-device software upgrading management method and system
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

Also Published As

Publication number Publication date
CN104850427B (en) 2019-08-30

Similar Documents

Publication Publication Date Title
CN104850427A (en) Method and device for upgrading code
CN107908485B (en) Interface parameter transmission method, device, equipment and computer readable storage medium
CN109033772B (en) Verification information input method and device
CN105389177A (en) Software version confirmation method, device and system
CN106484453B (en) Method and device for realizing system upgrading
CN107797854B (en) Transaction file processing method and device, storage medium and computer equipment
CN109947449A (en) Method for upgrading system, device, storage medium and electronic equipment
CN112231702B (en) Application protection method, device, equipment and medium
WO2023035901A1 (en) System software upgrading method and apparatus, and device and computer storage medium
CN109684795B (en) Method and device for anti-debugging of application program and electronic equipment
CN110336781A (en) A kind of method and apparatus based on browser identification terminal uniqueness
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
CN112948234A (en) Interface test method and device and electronic equipment
CN111176685A (en) Upgrading method and device
CN110569058A (en) System upgrading method, device, terminal and computer readable storage medium
CN106709281A (en) Patch releasing and obtaining method and device
CN107729043B (en) Method and device for checking increment upgrade package and computer readable storage medium
CN104539607A (en) Information checking method, terminal and server
CN112433935A (en) Test method, test device, electronic equipment and storage medium
CN105653412A (en) Fingerprint device compatibility detection method and terminal
CN109472148B (en) Method, device and storage medium for loading hot patch
CN108255629B (en) Breakpoint data obtaining method and terminal equipment
CN111382416A (en) Application program operation identification method and device, terminal equipment and storage medium
KR101386464B1 (en) Application program download apparatus and method for touch panel in mobile terminal

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