Invention content
In view of the foregoing deficiencies of prior art, the purpose of the present invention is to provide a kind of embedded device and one kind
Method for upgrading software, deficiency state control simple for solving escalation process in the prior art, and can not be according to a variety of of user
The problem of upgrade requirement preferably controls software upgrading.
In order to achieve the above objects and other related objects, the present invention provides a kind of embedded device, including:State machine is used
With the activation subregion version identifier of the software version acquisition of the activation subregion according to detection and inactive point according to detection
The inactive subregion version identifier that the software version in area obtains, determines its state in which;Webmaster module, to according to detection
The state of the state machine or the external control command of reception, perform it is described activation subregion or the inactive subregion software
Version updating or rollback operation.
Optionally, when the activation subregion version identifier is 0, the software version of the activation subregion is identified as just
Normal version, when the activation subregion version indications are 1, the software version for identifying the activation subregion is new version;When
When the inactive subregion version identifier is 0, the software version for identifying the inactive subregion is normal version, works as institute
When to state inactive subregion version identifier be 1, the software version for identifying the inactive subregion is new version, when described non-
When activation subregion version identifier is -1, the inactive subregion for identifying the inactive subregion does not have related software.
Optionally, the state machine includes at least one or more in following state:1) when the activation subregion version
When identifier is 0 and the inactive subregion version identifier is 0, the state machine is in normal condition;2) when the activation
Subregion version identifier be 0, and the inactive subregion version identifier be 1 when, the state machine be in need reset state;3)
When the activation subregion version identifier is 1, and the inactive subregion version identifier is 0, the state machine, which is in, to be needed
Synchronous regime;4) when the activation subregion version identifier is 1, and the inactive subregion version identifier is 1, the shape
State machine is in state to be committed;5) when the activation subregion version identifier is 0, and the inactive subregion version identifier
When being -1 or when the activation subregion version identifier is 1, and the inactive subregion version identifier is -1, the shape
State machine is in abnormality.
Optionally, the webmaster module enables described inactive when detecting that the state machine is in the abnormality
The software of the subregion in the activation subregion performs update operation.
Optionally, it when the state machine is in the normal condition, when receiving external upgrade command, enables described non-sharp
Subregion living obtains newer software according to default channel, and reset state is needed so that the state machine to be enabled to be in described;The webmaster mould
Block when detect the state machine be in it is described need reset state when, restart the embedded device, enable it is described activation subregion root
Update operation is performed according to the software of the inactive subregion, synchronous regime is needed so that the state machine to be enabled to be in described;The webmaster
Module when detect the state machine be in it is described need synchronous regime when, enable the inactive subregion according to the activation subregion
Software performs update operation, is detected in the activation subregion so that the state machine is enabled to be in the state to be committed, and is worked as
During running software exception, the activation subregion is enabled to perform rollback operation according to the software of the inactive subregion, and enable the shape
State machine, which is in, needs reset state;The webmaster module confirms institute when detecting that the state machine is in the state to be committed
The software upgrading for stating activation subregion and the inactive subregion is completed, and it is 0 and institute to enable the activation subregion version identifier
It is 0 to state inactive subregion version identifier, and the state machine is in normal condition.
In order to achieve the above objects and other related objects, it is embedding applied to one the present invention also provides a kind of method for upgrading software
Enter in formula equipment, include the following steps:The activation subregion version identifier obtained according to the software version of the activation subregion of detection
And the inactive subregion version identifier obtained according to the software version of the inactive subregion of detection, it determines residing for a state machine
State;According to the state of the state machine of detection or the external control command of reception, the activation subregion or described is performed
The version updating or rollback operation of the software of inactive subregion.
Optionally, when the activation subregion version identifier is 0, the software version of the activation subregion is identified as just
Normal version, when the activation subregion version indications are 1, the software version for identifying the activation subregion is new version;When
When the inactive subregion version identifier is 0, the software version for identifying the inactive subregion is normal version, works as institute
When to state inactive subregion version identifier be 1, the software version for identifying the inactive subregion is new version, when described non-
When activation subregion version identifier is -1, the inactive subregion for identifying the inactive subregion does not have related software.
Optionally, the state machine includes at least one or more in following state:1) when the activation subregion version
When identifier is 0 and the inactive subregion version identifier is 0, the state machine is in normal condition;2) when the activation
Subregion version identifier be 0, and the inactive subregion version identifier be 1 when, the state machine be in need reset state;3)
When the activation subregion version identifier is 1, and the inactive subregion version identifier is 0, the state machine, which is in, to be needed
Synchronous regime;4) when the activation subregion version identifier is 1, and the inactive subregion version identifier is 1, the shape
State machine is in state to be committed;5) when the activation subregion version identifier is 0, and the inactive subregion version identifier
When being -1 or when the activation subregion version identifier is 1, and the inactive subregion version identifier is -1, the shape
State machine is in abnormality.
Optionally, when detecting that the state machine is in the abnormality, the inactive subregion is enabled according to
The software in subregion is activated to perform update operation.
Optionally, it when the state machine is in the normal condition, when receiving external upgrade command, enables described non-sharp
Subregion living obtains newer software according to default channel, and reset state is needed so that the state machine to be enabled to be in described;The webmaster mould
Block when detect the state machine be in it is described need reset state when, restart the embedded device, enable it is described activation subregion root
Update operation is performed according to the software of the inactive subregion, synchronous regime is needed so that the state machine to be enabled to be in described;The webmaster
Module when detect the state machine be in it is described need synchronous regime when, enable the inactive subregion according to the activation subregion
Software performs update operation, is detected in the activation subregion so that the state machine is enabled to be in the state to be committed, and is worked as
During running software exception, the activation subregion is enabled to perform rollback operation according to the software of the inactive subregion, and enable the shape
State machine, which is in, needs reset state;The webmaster module confirms institute when detecting that the state machine is in the state to be committed
The software upgrading for stating activation subregion and the inactive subregion is completed, and it is 0 and institute to enable the activation subregion version identifier
It is 0 to state inactive subregion version identifier, and the state machine is in normal condition.
As described above, a kind of embedded device and a kind of method for upgrading software of the present invention, according to the activation of detection point
It activation subregion version identifier that the software version in area obtains and is obtained according to the software version of the inactive subregion of detection
Inactive subregion version identifier determines a state machine state in which;According to the state of the state machine of detection or reception
External control command, perform it is described activation subregion or the inactive subregion software version updating or rollback operation.This
Various states in the controllable escalation process of invention, make it become controllable from uncontrollable.More flexible, the Ke Yi for becoming escalation process
Free switching in the state of various needs.And make escalation process more reliable, system can be made from various mistakes or unstable state
It is switched to stable controllable state.
Specific embodiment
Illustrate embodiments of the present invention below by way of specific specific example, those skilled in the art can be by this specification
Disclosed content understands other advantages and effect of the present invention easily.The present invention can also pass through in addition different specific realities
The mode of applying is embodied or practiced, the various details in this specification can also be based on different viewpoints with application, without departing from
Various modifications or alterations are carried out under the spirit of the present invention.It should be noted that in the absence of conflict, following embodiment and implementation
Feature in example can be combined with each other.
It should be noted that the diagram provided in following embodiment only illustrates the basic structure of the present invention in a schematic way
Think, component count, shape and size when only display is with related component in the present invention rather than according to actual implementation in illustrating then
It draws, kenel, quantity and the ratio of each component can be a kind of random change during actual implementation, and its assembly layout kenel
It is likely more complexity.
Referring to Fig. 1, it is shown as a kind of module diagram of embedded device of the present invention in one embodiment.Institute
It states embedded device 1 and includes state machine 11 and webmaster module 12.Common embedded device is all soft by preserving two parts of systems
Part realizes that they are stored in the physical storage device that on two different storage equipment partitions or two panels is different respectively.Its
As shown in Figures 2 and 3, such as Fig. 2 is shown as two parts of system softwares of embedded device in the prior art for system architecture and principle
The schematic diagram in same storage device is deposited in, wherein the system software 1 is stored in the currently active subregion, the system software
2 are stored in inactive subregion, the i.e. usually described backup subregion.And as shown in figure 3, it is shown as embedded device in the prior art
Two parts of system softwares deposit in schematic diagram in different storage devices, wherein the system software 1 is stored in storage device 1
(the currently active subregion), the system software 2 are stored in storage device 2 (inactive subregion), i.e., usually said backup subregion.
The activation subregion version identifier that the state machine 11 obtains to the software version of the activation subregion according to detection
And the inactive subregion version identifier obtained according to the software version of the inactive subregion of detection, determine the shape residing for it
State.
For example, activation subregion version identifier and the inactive subregion version identifier include 0 and 1 two states,
When the activation subregion version identifier is 0, the software version that identifies the activation subregion is normal version, the activation
When subregion version indications are 1, the software version for identifying the activation subregion is new version;When the inactive subregion version
When this identifier is 0, the software version for identifying the inactive subregion is normal version, when the inactive subregion version
When identifier is 1, the software version for identifying the inactive subregion is new version, when the inactive subregion version identifier
It accords with when being -1, the inactive subregion for identifying the inactive subregion does not have related software.
And the state of the state machine 11 is including at least one or more in following state:
1) when the activation subregion version identifier is 0 and the inactive subregion version identifier is 0, the state
Machine 11 is in normal condition;
2) when the activation subregion version identifier is 0, and the inactive subregion version identifier is 1, the shape
State machine 11, which is in, needs reset state;
3) when the activation subregion version identifier is 1, and the inactive subregion version identifier is 0, the shape
State machine 11, which is in, needs synchronous regime;
4) when the activation subregion version identifier is 1, and the inactive subregion version identifier is 1, the shape
State machine 11 is in state to be committed;
5) when the activation subregion version identifier is 0, and the inactive subregion version identifier is -1 or work as institute
It is 1 to state activation subregion version identifier, and when the inactive subregion version identifier is -1, and the state machine 11 is in abnormal
State.
The webmaster module 12 is held to the state of the state machine 11 according to detection or the external control command of reception
The version updating or rollback operation of the software of the row activation subregion or the inactive subregion.The external control command includes
The embedded device 1 is enabled to carry out the order of software upgrading, and when the state machine 11 is in the normal condition, is received
During external upgrade command, the inactive subregion is enabled to obtain newer software according to default channel, to enable at the state machine 11
Reset state is needed in described, wherein, the default channel is, for example, ftp channels;The webmaster module 12, which is worked as, detects the shape
State machine 11 is in described and restarts the embedded device 1 when needing reset state, enables the activation subregion according to described inactive point
The software in area performs update operation, and synchronous regime is needed so that the state machine 11 to be enabled to be in described;The webmaster module 12 is when detection
To the state machine 11 be in it is described need synchronous regime when, enable the inactive subregion according to it is described activation subregion software perform
Update operation, the state machine 11 to be enabled to be in the state to be committed, and is worked as the software fortune detected in the activation subregion
When row is abnormal, the activation subregion is enabled to perform rollback operation according to the software of the inactive subregion, and enable the state machine 11
In needing reset state;The webmaster module 12 confirms institute when detecting that the state machine 11 is in the state to be committed
The software upgrading for stating activation subregion and the inactive subregion is completed, and it is 0 and institute to enable the activation subregion version identifier
It is 0 to state inactive subregion version identifier, and the state machine 11 is in normal condition.And work as when the webmaster module 12 and detect
When the state machine 11 is in the abnormality, the software of the inactive subregion in the activation subregion is enabled to hold
Row update operation.
The application principle of the present invention is further illustrated in conjunction with Fig. 4, cur is enabled to represent activation subregion version identifier
Symbol, backup represent inactive subregion version identifier, and the state of the state machine is respectively normal condition (Normal), need
Reset state (need reset), needs synchronous regime (need sync), state (need commit) to be committed and when described
It is 0 to activate subregion version identifier, and the abnormality (Lost backup) when the inactive subregion version identifier is -1
And the abnormality when the activation subregion version identifier is 1, and the inactive subregion version identifier is -1
(Lost backward), under Normal states, cur=backup=0;Under need reset states, cur=0, backup=
1;Under need sync states, cur=1, backup=0;Under need commit states, cur=backup=1;Lost
Under backup states, cur=0, backup=-1, under Lost backward states, cur=1, backup=-1.
And webmaster module represents, and for Update such as Fig. 4 institutes according to the operation that software upgrading command commands software is updated
Show, before Update, cur=backup=0, and after Update:Cur=0, backup=1;The webmaster module is when inspection
It measures the state machine and is in described and according to reset orders, restart the embedded device when needing reset state, enable and described swashing
Subregion living performs update operation according to the software of the inactive subregion, and synchronous regime is needed so that the state machine to be enabled to be in described,
That is cur=1, backup=0.The simultaneously operating of the software represents with Sync, even the software synchronization in activation subregion is to non-
It activates in subregion, before the Sync orders perform:Cru=0, backup=1, after order performs:Cur=0, backup=0;Or
Person, before Sync orders perform:Cru=1, backup=0;After order performs:Cur=1, backup=1.Alternatively, Sync orders
Before execution:Cru=0, backup=-1, after order performs:Cur=0, backup=0.Alternatively, before Sync orders perform:cru
=1, backup=-1, after order performs:Cur=1, backup=1.And work as cru=1, during backup=1, i.e., in waiting to carry
Friendship state, at this time when receiving price raising order commit, the state of the state machine is Normal, i.e. cru=0, backup
=0.And in the case where needing synchronous regime, if it find that new software version is defective or is unsatisfactory for demand, then webmaster module can
To send Backward orders, activation stores the backup subregion of old software version, i.e., former inactive subregion, and restarting equipment.From
And equipment is made to return to need reset states, equipment operation at this time is old software version.Again by sync orders, can make
Device replied is to original state.
Referring to Fig. 5, it is shown as a kind of flow diagram of method for upgrading software of the present invention in one embodiment.
Common embedded device is realized by preserving two parts of system softwares, they are stored in two different storages and set respectively
In back-up area or physical storage device that two panels is different.As shown in Figures 2 and 3, such as Fig. 2 is shown for its system architecture and principle
Two parts of system softwares for being shown as embedded device in the prior art deposit in schematic diagram in same storage device, wherein the system
System software 1 is stored in the currently active subregion, and the system software 2 is stored in inactive subregion, the i.e. usually described backup subregion.
And as shown in figure 3, two parts of system softwares for being shown as embedded device in the prior art are deposited in different storage devices
Schematic diagram, wherein the system software 1 is stored in storage device 1 (the currently active subregion), the system software 2 is stored in storage
Equipment 2 (inactive subregion), i.e., usually said backup subregion.
The method for upgrading software applied in an embedded device, includes the following steps:
S11:According to the activation subregion version identifier of the software version acquisition of the activation subregion of detection and according to detection
Inactive subregion software version obtain inactive subregion version identifier, determine a state machine state in which.
For example, activation subregion version identifier and the inactive subregion version identifier include 0 and 1 two states,
When the activation subregion version identifier is 0, the software version that identifies the activation subregion is normal version, the activation
When subregion version indications are 1, the software version for identifying the activation subregion is new version;When the inactive subregion version
When this identifier is 0, the software version for identifying the inactive subregion is normal version, when the inactive subregion version
When identifier is 1, the software version for identifying the inactive subregion is new version, when the inactive subregion version identifier
It accords with when being -1, the inactive subregion for identifying the inactive subregion does not have related software.
And the state of the state machine is including at least one or more in following state:
1) when the activation subregion version identifier is 0 and the inactive subregion version identifier is 0, the state
Machine is in normal condition;
2) when the activation subregion version identifier is 0, and the inactive subregion version identifier is 1, the shape
State machine, which is in, needs reset state;
3) when the activation subregion version identifier is 1, and the inactive subregion version identifier is 0, the shape
State machine, which is in, needs synchronous regime;
4) when the activation subregion version identifier is 1, and the inactive subregion version identifier is 1, the shape
State machine is in state to be committed;
5) when the activation subregion version identifier is 0, and the inactive subregion version identifier is -1 or work as institute
It is 1 to state activation subregion version identifier, and when the inactive subregion version identifier is -1, and the state machine is in abnormal shape
State.
S12:According to the state of the state machine of detection or the external control command of reception, perform the activation subregion or
The version updating or rollback operation of the software of the inactive subregion.The external control command includes enabling the embedded device
The order of software upgrading is carried out, and when the state machine is in the normal condition, when receiving external upgrade command, enables institute
It states inactive subregion and newer software is obtained according to default channel, reset state is needed so that the state machine to be enabled to be in described, wherein,
The default channel is, for example, ftp channels;When detect the state machine be in it is described need reset state when, restart the insertion
Formula equipment enables the activation subregion perform update operation according to the software of the inactive subregion, the state machine to be enabled to be in
It is described to need synchronous regime;When detect the state machine be in it is described need synchronous regime when, enable the inactive subregion according to institute
The software for stating activation subregion performs update operation, the state machine to be enabled to be in the state to be committed, and it is described when detecting
When activating the running software exception in subregion, the activation subregion is enabled to perform the behaviour that retracts according to the software of the inactive subregion
Make, and the state machine is enabled to be in need reset state;It is described when detecting that the state machine is in the state to be committed, really
The software upgrading for recognizing the activation subregion and the inactive subregion is completed, and it is 0 to enable the activation subregion version identifier
And the inactive subregion version identifier is 0, the state machine is in normal condition.And work as described in and detect the state
When machine is in the abnormality, the software of the inactive subregion in the activation subregion is enabled to perform update behaviour
Make.
The application principle of the present invention is further illustrated in conjunction with Fig. 4, cur is enabled to represent activation subregion version identifier
Symbol, backup represent inactive subregion version identifier, and the state of the state machine is respectively normal condition (Normal), need
Reset state (need reset), needs synchronous regime (need sync), state (need commit) to be committed and when described
It is 0 to activate subregion version identifier, and the abnormality (Lost backup) when the inactive subregion version identifier is -1
And the abnormality when the activation subregion version identifier is 1, and the inactive subregion version identifier is -1
(Lost backward), under Normal states, cur=backup=0;Under need reset states, cur=0, backup=
1;Under need sync states, cur=1, backup=0;Under need commit states, cur=backup=1;Lost
Under backup states, cur=0, backup=-1, under Lost backward states, cur=1, backup=-1.
And webmaster module represents, and for Update such as Fig. 4 institutes according to the operation that software upgrading command commands software is updated
Show, before Update, cur=backup=0, and after Update:Cur=0, backup=1;The webmaster module is when inspection
It measures the state machine and is in described and according to reset orders, restart the embedded device when needing reset state, enable and described swashing
Subregion living performs update operation according to the software of the inactive subregion, and synchronous regime is needed so that the state machine to be enabled to be in described,
That is cur=1, backup=0.The simultaneously operating of the software represents with Sync, even the software synchronization in activation subregion is to non-
It activates in subregion, before the Sync orders perform:Cru=0, backup=1, after order performs:Cur=0, backup=0;Or
Person, before Sync orders perform:Cru=1, backup=0;After order performs:Cur=1, backup=1.Alternatively, Sync orders
Before execution:Cru=0, backup=-1, after order performs:Cur=0, backup=0.Alternatively, before Sync orders perform:cru
=1, backup=-1, after order performs:Cur=1, backup=1.And work as cru=1, during backup=1, i.e., in waiting to carry
Friendship state, at this time when receiving price raising order commit, the state of the state machine is Normal, i.e. cru=0, backup
=0.And in the case where needing synchronous regime, if it find that new software version is defective or is unsatisfactory for demand, then webmaster module can
To send Backward orders, activation stores the backup subregion of old software version, i.e., former inactive subregion, and restarting equipment.From
And equipment is made to return to need reset states, equipment operation at this time is old software version.Again by sync orders, can make
Device replied is to original state.
In conclusion a kind of embedded device and a kind of method for upgrading software of the present invention, according to the activation of detection point
It activation subregion version identifier that the software version in area obtains and is obtained according to the software version of the inactive subregion of detection
Inactive subregion version identifier determines a state machine state in which;According to the state of the state machine of detection or reception
External control command, perform it is described activation subregion or the inactive subregion software version updating or rollback operation.This
Various states in the controllable escalation process of invention, make it become controllable from uncontrollable.More flexible, the Ke Yi for becoming escalation process
Free switching in the state of various needs.And make escalation process more reliable, system can be made from various mistakes or unstable state
It is switched to stable controllable state.So the present invention effectively overcomes various shortcoming of the prior art and has high industrial
Utility value.
The above-described embodiments merely illustrate the principles and effects of the present invention, and is not intended to limit the present invention.It is any ripe
The personage for knowing this technology all can carry out modifications and changes under the spirit and scope without prejudice to the present invention to above-described embodiment.Cause
This, those of ordinary skill in the art is complete without departing from disclosed spirit and institute under technological thought such as
Into all equivalent modifications or change, should by the present invention claim be covered.