CN106990982A - Program updating method and device - Google Patents
- ️Fri Jul 28 2017
Embodiment
Embodiments of the invention are described below in detail, the example of the embodiment is shown in the drawings, wherein from beginning to end Same or similar label represents same or similar element or the element with same or like function.Below with reference to attached The embodiment of figure description is exemplary, it is intended to for explaining the present invention, and be not considered as limiting the invention.
Below with reference to the accompanying drawings the method for updating program and device of the embodiment of the present invention described.
Fig. 1 is a kind of schematic flow sheet of method for updating program provided in an embodiment of the present invention.As shown in figure 1, the program Update method comprises the following steps:
S101, last time target program update failure after, return restarting the first bootstrap;Wherein, the first guiding Program Solidification is in memory;Target program is application program or the second bootstrap.
In the present embodiment, in order to realize after target program updates failure, it can continue to carry out more target program Newly, two parts will be divided into for the bootstrap (BootLoader) being updated to application program, a part is for mesh In the more new logic that beacon course sequence is updated, the present embodiment, the part is turned into the first bootstrap.Another part be for pair In the code block that application program is updated, the present embodiment, the part is turned into the second bootstrap.Based on the first bootstrap The renewal of target program can be finally completed with the second bootstrap.
In the present embodiment, in order to avoid BootLoader update failure after can not activation system risk, first is drawn Helical pitch sequence is cured in memory.The memory can be flash storage.First bootstrap includes entering target program The more new logic that row updates, when being updated to target program, the first bootstrap can guide system according to the renewal journey Sequence is updated.And due to the solidification of the first bootstrap in memory, can't draw when system update is upgraded to first Helical pitch sequence is updated upgrading.
Need to start from startup position in practical application, when system starts, in the present embodiment, by the first bootstrap It is cured to the startup position in memory.Specifically, the memory space of memory is divided in advance, can be by one of them Memory space is set as the startup position that system starts, and first bootstrap is solidificated in into corresponding first storage in startup position In space.
Target program can be application program, or the second bootstrap isolated from BootLoader.In mesh Beacon course sequence is updated after failure, can restart to attempt to update target program again.In the present embodiment, due to the first guiding journey Sequence solidify in memory, return restarting when, the position of the first bootstrap can be repositioned onto, start this first Bootstrap.When especially target program is the second bootstrap, in the prior art due to bootstrap is not separated into two parts, After bootstrap, which updates, to fail, it will be absorbed in the risk that system can not restart.And in the present embodiment, by bootstrap more New logic, which is separately separated, to be cured in memory, is updated after failure, can also be guided in system reboot even in another part According to more new logic, the second bootstrap is updated again.
S102, the first bootstrap of execution.
S103, according to the more new logic in the first bootstrap, target program is updated again.
After the first bootstrap has been restarted, it is possible to perform first bootstrap.Further, when performing the After one bootstrap, it is possible to according to the more new logic included by the first bootstrap, target program is updated again.
The method for updating program that the present embodiment is provided, after target program updates failure, returns to restarting first and guides Program, wherein the solidification of the first bootstrap is in memory;Target program is application program or the second bootstrap, and is held The bootstrap of row first, according to the more new logic in the first bootstrap, updates target program again.In the present embodiment, it will draw Helical pitch sequence is separated into two parts, and the first bootstrap including more new logic is cured in memory, when target program updates After failure, then it can be repositioned onto the position of the first bootstrap when returning restarting, start first bootstrap Guiding performs more new logic.Especially for BootLoader renewal, also it can continue to after failure is updated to the second guiding journey Sequence is updated, and so as to solve in the prior art, presence can not start and then cause after BootLoader, which updates, to fail The problem of ECU can not be used normally.
Fig. 2 is the schematic flow sheet of another method for updating program provided in an embodiment of the present invention.As shown in Fig. 2 the journey Sequence update method comprises the following steps:
S201, target program are updated after failure, return to the first bootstrap of restarting;Wherein, the first bootstrap is consolidated Change in memory.
Introduction on S201 can be found in the related record in S101 in above-described embodiment, and here is omitted.
S202, the first bootstrap of execution.
The first bootstrap is performed, first bootstrap includes more new logic, can be according to the first bootstrap institute Including more new logic, more new application again.In the present embodiment, the more new logic set is that application program and second guide Program mutually updates.For example, when target program is application program, then completing application program more by the second bootstrap Newly, and when target program is the second bootstrap, then the renewal of the second bootstrap is completed by application program.
In practical application, the renewal of application program needs to complete in the second bootstrap effective status, and second The renewal of bootstrap needs to complete in the case of application program is effective.In the present embodiment, according to application program and the At least one in two bootstrap is in effective status, forms above-mentioned more new logic.
In the present embodiment, if target program is application program, after application program update failure, returns to first and guide journey When being guided after sequence according to more new logic, then it can determine that the second bootstrap is in effective status, so as to continue to update Application program.After application program update success, application program may be in effective status.When needing to the second bootstrap When being updated, it is possible to the second bootstrap is updated by application program.
Similarly, if target program is the second bootstrap, after the second bootstrap, which updates, to fail, return to first and draw When being guided after helical pitch sequence according to more new logic, then it can determine that application program is in effective status, so as to continue to update Application program.After the second bootstrap is updated successfully, the second bootstrap may be in effective status.When needs are to application When program is updated, it is possible to application program is updated by the second bootstrap.
S203, by the first bootstrap judge whether need more new application.
Specifically, when needing more new application or during the second bootstrap, host computer can be by bus to system The indication signal for indicating to need to update is sent, the first bootstrap can be according to indication signal, to judge whether to need more New application.If it is judged that needing more new application, then S204 is performed.
S204, if necessary to more new application and when the second bootstrap is effective, more new application.
Because the renewal of application program needs to complete in the case of the second bootstrap is effective, needs are being judged After more new application, then need to judge whether the second bootstrap is effective, determining the effective feelings of the second bootstrap Under condition, it is possible to enter in the second bootstrap, application program is updated by the second bootstrap.
In the present embodiment, it can judge whether the second bootstrap is effective according to the effective marker position of the second bootstrap. One default value is set for effective marker position in advance, for example, can be " 1 ", when the numerical value of effective marker position is " 1 ", then may be used To judge that the second bootstrap is in effective status.
S205, if necessary to not more new application, in application program effectively and when the second bootstrap needs to update, more New second bootstrap.
Specifically, when the first bootstrap judges not needing more new application according to the indication signal of transmission, then Continue to may determine that whether application program is effective, if application program is effectively, into application program.Further, when second When bootstrap needs to update, then the second bootstrap can be updated.If the second bootstrap need not update, Application program can be performed.
In the present embodiment, it can judge whether application program is effective according to the effective marker position of application program.It is to have in advance Valid flag position sets a default value, for example, can be " 1 ", when the numerical value of effective marker position is " 1 ", then may determine that Application program is in effective status.
In the present embodiment, the more new logic write-in first that application program and the second bootstrap mutually update is guided in advance Program, then the first bootstrap be cured in memory, when target program update fail after, then can return restarting When, the position of the first bootstrap is repositioned onto, starts first bootstrap guiding and performs more new logic.Especially for BootLoader renewal, also can continue to be updated the second bootstrap after failure is updated, existing so as to solve Have in technology that presence can not start and then cause the problem of ECU can not be used normally after BootLoader, which updates, to fail.
Fig. 3 is the schematic flow sheet of another method for updating program provided in an embodiment of the present invention.Destination application can Think application program, or the second bootstrap.Both of which is updated according to the flow shown in Fig. 3.The present embodiment is carried The method for updating program of confession, can be applied in the various control systems such as ECU, MUC.As shown in figure 3, the method for updating program bag Include following steps:
S301, system start the first bootstrap.
In the present embodiment, due to the first bootstrap to be cured to the startup position of memory in advance.When target program more After new failure, then system may return to the startup position of memory, restart the first bootstrap.First bootstrap is just Target program can be updated again according to default more new logic.Destination application can be application program, also may be used Think the second bootstrap.Both updates according to the flow shown in Fig. 3.
In the present embodiment, the more new logic set is that application program and the second bootstrap mutually update.For example, working as target When program is application program, then the renewal of application program is completed by the second bootstrap, and when target program is the second guiding During program, then the renewal of the second bootstrap is completed by application program.In practical application, the renewal of application program is needed the Two bootstrap effective statuses can be completed, and the renewal of the second bootstrap needs the ability in the case of application program is effective It is enough to complete.In the present embodiment, effective status is in according at least one in application program and the second bootstrap, is formed above-mentioned More new logic.
In the present embodiment, the memory space of memory is divided in advance, specifically, the first bootstrap be cured to Start in corresponding first memory space in position.Further, one is chosen from remaining memory space as the second storage Space, the second memory space is used for the configuration parameter for depositing memory, wherein, the distribution that the configuration parameter includes memory is believed Breath, i.e., address information, the content deposited, size of memory space of each memory space etc..Further, configuration parameter is also The effective marker position of effective flag including target program, i.e. application program and the effective marker position of the second bootstrap. When can also include the version number of information, the i.e. application programs such as version number, the renewal time of target program in configuration parameter, update Between and the second bootstrap version number, renewal time.
In the present embodiment, in the residual memory space in addition to the first memory space and the second memory space, to deposit Second bootstrap and application program.Further, application program is operationally, in addition it is also necessary to the key parameter related to system These key parameter values, can be stored separately in an other memory space by value.When performing application program, system can To read nominal data from the memory space for having nominal data is deposited.
For example, 5 memory spaces can be divided the memory into, 5 memory space distributions can be stored:First guiding journey Sequence, configuration parameter, the second bootstrap, the nominal data of application program and application program.Wherein, nominal data is to apply journey Sequence key parameter related to system when performing, as shown in Figure 4.Fig. 4 deposits for a kind of memory provided in an embodiment of the present invention Store up the schematic diagram that space is divided.
S302, system judge whether to need more new application.
In practical application, in burning program in systems first, it is necessary to the bootstrap of burning first, configuration parameter and Second bootstrap, further uses application program to realize, can also together be burnt to application program in systems In memory.Burning can be carried out to program according to above-mentioned memory dividing mode.System can just be entered online after the completion of burning Row upgrading.
When system runs the program of burning first, the first bootstrap is directly entered after startup, then by the first guiding journey Sequence judges whether to need to be updated application program.Specifically, host computer can by bus to system send be used for refer to Show the first signal of needs more new application, the first signal that system is sent based on the first bootstrap according to host computer is sentenced It is disconnected whether to need more new application.S303 is then performed if necessary to update.If need not update, S304 is performed.
Generally, after burning application program in system, when performing the first bootstrap first, system is often not The first signal that host computer is sent by bus can be received, i.e., and need not correspond to and be updated with program.
S303, system judge whether the second bootstrap is effective according to the effective marker position of the second bootstrap.
Specifically, can be from the second memory space where configuration parameter, read the second bootstrap has criterion Will position, if the target program currently to be updated is application program, the effective marker of the second bootstrap is default value, then It may determine that the second bootstrap is in effective status, then perform S305.If the effective marker position of the second bootstrap is non- Default value, then may determine that the second bootstrap is in failure state, illustrates that the second guiding needs to update, then needs to perform S306 continues through application program to update the second bootstrap.
In the present embodiment, renewal for one version of target program, it is necessary to before to the version update for the first time, The default value of the effective marker position of target program is purged, after the once renewal failure to the target program version, Then determine that target program is in failure state according to the effective marker of target program position during next update.
I.e. when target program is the second bootstrap, if last time updates the failure of the second bootstrap, the second guiding journey The default value of the effective marker of sequence can be eliminated when updating last time, according to the effective marker position after removing, it may be determined that go out Second bootstrap is in disarmed state.Disarmed state is in if there is the second bootstrap, then performs S306.
S305, system enter the second bootstrap.
S307, system update application program.
Second bootstrap is used to be updated application program, and after system enters the second bootstrap, system is just Application program can be updated using the code block during second guides into.After the completion of to application program update, system is just It can be resetted.
S304, system judge whether application program is effective according to the effective marker position of application program.
Judge should program need not update when, it is possible to continuing to be judged according to the effective marker of application program position should It is whether effective with program.Specifically, system is stored with configuration parameter in the second memory space of memory, wherein, configuration ginseng Number includes the effective marker of application program and the second bootstrap.System can read application from the second memory space The effective marker position of program.System can judge whether application program is effective according to the numerical value of effective marker position.Generally, If application program need not update, there be the effective marker position of application program for default value, i.e. application program in configuration parameter Effect then performs S306.
When target program is application program, if last time more new application fails, the effective marker of application program Default value can be eliminated when updating last time, according to the effective marker position after removing, it may be determined that go out application program and be in nothing Effect state.Generally, application program is invalid illustrates that the application program needs to update, then needs to perform S307.
In practical application, when application program updated last time after renewal failure and when system is not connected with host computer, Although needing to be updated application program, but the indication signal of host computer transmission can not be received, in such cases, by In the indication signal for not receiving renewal, step S303 judges and need not corresponded to be updated with program, but actually Fail because application program last time updates, it is still desirable to which application program is updated.And due to every time to application program Version enters when updating, it is necessary to before to the version update for the first time, by the default value of the effective marker of application program position It is purged.At no point in the update process, if application program update fails, next time can be according to application program when updating again Effective marker position determines that application program is invalid, in such cases, then needs to perform S307.
S306, system enter application program.
S308, system judge whether to need to update the second bootstrap.
When the second bootstrap needs to update, host computer can be sent by bus to system to be needed to update for instruction The secondary signal of second bootstrap.Further, if receiving secondary signal, system can determine to need to guide second Program is updated, then performs S310.If not receiving secondary signal, system can be determined need not be to the second guiding journey Sequence is updated, then performs S312.
S310, the bootstrap of system update second.
System according to secondary signal when judging to need to be updated the second bootstrap, and system can just update Two bootstrap, specifically, can receive the more new content of the second bootstrap by bus from host computer.Updating After two bootstrap, system reset.
S312, system perform application program.
When application program judges that the second bootstrap need not update according to secondary signal, system directly performs application Program, the normal service provided using application program or function.System has been performed after application program, and system can following electricity.
Further, after target program has been updated, system can adjust target journey according to the actual size of target program The shared memory space of sequence.Specifically, system can be according to the actual size of target program, shared by adjustment target program Memory space size and/or position.In the present embodiment, in the storage in addition to the first memory space and the second memory space Stored target program in space.System can update after target program actual size, removed neatly to adjust in memory Residual memory space between first memory space and the second memory space.For example, the position of target program storage can be adjusted, The original shared space size of target program can be adjusted.
In practical application, the configuration parameter that target program is generally resulted in after being updated successfully in memory changes, then After the completion of target program renewal, system also needs to be updated the configuration parameter in the second memory space in memory.Example Such as, after target program is updated successfully, the effective marker position of target program needs to revert to default value, could so cause more Target program after new is used by system.For another example can be by the version number after the renewal of target program and renewal time etc. Information, updates into configuration parameter.
For another example after the completion of target program updates, it is necessary to adjust the position of memory space the problems such as may be due to actual size Put or size, system is needed the position shared by target program after renewal and the space size of occupancy after the completion of adjustment, more Newly in the distribution information of the memory into configuration parameter.
In order to understand program provided in an embodiment of the present invention more new technological process, enter so that target program is the second bootstrap as an example Row is illustrated.When performing the first bootstrap for the first time, the second bootstrap and application program are in effective status, not Need to be updated.When detecting the second bootstrap and needing renewal, it is necessary to be clear by the effective marker of the second bootstrap Remove.Now, application program is in effective status, so that after the second bootstrap updates failure, system returns to restarting the After one bootstrap, when application program need not update, entered to the whether effective step of application program is judged, due to this When application program be in effective status, system can then enter application program, come more so as to continue through application program New second bootstrap.
And when application program needs to update, effective judgment step of the second bootstrap is entered, due to the second guiding Program last time updates failed, and system, which can only enter, to be jumped in application program, and the second guiding journey is updated by application program Sequence, after being updated successfully in the second bootstrap, could start more new application.And when the second bootstrap is updated to After work(, the effective marker bit recovery of the second bootstrap to default value.
Because the second bootstrap is now effective, it is possible to enter the second bootstrap, application program is updated. Or, it is not updated successfully when application program updated last time, and because system and host computer are not connected with so that system does not connect The signal of the instruction more new application of host computer transmission is received, system enters the step for judging whether application program is effective, Because now application program is invalid, then it can enter the second bootstrap, application program is carried out more by the second bootstrap Newly, could be by the effective marker bit recovery of application program to default value until application program update completion.
The more new logic that the present embodiment is provided, it is ensured that application program in the second bootstrap with having at least one to be in Effective status, when in target program being one of them, because another is effective status, and the first bootstrap is solidificated in In memory, then it can return the first bootstrap after target program updates failure, target program be updated again, Completed until the target program updates, target program is effective after the completion of renewal.The present embodiment, it is possible to achieve application program with Second bootstrap mutually updates upgrading, especially for BootLoader renewal, also can continue to after failure is updated to the Two bootstrap are updated, so as to solve in the prior art when BootLoader update fail after presence can not start into And cause the problem of ECU can not be used normally.
Fig. 5 is a kind of structural representation of program renewing device provided in an embodiment of the present invention.As shown in figure 5, the program Updating device includes:Processor 11 and memory 12.
Processor 11, for after target program updates failure, returning to the first bootstrap of restarting;Wherein, it is described First bootstrap solidifies in memory 12;The target program is application program or the second bootstrap, is performed described First bootstrap, according to the more new logic in first bootstrap, updates the target program again.
Further, processor 11, specifically for mutually being updated based on the application program and second bootstrap More new logic, the target program is updated again.
Processor 11, has specifically for being according to the application program with least one in second bootstrap Effect state forms the more new logic.
Processor 11, specifically for being judged whether to need to update the application program by first bootstrap, if Need to update the application program and when second bootstrap is effective, update the application program.
Processor 11, the effective marker position specifically for reading second bootstrap from the memory 12, root According to the effective marker position of second bootstrap, judge whether second bootstrap is effective.
Processor 11, if specifically for the application program need not be updated, it is effective and described in the application program When second bootstrap needs to update, second bootstrap is updated.
Processor 11, the effective marker position specifically for reading the application program from the memory 12, according to institute The effective marker position of application program is stated, judges whether the application program is effective.
Processor 11, specifically for the renewal for one version of target program, it is necessary to be carried out just to the version Before secondary renewal, the default value of the effective marker position of the target program is purged, to the target program version After this once renewal failure, then the target program is determined according to the effective marker of the target program position during next update In failure state.
Processor 11, specifically for carrying out storage region division to the memory 12 in advance, forms multiple memory spaces, First bootstrap is solidificated in the first memory space;First memory space is the startup position that system starts, The second memory space is chosen from remaining memory space, wherein, second memory space is used for storage configuration parameter;It is described Configuration parameter includes the distribution information of the memory 12 and the effective marker position of the target program, except the described first storage The target program is deposited in memory space outside space and the second memory space.
Processor 11, specifically for after the completion of renewal, the target is adjusted according to the actual size of the target program The shared memory space of program.
Processor 11, after being updated successfully specifically for the target program, renewal is stored in second memory space The configuration parameter.
Processor 11, specifically for when the target program is the application program, the target program is updated successfully Afterwards, update and be stored in nominal data in the memory 12, wherein, the nominal data be when the application program is performed with The related key parameter values of system.
Processor 11 and memory 12 can be connected with each other by bus and complete mutual communication.The bus can be with It is industry standard architecture (Industry Standard Architecture, referred to as ISA) bus, external equipment interconnection (Peripheral Component, referred to as PCI) bus or extended industry-standard architecture (Extended Industry Standard Architecture, referred to as EISA) bus etc..The bus can be divided into address bus, data/address bus, control Bus processed etc..For ease of representing, only represented in Fig. 5 with a thick line, it is not intended that only one bus or a type of Bus.
Processor 11 is probably a central processing unit (Central Processing Unit, referred to as CPU), or Specific integrated circuit (Application Specific Integrated Circuit, referred to as ASIC), or by with It is set to the one or more integrated circuits for implementing the embodiment of the present invention.
In the description of this specification, reference term " one embodiment ", " some embodiments ", " example ", " specifically show The description of example " or " some examples " etc. means to combine specific features, structure, material or the spy that the embodiment or example are described Point is contained at least one embodiment of the present invention or example.In this manual, to the schematic representation of above-mentioned term not Identical embodiment or example must be directed to.Moreover, specific features, structure, material or the feature of description can be with office Combined in an appropriate manner in one or more embodiments or example.In addition, in the case of not conflicting, the skill of this area Art personnel can be tied the not be the same as Example or the feature of example and non-be the same as Example or example described in this specification Close and combine.
In addition, term " first ", " second " are only used for describing purpose, and it is not intended that indicating or implying relative importance Or the implicit quantity for indicating indicated technical characteristic.Thus, define " first ", the feature of " second " can express or Implicitly include at least one this feature.In the description of the invention, " multiple " are meant that at least two, such as two, three It is individual etc., unless otherwise specifically defined.
Any process described otherwise above or method description are construed as in flow chart or herein, represent to include Module, fragment or the portion of the code of one or more executable instructions for the step of realizing custom logic function or process Point, and the scope of the preferred embodiment of the present invention includes other realization, wherein can not be by shown or discussion suitable Sequence, including according to involved function by it is basic simultaneously in the way of or in the opposite order, carry out perform function, this should be of the invention Embodiment person of ordinary skill in the field understood.
Represent in flow charts or logic and/or step described otherwise above herein, for example, being considered use In the order list for the executable instruction for realizing logic function, it may be embodied in any computer-readable medium, for Instruction execution system, device or equipment (such as computer based system including the system of processor or other can be held from instruction The system of row system, device or equipment instruction fetch and execute instruction) use, or combine these instruction execution systems, device or set It is standby and use.For the purpose of this specification, " computer-readable medium " can any can be included, store, communicate, propagate or pass Defeated program is for instruction execution system, device or equipment or the dress for combining these instruction execution systems, device or equipment and using Put.The more specifically example (non-exhaustive list) of computer-readable medium includes following:Electricity with one or more wirings Connecting portion (electronic installation), portable computer diskette box (magnetic device), random access memory (RAM), read-only storage (ROM), erasable edit read-only storage (EPROM or flash memory), fiber device, and portable optic disk is read-only deposits Reservoir (CDROM).In addition, can even is that can be in the paper of printing described program thereon or other are suitable for computer-readable medium Medium, because can then enter edlin, interpretation or if necessary with it for example by carrying out optical scanner to paper or other media His suitable method is handled electronically to obtain described program, is then stored in computer storage.
It should be appreciated that each several part of the present invention can be realized with hardware, software, firmware or combinations thereof.Above-mentioned In embodiment, the software that multiple steps or method can in memory and by suitable instruction execution system be performed with storage Or firmware is realized.Such as, if realized with hardware with another embodiment, following skill well known in the art can be used Any one of art or their combination are realized:With the logic gates for realizing logic function to data-signal from Scattered logic circuit, the application specific integrated circuit with suitable combinational logic gate circuit, programmable gate array (PGA), scene can be compiled Journey gate array (FPGA) etc..
Those skilled in the art are appreciated that to realize all or part of step that above-described embodiment method is carried Rapid to can be by program to instruct the hardware of correlation to complete, described program can be stored in a kind of computer-readable storage medium In matter, the program upon execution, including one or a combination set of the step of embodiment of the method.
In addition, each functional unit in each embodiment of the invention can be integrated in a processing module, can also That unit is individually physically present, can also two or more units be integrated in a module.Above-mentioned integrated mould Block can both be realized in the form of hardware, it would however also be possible to employ the form of software function module is realized.The integrated module is such as Fruit is realized using in the form of software function module and as independent production marketing or in use, can also be stored in a computer In read/write memory medium.
Storage medium mentioned above can be read-only storage, disk or CD etc..Although having been shown and retouching above Embodiments of the invention are stated, it is to be understood that above-described embodiment is exemplary, it is impossible to be interpreted as the limit to the present invention System, one of ordinary skill in the art can be changed to above-described embodiment, change, replace and become within the scope of the invention Type.