Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
Embodiment 1
The embodiment of the invention provides a kind of embedded device parameter store method, and as shown in Figure 1, this method comprises:
101, in the memory headroom of flash memory, be provided for preserving first address and second address of embedded device parameter, also preserve respectively in described first address and second address and be used to indicate whether effectively zone bit of described parameter.
Wherein, being provided with of described first address and second address can specifically be provided with according to user's demand, for example, the first address Address1=0x80000000, the second address Address2=0x90000000, but the size of described parameter can not surpass Address1-Address2=0x10000000 byte.
102, when the embedded device parameter in the Synchronous Dynamic Random Access Memory changes the needs preservation, from described first address and second address, the address that to choose described sign place value be invalid value is as preserving the described address that changes the back parameter according to described zone bit.Described sign place value is that invalid value shows that the parameter of preserving in this address is current and is not used, and described sign place value is that effective value shows that the parameter of preserving in this address is current and is used.
Wherein, described sign place value can be according to user's use habit setting, and the effective value of this zone bit and invalid value also can be according to user's custom settings, and the embodiment of the invention does not limit this; For example, it is the value of one 16 system that described sign place value is set, and 0x5a is set is effective value, and the value except 0x5a is all thought invalid value; But when described sign place value is the value of one 16 system,, therefore when described sign place value is set, generally do not use 0x00 and 0xff two values in order to be different from default value because 0x00 and two values of 0xff are traditionally arranged to be the default value of system.
103, the described parameter of choosing in the address is wiped, and described variation back parameter is saved in described choosing in the address.
In the embodiment of the invention, two addresses are set in order to preserve parameter in flash memory, and in the address of described preservation parameter, preserve one and be used to indicate the current whether effectively zone bit of parameter in this address, when parameter need be preserved, choose the current invalid address of parameter in the address according to described sign place value, so that described variation back parameter is saved in the described address of choosing; Compared with prior art, in the embodiment of the invention, when the embedded device parameter in the Synchronous Dynamic Random Access Memory changes the needs preservation, described parameter of need preserving is saved in the address that parameter current do not using, because described current being in of choosing in the address of parameter do not have user mode, even if in the process of preserving described parameter, raw parameter in this address is wiped, preserve the not success of described parameter, and the current parameter of using is not wiped, keep original state, guaranteed that systematic parameter do not lose, thereby make system in power down or can be normal when restarting, operation reliably.
Embodiment 2
The embodiment of the invention provides a kind of embedded device parameter store method, and as shown in Figure 2, this method comprises:
201, in the memory headroom of flash memory, be provided for preserving first address and second address of embedded device parameter, also preserve respectively in described first address and second address and be used to indicate whether effectively zone bit of described parameter.
Wherein, being provided with of described first address and second address can specifically be provided with according to user's demand, for example, the first address Address1=0x80000000, the second address Address2=0x90000000, but the size of described parameter can not surpass Address1-Address2=0x10000000 byte.
Wherein, described embedded device parameter and zone bit are kept in described first address and second address with the form of structure member variable; Before being saved in described parameter and zone bit in the described address, need write structure, and the described structure of writing stated in code with the form of global variable, this global variable is kept at SDRAM (Synchronous Dynamic Random Access Memory, Synchronous Dynamic Random Access Memory); The member variable that comprises embedded device parameter and described zone bit in the described structure, the particular type of described structure body weight member variable can specifically be provided with as the case may be by the user, the embodiment of the invention does not limit this, for example: define a PARA_INFO_S structure, be specially:
Struct?PARA_INFO_S
{
Int flag; // zone bit
Int num; // parameter
Char value; // parameter
......
}。
202, when the embedded device parameter in the Synchronous Dynamic Random Access Memory changes the needs preservation, from described first address and second address, the address that to choose described sign place value be invalid value is as preserving the described address that changes the back parameter according to described zone bit.Described sign place value is that invalid value shows that the parameter of preserving in this address is current and is not used, and described sign place value is that effective value shows that the parameter of preserving in this address is current and is used.
Wherein, described according to described zone bit from described first address and second address, the address that to choose described sign place value be invalid value comprises as preserving the described address that changes the back parameter:
Read the value of described zone bit in described first address and second address;
If the sign place value of described first address of reading is an effective value, then choose described second address as preserving the described address that changes the back parameter;
If the sign place value of described second address of reading is an effective value, then choose described first address as preserving the described address that changes the back parameter;
If the sign place value of described first address of reading and the sign place value of described second address all be invalid value, then choose arbitrary address in described first address and described second address as preserving the described address of parameter afterwards that changes.
Wherein, described sign place value can be according to user's use habit setting, and the effective value of this zone bit and invalid value also can be according to user's custom settings, and the embodiment of the invention does not limit this; For example, it is the value of one 16 system that described sign place value is set, and 0x5a is set is effective value, and the value except 0x5a is all thought invalid value; But when the value of described zone bit is the value of one 16 system,, therefore when the value of described sign is set, generally do not use 0x00 and 0xff two values in order to be different from default value because 0x00 and two values of 0xff are traditionally arranged to be the default value of system.
And described embedded device parameter in Synchronous Dynamic Random Access Memory changes when needing to preserve, if there are hold-over command or button in system, can when the user wishes to preserve, call packaged preservation function, but inventive embodiments does not limit to this.
203, the described parameter of choosing in the address is wiped, and described variation back parameter is saved in described choosing in the address.
204, judge described variations back parameter is saved in describedly whether successfully to choose the address; If judge described variation back parameter is saved in the described address success of choosing, then execution in step 205; If judge that described variation back parameter is saved in the described address of choosing to get nowhere, then execution in step 207;
205, the described sign place value of choosing the address is set to effective value, in the time of need using described parameter with convenient system, so that operate accordingly according to described sign place value.
206, the parameter of preserving in another address in the described flash memory space is wiped, and the sign place value of described another address is set to invalid value, so that operate accordingly according to the value of described zone bit.
207, withdraw from the preservation of described parameter.
Further, when needs use the embedded device parameter that is kept in the described flash memory,,, need realize reading of parameter according to following method in order to obtain correct parameter owing to comprise the address of two stored parameters in the described flash memory:
Obtain described parameter according to described zone bit;
The described parameter of obtaining is duplicated the described parameter that obtains duplicating;
The described parameter of duplicating is sent to described Synchronous Dynamic Random Access Memory.
Wherein, describedly obtain described parameter according to described zone bit and comprise: the value that reads described zone bit in described first address and second address; If the sign place value of described first address of reading is an effective value, then from described first address, obtain described parameter; If the sign place value of described second address of reading is an effective value, then from described second address, obtain described parameter; If the sign place value of described first address of reading and the sign place value of described second address all are effective value, then from described first address or described second address, obtain described parameter; If the sign place value of described first address and the sign place value of described second address all are invalid value, then will use default parameters as described parameter.
In the embodiment of the invention, two addresses are set in order to preserve parameter in flash memory, and in the address of described preservation parameter, preserve one and be used to indicate the current whether effectively zone bit of parameter in this address, when parameter need be preserved, choose the current invalid address of parameter in the address according to the value of described zone bit, so that described variation back parameter is saved in the described address of choosing; Compared with prior art, in the embodiment of the invention, when the embedded device parameter in the Synchronous Dynamic Random Access Memory need be preserved, described parameter of need preserving is saved in the address that parameter current do not using, because described current being in of choosing in the address of parameter do not have user mode, even if in the process of preserving described parameter, raw parameter in this address is wiped, preserve the not success of described parameter, and the current parameter of using is not wiped, keep original state, guaranteed that systematic parameter do not lose, thereby make system in power down or can be normal when restarting, operation reliably.
Further, after the method for the preservation parameter of the employing embodiment of the invention, because when preserving variation back parameter, as if preserving successfully, then the sign place value of described address is set to effectively, and be not used in the sign place value that preserve to change the back argument address be set to invalid; If preserve when getting nowhere, the sign place value of the parameter corresponding address that maintenance is being used is effective value; Therefore by above-mentioned setting, change back parameter success or not no matter preserve, it is complete can both keeping in the described flash memory in two addresses a parameter in the address being arranged, and has guaranteed that systematic parameter do not lose, thus make system can be normally in power down or when restarting, operation reliably; After needs used parameter in the described flash memory, according to the parameter in the described zone bit address that to choose described sign place value be effective value, the system that just can realize can be normally in power down or when restarting, operation reliably.
Embodiment 3
The embodiment of the invention provides a kind of embedded device parameter save set, and as shown in Figure 3, this device comprises: address setting unit 31, choose unit 32, erase unit 33 and preserve unit 34.
Whether effectively address setting unit 31 is used for being provided for preserving at the memory headroom of flash memory first address and second address of embedded device parameter, also preserve respectively in described first address and second address to be used to indicate described parameter zone bit; Wherein, being provided with of described first address and second address can specifically be provided with according to user's demand, for example, the first address Address1=0x80000000, the second address Address2=0x90000000, but the size of described parameter can not surpass Address1-Address2=0x10000000 byte.
Choose unit 32, be used for when the embedded device parameter of Synchronous Dynamic Random Access Memory changes the needs preservation, from described first address and second address, the address that to choose described sign place value be invalid value is as preserving the described address that changes the back parameter according to described zone bit; Described sign place value is that invalid value shows that the parameter of preserving in this address is current and is not used, and described sign place value is that effective value shows that the parameter of preserving in this address is current and is used.Wherein, the value of described zone bit can be according to user's use habit setting, and the effective value of this zone bit and invalid value also can be according to user's custom settings, and the embodiment of the invention does not limit this; For example, the value that described zone bit is set is the value of one 16 system, and 0x5a is set is effective value, and the value except 0x5a is all thought invalid value; But when the value of described zone bit is the value of one 16 system,, therefore when the value of described sign is set, generally do not use 0x00 and 0xff two values in order to be different from default value because 0x00 and two values of 0xff are traditionally arranged to be the default value of system.
Erase unit 33 is used for the described parameter of choosing in the address unit 32 of choosing is wiped; Preserve unit 34, be used for described variation back parameter is saved in the described address that unit 32 is chosen of choosing.
In the embodiment of the invention, two addresses are set in order to preserve parameter in flash memory, and in the address of described preservation parameter, preserve one and be used to indicate the current whether effectively zone bit of parameter in this address, when parameter need be preserved, choose the current invalid address of parameter in the address according to described sign place value, so that described variation back parameter is saved in the described address of choosing; Compared with prior art, in the embodiment of the invention, when the embedded device parameter in the Synchronous Dynamic Random Access Memory need be preserved, described parameter of need preserving is saved in the address that parameter current do not using, because described current being in of choosing in the address of parameter do not have user mode, even if in the process of preserving described parameter, raw parameter in this address is wiped, preserve the not success of described parameter, and the current parameter of using is not wiped, keep original state, guaranteed that systematic parameter do not lose, thereby make system in power down or can not be normal when restarting, operation reliably.
Embodiment 4
The embodiment of the invention provides a kind of embedded device parameter save set, and as shown in Figure 4, this device comprises: address setting unit 41, choose unit 42, erase unit 43, preserve unit 44, judging unit 45 and sign unit 46 is set.
Whether effectively address setting unit 41 is used for being provided for preserving at the memory headroom of flash memory first address and second address of embedded device parameter, also preserve respectively in described first address and second address to be used to indicate described parameter zone bit; Wherein, being provided with of described first address and second address can specifically be provided with according to user's demand, for example, the first address Address1=0x80000000, the second address Address2=0x90000000, but the size of described parameter can not surpass Address1-Address2=0x10000000 byte.
Wherein, described embedded device parameter and zone bit are kept in described first address and second address with the form of structure member variable; Before being saved in described parameter and zone bit in the described address, need writing structure, and the described structure of writing is stated in code that with the form of global variable this global variable is kept in the Synchronous Dynamic Random Access Memory; The member variable that comprises embedded device parameter and described zone bit in the described structure, the particular type of described structure body weight member variable can specifically be provided with as the case may be by the user, and the embodiment of the invention does not limit this.
Choose unit 42, be used for when the embedded device parameter of Synchronous Dynamic Random Access Memory changes the needs preservation, from described first address and second address, the address that to choose described sign place value be invalid value is as preserving the described address that changes the back parameter according to described zone bit; Described sign place value is that invalid value shows that the parameter of preserving in this address is current and is not used, and described sign place value is that effective value shows that the parameter of preserving in this address is current and is used.
Erase unit 43 is used for the described parameter of choosing in the address unit 42 of choosing is wiped; Preserve unit 44, be used for described variation back parameter is saved in the described address that unit 43 is chosen of choosing.
Judging unit 45, be used for described variation back parameter is saved in described choose unit 43 and choose the address after, judge described variations back parameter is saved in the described whether success of address of choosing; Judge at described judging unit 45 described variations back parameter is saved in the described address of choosing when successful that zone bit is provided with unit 46 and is used for the described sign place value of choosing the address and is set to effective value; Described erase unit 43 also is used for the parameter of preserving in another address of described flash memory space is wiped; Described zone bit is provided with the sign place value that unit 46 also is used for described another address and is set to invalid value, so that operate accordingly according to the value of described zone bit.
Judge at described judging unit 45 described variations back parameter to be saved in described when choosing the address and getting nowhere, withdraw from the preservation of described parameter.
Wherein, the described unit 42 of choosing comprises: read module 421 and choose module 422.
When the described unit 42 of choosing changes when need preserving in described parameter, according to described zone bit from described first address and second address, the value of described zone bit in described first address and second address is at first read when preserving the described address that changes the back parameter in the address that to choose described sign place value be invalid value by described read module 421; If the sign place value of first address that described read module 421 reads is an effective value, then chooses module 422 and choose described second address as preserving the described address that changes the back parameter; If the sign place value of second address that described read module 421 reads is an effective value, then chooses module 422 and choose described first address as preserving the described address that changes the back parameter; If the sign place value of described read module 421 first address of reading and the sign place value of described second address all be invalid value, then choose module 422 and choose arbitrary address in described first address and described second address as preserving the described address of parameter afterwards that changes.
Wherein, described sign place value can be according to user's use habit setting, and the effective value of this zone bit and invalid value also can be according to user's custom settings, and the embodiment of the invention does not limit this; For example, the value that described zone bit is set is the value of one 16 system, and 0x5a is set is effective value, and the value except 0x5a is all thought invalid value; But when the value of described zone bit is the value of one 16 system,, therefore when the value of described sign is set, generally do not use 0x00 and 0xff two values in order to be different from default value because 0x00 and two values of 0xff are traditionally arranged to be the default value of system.
And described embedded device parameter in Synchronous Dynamic Random Access Memory changes when needing to preserve, if there are hold-over command or button in system, can when the user wishes to preserve, call packaged preservation function, but inventive embodiments does not limit to this.
Further, when needs use the embedded device parameter that is kept in the described flash memory, owing to comprise the address of two stored parameters in the described flash memory, in order to obtain correct parameter, as shown in Figure 5, this device also comprises: acquiring unit 47, copied cells 48 and transmitting element 49.
Acquiring unit 47 is used for obtaining described parameter according to described zone bit; After obtaining described parameter, copied cells 48 is used for the described parameter that acquiring unit 47 obtains is duplicated the described parameter that obtains duplicating; Transmitting element 49 is used for the described parameter that described copied cells 48 duplicates is sent to Synchronous Dynamic Random Access Memory, so that make system finish corresponding operation according to described parameter.
Wherein, described acquiring unit 47 comprises: second read module 471 and acquisition module 472.When described acquiring unit 47 obtains described parameter according to described zone bit, at first read the value of described zone bit in described first address and second address by described second read module 471; When the sign place value in first address that described second read module 471 reads was effective value, acquisition module 472 obtained described parameter from described first address; When the sign place value in second address that second read module 471 reads was effective value, described acquisition module 472 obtained described parameter from described second address; If when the sign place value of first address that described second read module 471 reads and the sign place value of described second address all were effective value, described acquisition module 472 obtained described parameter from described first address or described second address; When the sign place value in the sign place value of first address that described second read module 471 reads and described second address all is invalid value, will use default parameters as described parameter.
In the embodiment of the invention, two addresses are set in order to preserve parameter in flash memory, and in the address of described preservation parameter, preserve one and be used to indicate the current whether effectively zone bit of parameter in this address, when parameter need be preserved, choose the current invalid address of parameter in the address according to described sign place value, so that described variation back parameter is saved in the described address of choosing; Compared with prior art, in the embodiment of the invention, when the embedded device parameter in the Synchronous Dynamic Random Access Memory need be preserved, described parameter of need preserving is saved in the address that parameter current do not using, because described current being in of choosing in the address of parameter do not have user mode, even if in the process of preserving described parameter, raw parameter in this address is wiped, preserve the not success of described parameter, and the current parameter of using is not wiped, keep original state, guaranteed that systematic parameter do not lose, thereby make system in power down or can be normal when restarting, operation reliably.
Further, after the method for the preservation parameter of the employing embodiment of the invention, because when the parameter of preserving after changing, if preserve successfully, then the sign place value of described address is set to effectively, and be not used in the sign place value that preserve to change the back argument address be set to invalid; If preserve when getting nowhere, the sign place value of the parameter corresponding address that maintenance is being used is effective value; Therefore by above-mentioned setting, no matter preserve the parameter success or not after changing, it is complete can both keeping in the described flash memory in two addresses the parameter of an address being arranged, and has guaranteed that systematic parameter do not lose, thus make system can be normally in power down or when restarting, operation reliably; After needs used parameter in the described flash memory, the value of choosing described zone bit according to described zone bit was the parameter in the effective address, and the system that just can realize can be normally in power down or when restarting, operation reliably.
Through the above description of the embodiments, the those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential common hardware, can certainly pass through hardware, but the former is better embodiment under a lot of situation.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product is stored in the storage medium that can read, floppy disk as computing machine, hard disk or CD etc., comprise some instructions with so that computer equipment (can be personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the present invention.
The above; only be the specific embodiment of the present invention, but protection scope of the present invention is not limited thereto, anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; can expect easily changing or replacing, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of described claim.