Summary of the invention
For the problem in correlation technique, the present invention proposes a kind of upgrade method of embedded system, has solved in prior art, and escalation process need to participate in manually and upgrading personnel need to possess certain professional knowledge, and escalation process affects the problem of current operation.
Technical scheme of the present invention is achieved in that
According to an aspect of the present invention, provide a kind of upgrade method of embedded system, the method comprises:
Read the mirror image header of mirror image in memory device, determine the system boot partition number of mirror image according to the mirror image header reading;
Determine subregion to be upgraded according to system boot partition number;
Read the partition information of subregion to be upgraded, according to the version number of upgrade image pre-stored in the version number of the corresponding subregion mirror image of subregion to be upgraded and peripheral hardware, determine whether the subregion mirror image in memory device to upgrade;
For be in the situation that, upgrade image is synchronized to the assigned address in subregion to be upgraded in definite result.
Wherein, in the time determining whether the subregion mirror image in memory device to upgrade, the version number of upgrade image that can be pre-stored in peripheral hardware is greater than the corresponding mirrored version of subregion mirror image this shop to be upgraded, determines and need to upgrade to the subregion mirror image in memory device.
In addition, upgrade image being synchronized to after the assigned address in subregion to be upgraded, can also upgrade the corresponding partition information of subregion after upgrading according to the mirror image after synchronous;
System boot partition number in mirror image header is updated to the partition number of the subregion being this time upgraded.
Wherein, the partition information that needs to upgrade comprise following one of at least:
The size of regeneration block version number, regeneration block identifying code, regeneration block mirror image.
In addition, after partition information is upgraded, restart memory device, wherein, the step restarting comprises:
Read the mirror image header of the mirror image after having upgraded, obtain the system boot partition number after renewal, and reading system boot partition number the partition information of corresponding subregion, according to the subregion identifying code in this partition information, the mirror image of this subregion is carried out to verification;
When in the abnormal situation of verification, the mirror image header of the mirror image after this upgrading of resetting completes, is updated to the corresponding partition number in former boot partition by system boot partition number, and starts memory device by former boot partition.
According to a further aspect in the invention, provide a kind of update device of embedded system, this device comprises:
Read module, for reading the mirror image header of memory device mirror image, also for reading the partition information of subregion to be upgraded;
The first determination module, for determine the system boot partition number of mirror image according to the mirror image header reading, and determines subregion to be upgraded according to system boot partition number;
The second determination module, for according to the version number of the version number of the corresponding subregion mirror image of subregion to be upgraded and the pre-stored upgrade image of peripheral hardware, determines whether the mirror image in memory device to upgrade;
Upgrading module, in definite result for be in the situation that, upgrade image is synchronized to the assigned address in subregion to be upgraded.
Wherein, this device further comprises:
Update module, for upgrade image being synchronized to after the assigned address of subregion to be upgraded, upgrades the corresponding partition information of subregion after upgrading according to the mirror image after synchronous;
System boot partition number in mirror image header is updated to the partition number of the subregion being this time upgraded.
Wherein, the information that update module is upgraded, comprise following one of at least:
The size of regeneration block version number, regeneration block identifying code, regeneration block mirror image.
Wherein, this device further comprises:
Device start module, for after partition information is upgraded, restart memory device, wherein read module is further used in restart procedure, read the mirror image header of the mirror image after having upgraded, obtain the system boot partition number after renewal, and reading system boot partition number the partition information of corresponding subregion;
Authentication module, for according to system boot partition number the subregion identifying code of corresponding subregion the mirror image of this subregion is carried out to verification.
Wherein, this device further comprises:
Replacement module, for working as in the abnormal situation of verification, the mirror image header of the mirror image after this upgrading of resetting completes, is updated to the corresponding partition number in former boot partition by system boot partition number, and starts memory device by former boot partition.
The subregion of required use and the subregion that need to upgrade when the present invention determines that by reading the mirror image header of mirror image in memory device system starts, between subregion, be independent of each other, escalation process does not affect system normal operation, and escalation process manually participates in simple and convenient without user, strengthen user's experience, improved stability and the reliability of system.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiment.Based on the embodiment in the present invention, the every other embodiment that those of ordinary skill in the art obtain, belongs to the scope of protection of the invention.
First it should be noted that, every kind of mirror image all comprises a mirror image header, and Fig. 1 shows the message structure of mirror image head, and it comprises:
System boot partition number, the subregion using the unloading phase of being used for tag system.Such as, system boot partition number is subregion one, when system starts, need to read mirror image from subregion one; Second subregion is partition number to be upgraded.
The information of subregion, is used for identifying the essential information of this subregion.
As shown in Figure 2, the information of subregion at least comprise following one of at least:
The size of title, subregion version number, subregion check code, subregion mirror image reference position and the subregion mirror image of subregion mirror image.
According to embodiments of the invention, provide a kind of upgrade method of embedded system.
As shown in Figure 3, comprise according to the upgrade method of the embedded system of the embodiment of the present invention:
Step S301, reads the mirror image header of mirror image in memory device, determines the system boot partition number of mirror image according to the mirror image header reading;
Step S303, determines subregion to be upgraded according to system boot partition number;
Step S305, reads the partition information of subregion to be upgraded, according to the version number of upgrade image pre-stored in the version number of the corresponding subregion mirror image of subregion to be upgraded and peripheral hardware, determines whether the subregion mirror image in memory device to upgrade;
Step S307, for be in the situation that, is synchronized to assigned address in to be upgraded subregion by upgrade image in definite result.
Wherein, in the time determining whether the subregion mirror image in memory device to upgrade, the version number of upgrade image that can be pre-stored in peripheral hardware is greater than the corresponding mirrored version of subregion mirror image this shop to be upgraded, determines and need to upgrade to the subregion mirror image in memory device.
In addition, upgrade image being synchronized to after the assigned address in subregion to be upgraded, can also upgrade the corresponding partition information of subregion after upgrading according to the mirror image after synchronous; System boot partition number in mirror image header is updated to the partition number of the subregion being this time upgraded.
Like this, be that up-to-date version starts by automatically selecting mirror image when next device start.
Wherein, the partition information that needs to upgrade comprise following one of at least:
The size of regeneration block version number, regeneration block identifying code, regeneration block mirror image.
In addition, after partition information is upgraded, can restart memory device, wherein, the step restarting comprises:
Read the mirror image header of the mirror image after having upgraded, obtain the system boot partition number after renewal, and reading system boot partition number the partition information of corresponding subregion, according to the subregion identifying code in this partition information, the mirror image of this subregion is carried out to verification;
When in the abnormal situation of verification, the mirror image header of the mirror image after this upgrading of resetting completes, is updated to the corresponding partition number in former boot partition by system boot partition number, and starts memory device by former boot partition.
Like this, even if emergency situations occurs in escalation process to be caused upgrading unsuccessfully, when start next time, can not affect the normal operation of system yet, and whether upgrade successfully by verification system, in the situation that checking is abnormal, system adopts former boot partition to carry out the startup of current system, and can continue the former subregion that needs upgrading to upgrade, can't affect the operation conditions of current system, improve stability and the reliability of system.
In addition, when the upgrade method of embedded system provided by the present invention not only can be the unloading phase of system, carried out but also can in the time of the system operation phase, carry out, for convenience of description and understand, in the following embodiments, peripheral hardware describes as an example of SD card example, but it should be noted that, the peripheral hardware in the present invention is not limited only to SD card, can also be other external memory devices.
The schematic flow sheet of the upgrade method of embedded system unloading phase that Fig. 4 showing according to the system of the embodiment of the present invention time, this system upgrade process is as follows:
1, detect SD card and whether insert, if do not inserted, enter normal startup flow process;
If 2 SD cards insert, from SD card, read upgrade script, if this file does not exist, enter normal startup flow process;
3, from upgrade script, obtain the version number information of mirror image and upgrade whether, by the customizable escalation process of upgrade;
If the version number of 4 mirror images is less than the version number of the built-in mirror image of equipment, enter normal startup flow process;
If the version number of 5 mirror images is greater than the version number of the built-in mirror image of equipment, enter upgrading flow process;
6, first upgrading flow process is read the mirror image in SD card in internal memory by the upgrade in upgrade script, then the mirror image in internal memory is synchronized in the built-in memory device of equipment, and this process is by the green flicker mark of pilot lamp;
7, upgrade successfully, the green Chang Liang of pilot lamp, system autoboot, pilot lamp goes out.
The schematic flow sheet of the upgrade method of embedded system when Fig. 5 shows according to the system operation phase of the embodiment of the present invention, this system upgrade process is as follows:
System is normally moved:
1, whether backstage monitor process detects SD card by the signal pins in place of SD card and inserts, if do not inserted, system is normally moved;
If 2 SD cards insert, from SD card, read upgrade script, if this file does not exist, enter normal startup flow process;
3, from upgrade script, obtain version number information and the upgrade of mirror image, by the customizable escalation process of upgrade;
If the version number of 4 mirror images is less than the version number of the built-in mirror image of equipment, exit upgrading flow process, system is normally moved;
If the version number of 5 mirror images is greater than the version number of the built-in mirror image of equipment, enter upgrading flow process;
6, the first Operation class of adjustment System of upgrading flow process, enter safety upgrade pattern, then by the upgrade in upgrade script, the mirror image in SD card is read in internal memory, then the mirror image in internal memory is synchronized in the built-in memory device of equipment, this process is by the green flicker mark of pilot lamp;
7, upgrade successfully, the green Chang Liang of pilot lamp, system autoboot, pilot lamp goes out.
Introduce the upgrade image of preserving in SD card is copied to the process in subregion to be upgraded in detail below, its idiographic flow is as follows:
1, read the mirror image header of this mirror image, obtain the system boot partition number in mirror image header, can obtain partition number to be upgraded according to system boot partition number;
2, read the corresponding partition information of partition number to be upgraded, obtain the reference position of subregion mirror image;
3, mirror image itself is updated to the position of appointment;
4, upgrade the corresponding partition information of partition number to be upgraded, refresh the information such as the size of subregion version number, subregion check code, subregion mirror image;
5, the system boot partition number in mirror image header is updated to the partition number being this time upgraded.
As shown in Figure 6, its process is as follows for the process of restarting after system upgrade:
1, the mirror image header that reads this mirror image, obtains system boot partition number;
2, reading system boot partition number corresponding partition information, obtains the information such as the reference position of subregion mirror image and the size of subregion mirror image;
3, read corresponding mirror image from specified location;
4, according to the subregion check code in partition information, mirror image is carried out to verification;
If 5 verifications are normal, use up-to-date mirror image to start, escalation process finishes;
If 6 verifications are abnormal, the mirror image header of this mirror image of resetting, is updated to system boot partition number the partition number of former boot partition, and uses the mirror image of this subregion to start;
In addition, restarting flow process and also can select Starting mode by configuration after system image upgrading, default configuration is that the mirror image of use system boot partition starts, and can dynamic-configuration be also that the arbitrary subregion of use starts.
According to embodiments of the invention, also provide a kind of update device of embedded system.
As shown in Figure 7, comprise according to the update device of the embedded system of the embodiment of the present invention:
Read module 71, for reading the mirror image header of memory device mirror image, also for reading the partition information of subregion to be upgraded;
The first determination module 72, for determine the system boot partition number of mirror image according to the mirror image header reading, and determines subregion to be upgraded according to system boot partition number;
The second determination module 73, for according to the version number of the version number of the corresponding subregion mirror image of subregion to be upgraded and the pre-stored upgrade image of peripheral hardware, determines whether the mirror image in memory device to upgrade;
Upgrading module 74, in definite result for be in the situation that, upgrade image is synchronized to the assigned address in subregion to be upgraded.
Wherein, this device also comprises:
Update module (not shown), for upgrade image being synchronized to after the assigned address of subregion to be upgraded, upgrades the corresponding partition information of subregion after upgrading according to the mirror image after synchronous;
System boot partition number in mirror image header is updated to the partition number of the subregion being this time upgraded.
Wherein, the information that update module is upgraded, comprise following one of at least:
The size of regeneration block version number, regeneration block identifying code, regeneration block mirror image.
Wherein, this device further comprises:
Device start module (not shown), for after partition information is upgraded, restart memory device, wherein read module 71 is further used in restart procedure, read the mirror image header of the mirror image after having upgraded, obtain the system boot partition number after renewal, and reading system boot partition number the partition information of corresponding subregion;
Authentication module (not shown), for according to system boot partition number the subregion identifying code of corresponding subregion the mirror image of this subregion is carried out to verification.
Wherein, this device further comprises:
Replacement module (not shown), for working as in the abnormal situation of verification, the reset mirror image header of the mirror image of this upgrading after completing, is updated to the corresponding partition number in former boot partition by system boot partition number, and starts memory device by former boot partition.
In sum, by means of technique scheme of the present invention, the subregion of required use and the subregion needing of upgrading while determining that by reading the mirror image header of mirror image in memory device system starts, between subregion, be independent of each other, escalation process does not affect system normal operation, and, when the mirror image that version is up-to-date is synchronized to behind the position of the subregion being upgraded, the mirror image being upgraded is upgraded, ensureing next autoboot when, system is up-to-date image release by operation, and in restarting process, verify processing by the mirror image that new upgrading is completed, when checking occurs in abnormal situation, system will be used original subregion mirror image to start, thereby make system can as usual start the use that can not affect user, and whole escalation process is simple and convenient, escalation process manually participates in without user, strengthen user's experience, stability and reliability improve.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any amendment of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.