Summary of the invention
Fundamental purpose of the present invention is to provide a kind of flash system and method for updating program thereof that still can guarantee the product normal boot-strap under the unsuccessful situation of software upgrading at the defective that the above-mentioned background technology exists.
For achieving the above object, flash system of the present invention, be applied on the electronic product, this flash system comprises one first system's image cut section, one second system's image cut section, one first boot variable cut section, one second boot variable cut section and a start loading procedure cut section.First, second system's image cut section includes a kernel program cut section and an archives economy program cut section, described kernel program cut section is used to store kernel program, described archives economy program cut section is used to store root archives economy program, comprises a software upgrade procedure in the root archives economy program.The first boot variable cut section is used to store one first boot variable, described software upgrade procedure can check whether the numerical value of first boot variable is correct, and according to value selection renewal first system's image cut section of first boot variable or kernel program and the root archives economy program in second system's image cut section.The second boot variable cut section is used to store one second boot variable.Start loading procedure cut section stores the start loading procedure, be used for initiating hardware equipment, whether the numerical value that can check first boot variable is correct, and the full content in the second boot variable cut section can be copied in the first boot variable cut section and replace full content in the first boot variable cut section, and can select kernel program and root archives economy program in operation first system's image cut section or the second system's image cut section according to the value of first boot variable.Wherein, software upgrade procedure can check whether kernel program and root archives economy program in the corresponding system image cut section be correct.Software upgrade procedure can be selected the repayment mistake according to check result, perhaps revises the numerical value of first boot variable and the full content in the first boot variable cut section can be copied in the second boot variable cut section and replace full content in the second boot variable cut section.
The update method of flash system program provided by the present invention includes following steps: after (1) started software upgrade procedure, at first whether software upgrade procedure checked first boot variable effective; If invalid, execution in step (5); If effectively, enter next step; (2) software upgrade procedure is selected to replace kernel program and root archives economy program in first system's image cut section or the second system's image cut section with new procedures according to the value of first boot variable; (3) whether the software upgrade procedure scrutiny program upgrades successful; If failure finishes software upgrade procedure and repays mistake, return execution in step (1); If success enters next step; (4) software upgrade procedure is changed the value of first boot variable, copies to the full content in the first boot variable cut section in the second boot variable cut section and replaces full content in the second boot variable cut section; (5) restart system, whether the start loading procedure checks first boot variable effective; If invalid, the full content in the second boot variable cut section is copied in the first boot variable cut section, and replace the interior full content of the first boot variable cut section, enter next step again; If effectively, directly enter next step; (6) the start loading procedure is checked the verification of first system's image cut section or second system's image cut section and whether correct according to the value of current first boot variable; If it is correct, the start loading procedure remembers to change after the value of first boot variable value of first boot variable again, and the full content in the first boot variable cut section is copied in the second boot variable cut section, and replace the interior full content of the second boot variable cut section; If mistake, the start loading procedure is only remembered the more revaluate of first boot variable, but does not change first boot variable; (7) the start loading procedure selects to login first system's image cut section or second system's image cut section according to the value of being remembered; (8) whether software upgrade procedure checks first boot variable effective; If invalid, execution in step (5); If effectively, software upgrade procedure is changed the value of first boot variable, and the full content in the first boot variable cut section is copied in the second boot variable cut section, and replace the full content in the second boot variable cut section; (9) software upgrade procedure judges whether the demand of software upgrading, if any, return the first step and begin to carry out, as do not have, then wait for.
In sum, flash system of the present invention is provided with one first system's image cut section, one second system's image cut section, one first boot variable cut section and one second boot variable cut section.In the kernel program of in upgrading first system's image cut section or second system's image cut section, being stored and the process of root archives economy program, if the outage situation occurs, only destroy kernel program and the root Documentor in first system's image cut section or the second system's image cut section of being stored in of not finishing renewal.After restarting, method for updating program according to flash system, first boot variable that the start loading procedure can be stored respectively according to institute in the first boot variable cut section and the second boot variable cut section and the value of second boot variable, kernel program and the root archives economy program of selecting the not ruined system of operation image cut section to be stored, thus guarantee that product still can normal boot-strap under the situation of program updates failure.
Embodiment
For describing technology contents of the present invention, structural attitude, the purpose of being reached and effect in detail, described in detail below in conjunction with embodiment and conjunction with figs..
See also Fig. 1, flash system 100 of the present invention, be applied on the electronic product, this flash system 100 comprises one first system's image cut section 60, one second system's image cut section 70, one first boot variable cut section 20, one second boot variable cut section 30 and a start loading procedure cut section 10.
First system's image cut section 60 comprises a kernel program cut section 40 and an archives economy program cut section 50, described kernel program cut section 40 is used to store kernel program, described archives economy program cut section 50 is used to store root archives economy program, comprises a software upgrade procedure in the root archives economy program.
Second system's image cut section 70 comprises a kernel program cut section 40 and an archives economy program cut section 50, described kernel program cut section 40 is used to store kernel program, described archives economy program cut section 50 is used to store root archives economy program, comprises a software upgrade procedure in the root archives economy program.
The first boot variable cut section 20 is used to store one first boot variable, described software upgrade procedure can check whether the value of first boot variable is correct, and according to value selection renewal first system's image cut section 60 of first boot variable or kernel program and the root archives economy program in second system's image cut section 70.
The second boot variable cut section 30 is used to store one second boot variable.
Start loading procedure cut section 10 stores the start loading procedure, be used for initiating hardware equipment, whether the numerical value that can check first boot variable is correct, and the full content in the second boot variable cut section 30 can be copied in the first boot variable cut section 20, and replace full content in the first boot variable cut section 20, and can select kernel program and root archives economy program in operation first system's image cut section 60 or the second system's image cut section 70 according to the value of first boot variable.
Wherein, software upgrade procedure can check whether kernel program and the root archives economy program in the corresponding system image cut section be correct, software upgrade procedure can be selected the repayment mistake according to check result, the numerical value of perhaps revising first boot variable also can copy to the full contents in the first boot variable cut section 20 in the second boot variable cut section 30, and replaces the full content in the second boot variable cut section 30.
Described first system's image cut section 60, second system's image cut section 70, the first boot variable cut section 20 and the second boot variable cut section 30 all store a verification and, whether correct in order to the content that detects these cut sections.
The electronic product of described this flash system of application is provided with a buffer zone, and wherein said start loading procedure and software upgrade procedure operation such as calculate by the full content in the cut section being read in this buffer zone to the content of this cut section.And the electronic product of using this flash system is provided with a timer, and wherein said software upgrade procedure can stop timer work.
The method for updating program of flash system of the present invention, the full content that is set in the original state first boot variable cut section is consistent with the second boot variable cut section, and the initial value of first boot variable and second boot variable is 0, and the current boot system image of system is first system's image cut section 60.Wherein, software upgrade procedure and start loading procedure can select all the time the first boot variable cut section 20 or the second boot variable cut section 30 calculates and operation such as check, in the present embodiment, set and all the time the first boot variable cut section 20 to be calculated and operation such as check.The method for updating program of this flash system comprises the steps:
Step 81: start and the software upgrade program.
Step 82: software upgrade procedure is read the full content in the first boot variable cut section 20 in the buffer zone, and according to the full contents in the first boot variable cut section 20 in this buffer zone calculate verification and, software upgrade procedure is checked verification that the verification that calculated with whether stored with the first boot variable cut section 20 and consistent.As unanimity, then first boot variable is effectively, execution in step 83; As inconsistent, then first boot variable is invalid, and then execution in step 85.
Step 83: software upgrade procedure calculates the system's image cut section that will be updated according to the value of first boot variable.Concrete computing method are software upgrade procedure value and 1 XOR values with first boot variable, are 1 as the result, and then software upgrade procedure selects to upgrade second system's image cut section 70 (being execution in step 84); As the result is 0, and then software upgrade procedure selects to upgrade first system's image cut section 60.
Step 84: because of setting the first boot variable initial value is 0,0 XOR 1 then, value is 1, software upgrade procedure select with new procedures replace kernel program in second system's image cut section 70, root archives economy programs and corresponding to the verification of second system's image cut section 70 and.
Step 85: restart system, execution in step 90.
Step 86: software upgrade procedure is read the full content of second system's image cut section 70 in the buffer zone, and according to the full contents in second system's image cut section 70 in this buffer zone calculate verification and, software upgrade procedure is checked verification that the verification that calculated with whether stored with second system's image cut section 70 and consistent.As unanimity, the renewal success of expression step 84, promptly second system's image cut section 70 upgrades successfully, and then execution in step 87; As inconsistent, represent the image cut section 70 program updates failure of second system, then execution in step 89.
Step 87: software upgrade procedure is changed the value of first boot variable.The change method is with the value of first boot variable and 1 XOR value, because the initial value of first boot variable is 0,0 XOR 1, value is 1, and promptly the value of change back first boot variable is 1.Then, software upgrade procedure copies to the full content of the first boot variable cut section 20 in the second boot variable cut section 30, and replaces the full content of the second boot variable cut section 30, and thus, the value of second boot variable also is 1.
Step 88: software upgrade procedure restarting systems.
Step 89: software upgrade procedure finishes to carry out and the repayment mistake, returns execution in step 81.
Step 90: after restarting system, the start loading procedure begins to carry out.
Step 91: the start loading procedure is read the full content in the first boot variable cut section 20 in the buffer zone, and according to the full contents in the first boot variable cut section 20 in this buffer zone calculate verification and, the start loading procedure is checked verification that the verification that calculated with whether stored with the first boot variable cut section 20 and consistent.As unanimity, execution in step 92; As inconsistent, execution in step 95.
Step 92: the start loading procedure selects to login first system's image cut section 60 or second system's image cut section 70 according to the value of first boot variable.Because the value of present first boot variable is 1, therefore earlier the full content of this second system image cut section 70 is read in the buffer zone, and calculate second system's image cut section 70 in this buffer zone verification and, the start loading procedure is checked verification that the verification that calculated with whether stored with second system's image cut section 70 and consistent.As unanimity, execution in step 93; As inconsistent, execution in step 96.
Step 93: the start loading procedure is remembered the currency 1 of first boot variable earlier, and then with the value and the 1 XOR value of first boot variable, promptly 1 XOR, 1 value is 0, thereby the value of first boot variable is changed to 0, the full content of the first boot variable cut section 20 is copied in the second boot variable cut section 30, and replace the full content of the second boot variable cut section 30.
Step 94: the start loading procedure selects to login first system's image cut section 60 or second system's image cut section 70 according to the value of first boot variable of being remembered.As the value that the loading procedure of starting shooting is remembered is 1, then selects to login second system's image cut section 70, and the value of remembeing as the start loading procedure is 0, then selects to login first system's image cut section 60.Because of the value of first boot variable remembered of start loading procedure in the step 94 is 1, then select to login second system's image cut section 70.
Step 95: after the start loading procedure duplicates and be substituted into the full content in the second boot variable cut section 30 in the first boot variable cut section 20, execution in step 92 again, guaranteeing being convenient program updates when unsuccessful, start verification that loading procedure calculated and the verification of being stored with the first boot variable cut section 20 and consistent.
Step 96: the start loading procedure is only remembered the value of first boot variable and the value after the 1 XOR value, i.e. 1 XOR 1, and value is 0, the value of remembeing 0, but do not change the value of first boot variable, execution in step 97.
Step 97: the start loading procedure selects to login first system's image cut section 60.
Step 98: login to second system's image cut section 70 (steps 94) or first system's image cut section 60 (steps 97) beginning software upgrade program finishing.
Step 99: at first, software upgrade procedure makes timer out of service, restarts in order to avoid judge the on time long system that makes because of timer.Then, software upgrade procedure is read the full content of the first boot variable cut section 20 in the buffer zone, and calculate the first boot variable cut section 20 in this buffer zone verification and, software upgrade procedure is checked verification that the verification that calculated with whether stored with the first boot variable cut section 20 and consistent.As unanimity, execution in step 100; As inconsistent, execution in step 101.
Step 100: software upgrade procedure is changed the value of first boot variable, is about to the value 0 and the 1 XOR value of first boot variable that step 96 sets, 0 XOR 1 then, and value is 1.Software upgrade procedure copies to the full content of the first boot variable cut section 20 in the second boot variable cut section 30 again, and replaces the full content of the second boot variable cut section 30.
Step 101: restart system, the start loading procedure begins to carry out, and promptly begins to carry out from step 90.
Step 102: software upgrade procedure is waited for the demand whether software upgrading is arranged, if any, execution in step 103, otherwise execution in step 104.
Step 103: return step 81 and begin to carry out.
Step 104: software upgrade procedure is waited for next upgrade requirement.
Flash system of the present invention moves to this process of step 89 by described step 81, software upgrade procedure is finished being stored in the kernel program in second system's image cut section 70 and the renewal of root archives economy program, whether successful and software upgrade procedure is according to checking verification that the verification that calculated with whether stored with second system's image cut section 70 and consistent, finish program updates check.
After restarting system, first is performed the start loading procedure, move to step 103 or this process of step 104 by described step 90, the start loading procedure selects to move first system's image cut section 60 or interior kernel program and the root archives economy program of second system's image cut section 70 according to step 81 to the value of first boot variable of step 89 storage that this process is calculated.As program updates failure, it is destroyed to have upgraded second system's image cut section 70 contents, and the start loading procedure can select to move kernel program in the first system's image cut section 60 that is not updated and root archives economy program to guarantee to finish start.
In the present embodiment, software upgrade procedure changes to 1 with the value of first, second boot variable, and the start loading procedure can select to move the kernel program and the root archives economy program of second system's image cut section 70 stored of having upgraded according to the value 1 of first boot variable when guaranteeing to start shooting once more.Equally, if software upgrade procedure finds to have the program updates demand, then returning step 81 restarts to carry out, and this moment first boot variable and second boot variable value be 1, be that initial value is 1, then, can carry out corresponding renewal the first system's image cut section 60 that was not updated according to the method for updating program of above-mentioned flash system, promptly in program updates process each time, all can carry out program updates to system's image cut section of legacy version.
In sum, flash system 100 of the present invention is provided with one first system's image cut section 60, one second system's image cut section 70, one first boot variable cut section 20 and one second boot variable cut section 30, in the kernel program of in upgrading second system's image cut section 70, being stored and the process of root archives economy program, if the outage situation occurs, only destroy kernel program and the root Documentor in second system's image cut section 70 of being stored in of not finishing renewal.After restarting, method for updating program according to above-mentioned flash system, first boot variable that the start loading procedure can be stored respectively according to institute in the first boot variable cut section 20 and the second boot variable cut section 30 and the value of second boot variable, kernel program and root archives economy program that first system's image cut section 60 of selecting operation not to be updated is stored, thus guarantee that product still can normal boot-strap under the situation of upgrading failure.