Summary of the invention
The shortcoming of prior art in view of the above, the object of the present invention is to provide a kind of embedded device and a kind of method for upgrading software, simple for solving escalation process in prior art, deficiency state controls, and cannot carry out the problem of control preferably to software upgrading according to the multiple upgrade requirement of user.
For achieving the above object and other relevant objects, the invention provides a kind of embedded device, comprise: state machine, in order to the activation subregion version identifier obtained according to the software version of the activation subregion detected and the inactive subregion version identifier obtained according to the software version of the inactive subregion detected, determine the state residing for it; Webmaster module, in order to according to the state of described state machine detected or the external control order of reception, performs version updating or the rollback operation of the software of described activation subregion or described inactive subregion.
Optionally, when described activation subregion version identifier is 0, the described software version identifying described activation subregion is normal version, and when described activation subregion version indications is 1, the described software version identifying described activation subregion is redaction; When described inactive subregion version identifier is 0, the described software version identifying described inactive subregion is normal version, when described inactive subregion version identifier is 1, the described software version identifying described inactive subregion is redaction, when described inactive subregion version identifier is-1, the described inactive subregion identifying described inactive subregion does not have related software.
Optionally, described state machine at least comprises one or more in following state: 1) when described activation subregion version identifier is 0 and described inactive subregion version identifier is 0, described state machine is in normal condition; 2) when described activation subregion version identifier is 0, and when described inactive subregion version identifier is 1, described state machine is in and needs reset mode; 3) when described activation subregion version identifier is 1, and when described inactive subregion version identifier is 0, described state machine is in and needs synchronous regime; 4) when described activation subregion version identifier is 1, and when described inactive subregion version identifier is 1, described state machine is in state to be committed; 5) when described activation subregion version identifier is 0, and when described inactive subregion version identifier is-1, or when described activation subregion version identifier is 1, and when described inactive subregion version identifier is-1, described state machine is in abnormality.
Optionally, described webmaster module, when detecting that described state machine is in described abnormality, makes described inactive subregion perform renewal rewards theory according to the described software in described activation subregion.
Optionally, when described state machine is in described normal condition, when receiving outside upgrade, make described inactive subregion obtain according to presetting passage the software upgraded, being in make described state machine describedly needs reset mode; Described webmaster module when detect described state machine be in described need reset mode time, restart described embedded device, make described activation subregion perform renewal rewards theory according to the software of described inactive subregion, being in make described state machine describedly needs synchronous regime; Described webmaster module when detect described state machine be in described need synchronous regime time, described inactive subregion is made to perform renewal rewards theory according to the software of described activation subregion, described state to be committed is in make described state machine, and when detecting that the running software in described activation subregion is abnormal, make described activation subregion perform rollback operation according to the software of described inactive subregion, and make described state machine be in needing reset mode; Described webmaster module is when detecting that described state machine is in described state to be committed, confirm that the software upgrading of described activation subregion and described inactive subregion completes, and making described activation subregion version identifier be 0 and described inactive subregion version identifier is 0, described state machine is in normal condition.
For achieving the above object and other relevant objects, the present invention also provides a kind of method for upgrading software, be applied in an embedded device, comprise the following steps: the inactive subregion version identifier that the activation subregion version identifier obtained according to the software version of the activation subregion detected and the software version according to the inactive subregion detected obtain, determine the state residing for a state machine; According to the state of described state machine detected or the external control order of reception, perform version updating or the rollback operation of the software of described activation subregion or described inactive subregion.
Optionally, when described activation subregion version identifier is 0, the described software version identifying described activation subregion is normal version, and when described activation subregion version indications is 1, the described software version identifying described activation subregion is redaction; When described inactive subregion version identifier is 0, the described software version identifying described inactive subregion is normal version, when described inactive subregion version identifier is 1, the described software version identifying described inactive subregion is redaction, when described inactive subregion version identifier is-1, the described inactive subregion identifying described inactive subregion does not have related software.
Optionally, described state machine at least comprises one or more in following state: 1) when described activation subregion version identifier is 0 and described inactive subregion version identifier is 0, described state machine is in normal condition; 2) when described activation subregion version identifier is 0, and when described inactive subregion version identifier is 1, described state machine is in and needs reset mode; 3) when described activation subregion version identifier is 1, and when described inactive subregion version identifier is 0, described state machine is in and needs synchronous regime; 4) when described activation subregion version identifier is 1, and when described inactive subregion version identifier is 1, described state machine is in state to be committed; 5) when described activation subregion version identifier is 0, and when described inactive subregion version identifier is-1, or when described activation subregion version identifier is 1, and when described inactive subregion version identifier is-1, described state machine is in abnormality.
Optionally, when detecting that described state machine is in described abnormality, described inactive subregion is made to perform renewal rewards theory according to the described software in described activation subregion.
Optionally, when described state machine is in described normal condition, when receiving outside upgrade, make described inactive subregion obtain according to presetting passage the software upgraded, being in make described state machine describedly needs reset mode; Described webmaster module when detect described state machine be in described need reset mode time, restart described embedded device, make described activation subregion perform renewal rewards theory according to the software of described inactive subregion, being in make described state machine describedly needs synchronous regime; Described webmaster module when detect described state machine be in described need synchronous regime time, described inactive subregion is made to perform renewal rewards theory according to the software of described activation subregion, described state to be committed is in make described state machine, and when detecting that the running software in described activation subregion is abnormal, make described activation subregion perform rollback operation according to the software of described inactive subregion, and make described state machine be in needing reset mode; Described webmaster module is when detecting that described state machine is in described state to be committed, confirm that the software upgrading of described activation subregion and described inactive subregion completes, and making described activation subregion version identifier be 0 and described inactive subregion version identifier is 0, described state machine is in normal condition.
As mentioned above, a kind of embedded device of the present invention and a kind of method for upgrading software, the activation subregion version identifier obtained according to the software version of the activation subregion detected and the inactive subregion version identifier obtained according to the software version of the inactive subregion detected, determine the state residing for a state machine; According to the state of described state machine detected or the external control order of reception, perform version updating or the rollback operation of the software of described activation subregion or described inactive subregion.The present invention can control various state in escalation process, make its from uncontrollable become controlled.What escalation process was become is more flexible, freely can switch in the state of various needs.And make escalation process more reliable, system can be made to be switched to stable controlled state from various mistake or non-steady state.
Embodiment
Below by way of specific instantiation, embodiments of the present invention are described, those skilled in the art the content disclosed by this instructions can understand other advantages of the present invention and effect easily.The present invention can also be implemented or be applied by embodiments different in addition, and the every details in this instructions also can based on different viewpoints and application, carries out various modification or change not deviating under spirit of the present invention.It should be noted that, when not conflicting, the feature in following examples and embodiment can combine mutually.
It should be noted that, the diagram provided in following examples only illustrates basic conception of the present invention in a schematic way, then only the assembly relevant with the present invention is shown in diagram but not component count, shape and size when implementing according to reality is drawn, it is actual when implementing, and the kenel of each assembly, quantity and ratio can be a kind of change arbitrarily, and its assembly layout kenel also may be more complicated.
Refer to Fig. 1, be shown as a kind of embedded device of the present invention module diagram in one embodiment.Described embedded device 1 comprises state machine 11 and webmaster module 12.Common embedded device is all realize by preserving two parts of system softwares, and they leave on two different storage equipment partitions respectively, or the physical storage device that two panels is different.Its system architecture and principle are as shown in Figures 2 and 3, such as Fig. 2, the two parts of system softwares being shown as embedded device in prior art deposit in the schematic diagram in same memory device, wherein said system software 1 is stored in current activation subregion, described system software 2 is stored in inactive subregion, namely usually described backup subregion.And as shown in Figure 3, the two parts of system softwares being shown as embedded device in prior art deposit in the schematic diagram in different memory devices, wherein said system software 1 is stored in memory device 1 (current activation subregion), described system software 2 is stored in memory device 2 (inactive subregion), namely usually said backup subregion.
Described state machine 11, in order to the activation subregion version identifier obtained according to the software version of the activation subregion detected and the inactive subregion version identifier obtained according to the software version of the inactive subregion detected, determines the state residing for it.
Such as, activation subregion version identifier and described inactive subregion version identifier comprise 0 and 1 two states, when described activation subregion version identifier is 0, the described software version identifying described activation subregion is normal version, when described activation subregion version indications is 1, the described software version identifying described activation subregion is redaction; When described inactive subregion version identifier is 0, the described software version identifying described inactive subregion is normal version, when described inactive subregion version identifier is 1, the described software version identifying described inactive subregion is redaction, when described inactive subregion version identifier is-1, the described inactive subregion identifying described inactive subregion does not have related software.
And the state of described state machine 11 at least comprises one or more in following state:
1) when described activation subregion version identifier is 0 and described inactive subregion version identifier is 0, described state machine 11 is in normal condition;
2) when described activation subregion version identifier is 0, and when described inactive subregion version identifier is 1, described state machine 11 is in and needs reset mode;
3) when described activation subregion version identifier is 1, and when described inactive subregion version identifier is 0, described state machine 11 is in and needs synchronous regime;
4) when described activation subregion version identifier is 1, and when described inactive subregion version identifier is 1, described state machine 11 is in state to be committed;
5) when described activation subregion version identifier is 0, and when described inactive subregion version identifier is-1, or when described activation subregion version identifier is 1, and when described inactive subregion version identifier is-1, described state machine 11 is in abnormality.
Described webmaster module 12, in order to according to the state of described state machine 11 detected or the external control order of reception, performs version updating or the rollback operation of the software of described activation subregion or described inactive subregion.Described external control order comprises makes described embedded device 1 carry out the order of software upgrading, and when described state machine 11 is in described normal condition, when receiving outside upgrade, described inactive subregion is made to obtain according to presetting passage the software upgraded, be in make described state machine 11 and describedly need reset mode, wherein, described default passage is such as ftp passage; Described webmaster module 12 when detect described state machine 11 be in described need reset mode time, restart described embedded device 1, make described activation subregion perform renewal rewards theory according to the software of described inactive subregion, being in make described state machine 11 describedly needs synchronous regime; Described webmaster module 12 when detect described state machine 11 be in described need synchronous regime time, described inactive subregion is made to perform renewal rewards theory according to the software of described activation subregion, described state to be committed is in make described state machine 11, and when detecting that the running software in described activation subregion is abnormal, make described activation subregion perform rollback operation according to the software of described inactive subregion, and make described state machine 11 be in needing reset mode; Described webmaster module 12 is when detecting that described state machine 11 is in described state to be committed, confirm that the software upgrading of described activation subregion and described inactive subregion completes, and making described activation subregion version identifier be 0 and described inactive subregion version identifier is 0, described state machine 11 is in normal condition.And when described webmaster module 12 is when detecting that described state machine 11 is in described abnormality, make described inactive subregion perform renewal rewards theory according to the described software in described activation subregion.
Existing composition graphs 4 is described further to application principle of the present invention, make cur represent and activate subregion version identifier, backup represents inactive subregion version identifier, the state of described state machine is respectively, normal condition (Normal), need reset mode (need reset), need synchronous regime (need sync), state to be committed (need commit), and when described activation subregion version identifier is 0, and the abnormality (Lost backup) of described inactive subregion version identifier when being-1 and when described activation subregion version identifier is 1, and the abnormality (Lostbackward) of described inactive subregion version identifier when being-1, under Normal state, cur=backup=0, under need reset state, cur=0, backup=1, under need sync state, cur=1, backup=0, under need commit state, cur=backup=1, under Lost backup state, under cur=0, backup=-1, Lost backward state, cur=1, backup=-1.
And the Update that is operating as that webmaster module carries out upgrading according to software upgrading command commands software represents, and as shown in Figure 4, before Update, cur=backup=0, and after Update: cur=0, backup=1; Described webmaster module when detect described state machine be in described need reset mode time, according to reset order, restart described embedded device, described activation subregion is made to perform renewal rewards theory according to the software of described inactive subregion, be in make described state machine and describedly need synchronous regime, i.e. cur=1, backup=0.The synchronous operation of described software represents with Sync, even the software synchronization activated in subregion is in inactive subregion, before described Sync order performs: cru=0, backup=1, after order performs: cur=0, backup=0; Or, before Sync order performs: cru=1, backup=0; After order performs: cur=1, backup=1.Or, before Sync order performs: cru=0, backup=-1, after order performs: cur=0, backup=0.Or, before Sync order performs: cru=1, backup=-1, after order performs: cur=1, backup=1.And work as cru=1, during backup=1, be namely in state to be committed, now when receiving price raising order commit, the state of described state machine is Normal, i.e. cru=0, backup=0.And needing under synchronous regime, if find new software version defectiveness, or do not satisfy the demands, so webmaster module can send Backward order, activates the backup subregion storing old software version, i.e. former inactive subregion, and restarting equipment.Thus make equipment get back to need reset state, what now equipment ran is old software version.Again by sync order, device replied can be made to original state.
Refer to Fig. 5, be shown as a kind of method for upgrading software of the present invention schematic flow sheet in one embodiment.Common embedded device is all realize by preserving two parts of system softwares, and they leave on two different storage equipment partitions respectively, or the physical storage device that two panels is different.Its system architecture and principle are as shown in Figures 2 and 3, such as Fig. 2, the two parts of system softwares being shown as embedded device in prior art deposit in the schematic diagram in same memory device, wherein said system software 1 is stored in current activation subregion, described system software 2 is stored in inactive subregion, namely usually described backup subregion.And as shown in Figure 3, the two parts of system softwares being shown as embedded device in prior art deposit in the schematic diagram in different memory devices, wherein said system software 1 is stored in memory device 1 (current activation subregion), described system software 2 is stored in memory device 2 (inactive subregion), namely usually said backup subregion.
Described method for upgrading software, is applied in an embedded device, comprises the following steps:
S11: the inactive subregion version identifier that the activation subregion version identifier obtained according to the software version of the activation subregion detected and the software version according to the inactive subregion detected obtain, determines the state residing for a state machine.
Such as, activation subregion version identifier and described inactive subregion version identifier comprise 0 and 1 two states, when described activation subregion version identifier is 0, the described software version identifying described activation subregion is normal version, when described activation subregion version indications is 1, the described software version identifying described activation subregion is redaction; When described inactive subregion version identifier is 0, the described software version identifying described inactive subregion is normal version, when described inactive subregion version identifier is 1, the described software version identifying described inactive subregion is redaction, when described inactive subregion version identifier is-1, the described inactive subregion identifying described inactive subregion does not have related software.
And the state of described state machine at least comprises one or more in following state:
1) when described activation subregion version identifier is 0 and described inactive subregion version identifier is 0, described state machine is in normal condition;
2) when described activation subregion version identifier is 0, and when described inactive subregion version identifier is 1, described state machine is in and needs reset mode;
3) when described activation subregion version identifier is 1, and when described inactive subregion version identifier is 0, described state machine is in and needs synchronous regime;
4) when described activation subregion version identifier is 1, and when described inactive subregion version identifier is 1, described state machine is in state to be committed;
5) when described activation subregion version identifier is 0, and when described inactive subregion version identifier is-1, or when described activation subregion version identifier is 1, and when described inactive subregion version identifier is-1, described state machine is in abnormality.
S12: according to the state of described state machine detected or the external control order of reception, perform version updating or the rollback operation of the software of described activation subregion or described inactive subregion.Described external control order comprises the order making described embedded device carry out software upgrading, and when described state machine is in described normal condition, when receiving outside upgrade, described inactive subregion is made to obtain according to presetting passage the software upgraded, be in make described state machine and describedly need reset mode, wherein, described default passage is such as ftp passage; When detect described state machine be in described need reset mode time, restart described embedded device, make described activation subregion perform renewal rewards theory according to the software of described inactive subregion, being in make described state machine describedly needs synchronous regime; When detect described state machine be in described need synchronous regime time, described inactive subregion is made to perform renewal rewards theory according to the software of described activation subregion, described state to be committed is in make described state machine, and when detecting that the running software in described activation subregion is abnormal, make described activation subregion perform rollback operation according to the software of described inactive subregion, and make described state machine be in needing reset mode; Described when detecting that described state machine is in described state to be committed, confirm that the software upgrading of described activation subregion and described inactive subregion completes, and making described activation subregion version identifier be 0 and described inactive subregion version identifier is 0, described state machine is in normal condition.And when described when detecting that described state machine is in described abnormality, make described inactive subregion perform renewal rewards theory according to the described software in described activation subregion.
Existing composition graphs 4 is described further to application principle of the present invention, make cur represent and activate subregion version identifier, backup represents inactive subregion version identifier, the state of described state machine is respectively, normal condition (Normal), need reset mode (need reset), need synchronous regime (need sync), state to be committed (need commit), and when described activation subregion version identifier is 0, and the abnormality (Lost backup) of described inactive subregion version identifier when being-1 and when described activation subregion version identifier is 1, and the abnormality (Lostbackward) of described inactive subregion version identifier when being-1, under Normal state, cur=backup=0, under need reset state, cur=0, backup=1, under need sync state, cur=1, backup=0, under need commit state, cur=backup=1, under Lost backup state, under cur=0, backup=-1, Lost backward state, cur=1, backup=-1.
And the Update that is operating as that webmaster module carries out upgrading according to software upgrading command commands software represents, and as shown in Figure 4, before Update, cur=backup=0, and after Update: cur=0, backup=1; Described webmaster module when detect described state machine be in described need reset mode time, according to reset order, restart described embedded device, described activation subregion is made to perform renewal rewards theory according to the software of described inactive subregion, be in make described state machine and describedly need synchronous regime, i.e. cur=1, backup=0.The synchronous operation of described software represents with Sync, even the software synchronization activated in subregion is in inactive subregion, before described Sync order performs: cru=0, backup=1, after order performs: cur=0, backup=0; Or, before Sync order performs: cru=1, backup=0; After order performs: cur=1, backup=1.Or, before Sync order performs: cru=0, backup=-1, after order performs: cur=0, backup=0.Or, before Sync order performs: cru=1, backup=-1, after order performs: cur=1, backup=1.And work as cru=1, during backup=1, be namely in state to be committed, now when receiving price raising order commit, the state of described state machine is Normal, i.e. cru=0, backup=0.And needing under synchronous regime, if find new software version defectiveness, or do not satisfy the demands, so webmaster module can send Backward order, activates the backup subregion storing old software version, i.e. former inactive subregion, and restarting equipment.Thus make equipment get back to need reset state, what now equipment ran is old software version.Again by sync order, device replied can be made to original state.
In sum, a kind of embedded device of the present invention and a kind of method for upgrading software, the activation subregion version identifier obtained according to the software version of the activation subregion detected and the inactive subregion version identifier obtained according to the software version of the inactive subregion detected, determine the state residing for a state machine; According to the state of described state machine detected or the external control order of reception, perform version updating or the rollback operation of the software of described activation subregion or described inactive subregion.The present invention can control various state in escalation process, make its from uncontrollable become controlled.What escalation process was become is more flexible, freely can switch in the state of various needs.And make escalation process more reliable, system can be made to be switched to stable controlled state from various mistake or non-steady state.So the present invention effectively overcomes various shortcoming of the prior art and tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all without prejudice under spirit of the present invention and category, can modify above-described embodiment or changes.Therefore, such as have in art usually know the knowledgeable do not depart from complete under disclosed spirit and technological thought all equivalence modify or change, must be contained by claim of the present invention.