Configuration information access method, device and computer readable storage medium
By writing the configuration information into RAM in the Bluetooth headset products, it is synchronized to Flash, and the configuration information in RAM is preferred when the system starts, which solves the problem of inaccurate configuration information due to abnormal restart to ensure the normal operation of the system function.
Patent Information
- Application Number
- CN202110851498.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-27
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2041-07-27
AI Technical Summary
During the synchronization of configuration information to Flash, the configuration information synchronized to Flash is inaccurate due to abnormal restart, or is not synchronized to Flash, which in turn leads to inaccurate configuration information read during product startup, causing abnormal system functions.
When receiving the configuration information writing request, write the configuration information into RAM and synchronize the configuration information in the RAM to Flash. When the system starts, first get the effectiveness of the configuration information from the RAM. If it is valid, the operation of the system is performed according to the configuration information in the RAM, and the configuration information in the Flash is inconsistent with the configuration information in the RAM. The configuration information is synchronized to Flash.
By configured RAM's attributes to no power restart data, it is not updated, ensuring that the effective configuration information execution system can be obtained from the RAM after the abnormal restart, and the configuration information in the synchronous RAM can be Effective configuration information is obtained from Flash when the system starts to avoid system functional abnormalities.
Smart Images

Figure CN113553086B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a configuration information access method, device and computer-readable storage medium. Background Art
[0002] During the factory production process of Bluetooth headset products, some configuration information is written into the product, such as the hardware version number, calibration value, etc. After this configuration information is written into the product, it will be saved in the product's Flash. During the product startup process, the relevant configuration information will be read from the Flash, and then different processing operations will be performed according to the configuration. At present, during the process of synchronizing the configuration information to the Flash, it may restart abnormally, resulting in inaccurate configuration information synchronized to the Flash, or no synchronization to the Flash, which will cause the subsequent product to read inaccurate configuration information during the startup process, resulting in system function abnormalities. Summary of the invention
[0003] The main purpose of the present invention is to provide a configuration information access method, device and computer-readable storage medium, aiming to solve the technical problem of system function abnormality when the configuration information is synchronized to Flash due to an abnormal restart, resulting in inaccurate configuration information synchronized to Flash.
[0004] To achieve the above object, the present invention provides a configuration information access method, the method comprising the following steps:
[0005] When a configuration information write request is received, the configuration information to be written corresponding to the configuration information write request is written into the RAM, and then the configuration information in the RAM is synchronized to the Flash, wherein the RAM attribute is configured so that the data is not updated when the power is off and restarted;
[0006] When the system starts, check whether the configuration information in RAM is valid;
[0007] If the configuration information in the RAM is valid, the system startup operation is performed according to the configuration information in the RAM, and the configuration information in the Flash is detected to be consistent with the configuration information in the RAM;
[0008] If they are inconsistent, the configuration information in RAM is synchronized to Flash.
[0009] Optionally, the step of synchronizing the configuration information in the RAM to the Flash includes:
[0010] Synchronize the configuration information in RAM to the main partition of Flash, and then check whether the configuration information in the main partition of Flash is valid;
[0011] If the configuration information in the primary partition of the Flash is valid, the configuration information in the RAM is synchronized to the backup area of the Flash;
[0012] If the configuration information in the primary partition of the Flash is invalid, retry to synchronize the configuration information in the RAM to the primary partition of the Flash.
[0013] Optionally, when a configuration information write request is received, the step of writing the configuration information to be written corresponding to the configuration information write request into the RAM includes:
[0014] When receiving a configuration information write request, checking whether the configuration information in the RAM is valid;
[0015] If the configuration information in the RAM is valid, the configuration information to be written corresponding to the configuration information writing request is written into the RAM;
[0016] If the configuration information in RAM is invalid, read and check whether the configuration information in Flash is valid;
[0017] If the configuration information in the Flash is valid, after synchronizing the configuration information in the Flash to the RAM, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0018] Optionally, if the configuration information in the RAM is invalid, the step of reading and detecting whether the configuration information in the Flash is valid includes:
[0019] If the configuration information in the RAM is invalid, read and check whether the configuration information in the main partition of the Flash is valid;
[0020] If the configuration information in the Flash is valid, the step of synchronizing the configuration information in the Flash to the RAM and then writing the configuration information to be written corresponding to the configuration information write request into the RAM includes:
[0021] If the configuration information in the main partition of the Flash is valid, after synchronizing the configuration information in the main partition of the Flash to the RAM, the configuration information to be written corresponding to the configuration information write request is written into the RAM;
[0022] If the configuration information in the primary partition of the Flash is invalid, read and check whether the configuration information in the backup area of the Flash is valid;
[0023] If the configuration information in the backup area of the Flash is valid, after synchronizing the configuration information in the backup area of the Flash to the RAM and the main partition of the Flash, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0024] Optionally, after the step of reading and detecting whether the configuration information in the Flash is valid if the configuration information in the RAM is invalid, the step further includes:
[0025] If the configuration information in the Flash is invalid, after resetting the configuration information in the RAM and the Flash to preset default values, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0026] Optionally, after the step of detecting whether the configuration information in the RAM is valid when the system is started, the method further includes:
[0027] If the configuration information in RAM is invalid, read and check whether the configuration information in Flash is valid;
[0028] If the configuration information in the Flash is valid, the system startup operation is performed according to the configuration information in the Flash, and the configuration information in the Flash is synchronized to the RAM.
[0029] Optionally, if the configuration information in the RAM is invalid, the step of reading and detecting whether the configuration information in the Flash is valid includes:
[0030] If the configuration information in the RAM is invalid, read and check whether the configuration information in the main partition of the Flash is valid;
[0031] If the configuration information in the Flash is valid, the steps of performing a system startup operation according to the configuration information in the Flash and synchronizing the configuration information in the Flash to the RAM include:
[0032] If the configuration information in the main partition of the Flash is valid, the system startup operation is performed according to the configuration information in the main partition of the Flash, and the configuration information in the main partition of the Flash is synchronized to the RAM;
[0033] If the configuration information in the primary partition of the Flash is invalid, read and check whether the configuration information in the backup area of the Flash is valid;
[0034] If the configuration information in the backup area of the Flash is valid, the system startup operation is performed according to the configuration information in the backup area of the Flash, and the configuration information in the backup area of the Flash is synchronized to the main partitions of the RAM and the Flash.
[0035] Optionally, after the step of reading and detecting whether the configuration information in the Flash is valid if the configuration information in the RAM is invalid, the step further includes:
[0036] If the configuration information in the Flash is invalid, the system startup operation is performed according to the preset default values, and the preset default values are written into the RAM and the Flash as the configuration information.
[0037] To achieve the above object, the present invention further provides a configuration information access device, the device comprising:
[0038] A writing module, which is used to write the configuration information to be written corresponding to the configuration information writing request into the RAM when receiving the configuration information writing request, and then synchronize the configuration information in the RAM to the Flash, wherein the attribute of the RAM is configured so that the data is not updated when the power is off and restarted;
[0039] The first detection module is used to detect whether the configuration information in the RAM is valid when the system starts;
[0040] A second detection module is used to execute a system startup operation according to the configuration information in the RAM if the configuration information in the RAM is valid, and detect whether the configuration information in the Flash is consistent with the configuration information in the RAM;
[0041] The synchronization module is used to synchronize the configuration information in the RAM to the Flash if there is any inconsistency.
[0042] To achieve the above-mentioned purpose, the present invention also provides a configuration information access device, which includes: a memory, a processor, and a configuration information access program stored in the memory and executable on the processor, and the configuration information access program implements the steps of the configuration information access method described above when executed by the processor.
[0043] In addition, to achieve the above objectives, the present invention also proposes a computer-readable storage medium, on which a configuration information access program is stored, and when the configuration information access program is executed by a processor, the steps of the configuration information access method described above are implemented.
[0044] In the present invention, by configuring the RAM attribute so that the data is not updated when the power is turned off and restarted, when a configuration information write request is received, the configuration information to be written corresponding to the configuration information write request is written into the RAM, and then the configuration information in the RAM is synchronized to the Flash. When the system starts, the configuration information is first obtained from the RAM to detect whether the configuration information is valid. If it is valid, the configuration information in the RAM is used to perform subsequent system startup operations, and when the configuration information in the Flash is inconsistent with the configuration information in the RAM, the configuration information in the RAM is synchronized to the Flash. It is achieved that when an abnormal restart occurs when writing the configuration information, resulting in the configuration information not being synchronized to the Flash or the configuration information synchronized to the Flash is wrong, valid configuration information can also be obtained from the RAM to perform subsequent system startup operations, and by synchronizing the valid configuration information in the RAM to the Flash, when the system is restarted after a subsequent power outage, valid configuration information can also be obtained from the Flash to perform subsequent system startup operations, thereby ensuring the normal operation of the system functions. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A schematic diagram of the structure of the hardware operating environment involved in the embodiment of the present invention;
[0046] Figure 2 A schematic diagram of a flow chart of a first embodiment of a configuration information access method of the present invention;
[0047] Figure 3 A schematic diagram of a configuration information storage process involved in an embodiment of the present invention;
[0048] Figure 4 The present invention is a flow chart of configuration information reading according to an embodiment of the present invention.
[0049] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0051] like Figure 1 As shown, Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention.
[0052] It should be noted that the configuration information access device in the embodiment of the present invention may be a smart phone, a personal computer, a server or other device, and no specific limitation is made herein.
[0053] like Figure 1As shown, the configuration information access device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0054] Those skilled in the art will understand that Figure 1 The device structure shown in the figure does not constitute a limitation on the configuration information access device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0055] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a configuration information access program. The operating system is a program that manages and controls the hardware and software resources of the device and supports the operation of the configuration information access program and other software or programs. Figure 1 In the device shown, the user interface 1003 is mainly used for data communication with the client; the network interface 1004 is mainly used for establishing a communication connection with the server; and the processor 1001 can be used to call the configuration information access program stored in the memory 1005 and perform the following operations:
[0056] When a configuration information write request is received, the configuration information to be written corresponding to the configuration information write request is written into the RAM, and then the configuration information in the RAM is synchronized to the Flash, wherein the RAM attribute is configured so that the data is not updated when the power is off and restarted;
[0057] When the system starts, check whether the configuration information in RAM is valid;
[0058] If the configuration information in the RAM is valid, the system startup operation is performed according to the configuration information in the RAM, and the configuration information in the Flash is detected to be consistent with the configuration information in the RAM;
[0059] If they are inconsistent, the configuration information in RAM is synchronized to Flash.
[0060] Furthermore, synchronizing the configuration information in the RAM to the Flash includes:
[0061] Synchronize the configuration information in RAM to the main partition of Flash, and then check whether the configuration information in the main partition of Flash is valid;
[0062] If the configuration information in the primary partition of the Flash is valid, the configuration information in the RAM is synchronized to the backup area of the Flash;
[0063] If the configuration information in the primary partition of the Flash is invalid, retry to synchronize the configuration information in the RAM to the primary partition of the Flash.
[0064] Further, when receiving a configuration information write request, writing the configuration information to be written corresponding to the configuration information write request into the RAM includes:
[0065] When receiving a configuration information write request, checking whether the configuration information in the RAM is valid;
[0066] If the configuration information in the RAM is valid, the configuration information to be written corresponding to the configuration information writing request is written into the RAM;
[0067] If the configuration information in RAM is invalid, read and check whether the configuration information in Flash is valid;
[0068] If the configuration information in the Flash is valid, after synchronizing the configuration information in the Flash to the RAM, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0069] Furthermore, if the configuration information in the RAM is invalid, reading and detecting whether the configuration information in the Flash is valid includes:
[0070] If the configuration information in RAM is invalid, read and check whether the configuration information in the main partition of Flash is valid;
[0071] If the configuration information in the Flash is valid, synchronizing the configuration information in the Flash to the RAM, and writing the configuration information to be written corresponding to the configuration information write request into the RAM includes:
[0072] If the configuration information in the main partition of the Flash is valid, after synchronizing the configuration information in the main partition of the Flash to the RAM, the configuration information to be written corresponding to the configuration information write request is written into the RAM;
[0073] If the configuration information in the primary partition of the Flash is invalid, read and check whether the configuration information in the backup area of the Flash is valid;
[0074] If the configuration information in the backup area of the Flash is valid, after synchronizing the configuration information in the backup area of the Flash to the RAM and the main partition of the Flash, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0075] Furthermore, if the configuration information in the RAM is invalid, after reading and detecting whether the configuration information in the Flash is valid, the processor 1001 can also be used to call the configuration information access program stored in the memory 1005 to perform the following operations:
[0076] If the configuration information in the Flash is invalid, after resetting the configuration information in the RAM and the Flash to preset default values, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0077] Furthermore, when the system is started, after detecting whether the configuration information in the RAM is valid, the processor 1001 can also be used to call the configuration information access program stored in the memory 1005 to perform the following operations:
[0078] If the configuration information in RAM is invalid, read and check whether the configuration information in Flash is valid;
[0079] If the configuration information in the Flash is valid, the system startup operation is performed according to the configuration information in the Flash, and the configuration information in the Flash is synchronized to the RAM.
[0080] Furthermore, if the configuration information in the RAM is invalid, reading and detecting whether the configuration information in the Flash is valid includes:
[0081] If the configuration information in the RAM is invalid, read and check whether the configuration information in the main partition of the Flash is valid;
[0082] If the configuration information in the Flash is valid, performing a system startup operation according to the configuration information in the Flash, and synchronizing the configuration information in the Flash to the RAM includes:
[0083] If the configuration information in the main partition of the Flash is valid, the system startup operation is performed according to the configuration information in the main partition of the Flash, and the configuration information in the main partition of the Flash is synchronized to the RAM;
[0084] If the configuration information in the primary partition of the Flash is invalid, read and check whether the configuration information in the backup area of the Flash is valid;
[0085] If the configuration information in the backup area of the Flash is valid, the system startup operation is performed according to the configuration information in the backup area of the Flash, and the configuration information in the backup area of the Flash is synchronized to the main partitions of the RAM and the Flash.
[0086] Furthermore, if the configuration information in the RAM is invalid, after reading and detecting whether the configuration information in the Flash is valid, the processor 1001 can also be used to call the configuration information access program stored in the memory 1005 to perform the following operations:
[0087] If the configuration information in the Flash is invalid, the system startup operation is performed according to the preset default values, and the preset default values are written into the RAM and the Flash as the configuration information.
[0088] Based on the above structure, various embodiments of a configuration information access method are proposed.
[0089] Reference Figure 2 , Figure 2 FIG. 1 is a flow chart of a first embodiment of a configuration information access method according to the present invention.
[0090] The embodiment of the present invention provides an embodiment of the configuration information access method. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described can be performed in a different order than here. The configuration information access method of the present invention is applied to Bluetooth headsets, and can also be applied to devices such as smart phones, personal computers and servers. For ease of description, the execution subject is omitted below to explain each embodiment. In this embodiment, the configuration information access method includes:
[0091] Step S10, when a configuration information write request is received, the configuration information to be written corresponding to the configuration information write request is written into the RAM, and then the configuration information in the RAM is synchronized to the Flash, wherein the attribute of the RAM is configured so that the data is not updated when the power is off and restarted;
[0092] When a configuration information write request is received, the configuration information to be written corresponding to the configuration information write request is written into RAM (a volatile random access memory). Among them, the configuration information write request can be a request for writing configuration information that is sent to the product or triggered in the product by the writing device on the production line accessing the product during product production, or it can also be a request for the user terminal to send a write configuration information to the product through an APP in the user terminal that can be used to modify the product configuration information when the user uses the product. The configuration information to be written corresponding to the configuration information write request can refer to the configuration information that needs to be written to the product carried in the configuration information write request, or it can refer to the configuration information that needs to be written to the product that is sent after the configuration information write request. The properties of RAM are configured so that the data is not updated when the power is not turned off and restarted. Then, after the configuration information to be written is written into RAM, if an abnormal restart occurs and there is no time to synchronize the configuration information to Flash (a non-volatile random access memory), the configuration information in RAM is still there, so that the configuration information in RAM can be used to perform subsequent system startup operations.
[0093] It should be noted that configuration information generally includes multiple items, such as hardware version number, calibration value, etc., which are generally data that cannot be lost after the product loses power and are required when the system starts up, for example, different functions are started according to different configuration information. In this embodiment, the configuration information to be written may include all configuration information items, so that after the configuration information to be written is written into the RAM, the system can directly obtain the configuration information from the RAM to perform subsequent system startup operations.
[0094] After the configuration information to be written is written into the RAM according to the configuration information write request, the configuration information in the RAM is synchronized to the Flash. Specifically, the configuration information in the RAM can be used to overwrite the corresponding configuration information item in the Flash.
[0095] In one embodiment, Flash can be divided into a main partition and a backup area, and the configuration information in RAM can be synchronized to the main partition and backup area of Flash to avoid loss or error of the configuration information of the main partition. The configuration information of the backup area can be used for recovery, thereby improving the storage reliability of the configuration information.
[0096] Step S20, when the system starts, checking whether the configuration information in the RAM is valid;
[0097] Whenever the system starts up and needs to obtain configuration information to perform subsequent system startup operations according to the configuration information, the configuration information can be obtained from the RAM first. Specifically, the configuration information in the RAM can be checked first to see if it is valid; the detection method can refer to the existing configuration information validity detection method, for example, the validity detection can be performed by detecting whether the magic number is a preset fixed value, whether the format version number is the same as the preset version number, and performing a CRC (Cyclic Redundancy Check) check on the entire data area.
[0098] Step S30, if the configuration information in the RAM is valid, the system startup operation is performed according to the configuration information in the RAM, and the configuration information in the Flash is detected to be consistent with the configuration information in the RAM;
[0099] If the configuration information in RAM is valid, the subsequent system startup operations can be performed according to the configuration information in RAM. It should be noted that, since the properties of RAM are configured so that the data is not updated when the power is not turned off and restarted, if the configuration information in RAM is valid when the system starts, it means that the system is not powered off and restarted, and the configuration information in RAM is the latest configuration information written. Therefore, the valid configuration information in RAM can be used to perform subsequent system startup operations to ensure the normal operation of system functions. If the configuration information in RAM is valid, it can be detected whether the configuration information in Flash is consistent with the configuration information in RAM. If they are consistent, it means that the latest configuration information written in RAM has been successfully synchronized to Flash. At this time, no operation is required.
[0100] Step S40: If they are inconsistent, the configuration information in the RAM is synchronized to the Flash.
[0101] If the configuration information in the Flash is inconsistent with the configuration information in the RAM, it means that before the restart, the latest configuration information written in the RAM has not been synchronized to the Flash or the configuration information synchronized to the Flash is incorrect. In this case, the configuration information in the RAM can be synchronized to the Flash so that the next time the system is restarted after power failure, the valid configuration information can be obtained from the Flash to perform subsequent system startup operations, thereby avoiding the system startup abnormality caused by the abnormal restart configuration information not being synchronized to the Flash or the configuration information synchronized to the Flash being incorrect when writing the configuration information.
[0102] In this embodiment, by configuring the RAM attribute so that the data is not updated when the power is turned off and restarted, when a configuration information write request is received, the configuration information to be written corresponding to the configuration information write request is written into the RAM, and then the configuration information in the RAM is synchronized to the Flash. When the system starts, the configuration information is first obtained from the RAM to detect whether the configuration information is valid. If it is valid, the configuration information in the RAM is used to perform subsequent system startup operations, and when the configuration information in the Flash is inconsistent with the configuration information in the RAM, the configuration information in the RAM is synchronized to the Flash. It is achieved that when an abnormal restart occurs when writing the configuration information, resulting in the configuration information not being synchronized to the Flash or the configuration information synchronized to the Flash being wrong, valid configuration information can also be obtained from the RAM to perform subsequent system startup operations, and by synchronizing the valid configuration information in the RAM to the Flash, when the system is restarted after a subsequent power outage, valid configuration information can also be obtained from the Flash to perform subsequent system startup operations, thereby ensuring the normal operation of the system functions.
[0103] Further, in one embodiment, the step of synchronizing the configuration information in the RAM to the Flash in step S10 and / or step S40 includes:
[0104] Step a, synchronizing the configuration information in the RAM to the main partition of the Flash, and then detecting whether the configuration information in the main partition of the Flash is valid;
[0105] Flash can be divided into a main partition and a backup area, and the configuration information in RAM can be synchronized to the main partition and the backup area of Flash, so that when the configuration information of the main partition is lost or an error occurs, the configuration information in the backup area can be used for recovery, thereby improving the storage reliability of the configuration information. Specifically, after the configuration information to be written is written into RAM, the configuration information in RAM can be synchronized to the main partition of Flash, and then the configuration information in the main partition of Flash can be obtained to detect whether it is valid, so as to determine whether the synchronization is successful. The method for detecting the validity of the configuration information in the main partition of Flash can refer to the method for detecting the validity of the configuration information in RAM in the above embodiment, which will not be repeated here.
[0106] Step b, if the configuration information in the primary partition of the Flash is valid, synchronizing the configuration information in the RAM to the backup area of the Flash;
[0107] If the configuration information in the main partition of Flash is valid, it means that the synchronization is successful, and the configuration information in RAM can be synchronized to the backup area of Flash. Furthermore, after synchronization to the backup area of Flash, it is also possible to detect whether the configuration information in the backup area of Flash is valid. If it is invalid, a retry is performed, that is, the configuration information in RAM is synchronized to the backup area of Flash again. If the synchronization is successful, no retries are performed, or if the number of retries reaches a preset upper limit, no retries are performed, and an error can be reported. Among them, the method for detecting the validity of the configuration information in the backup area of Flash can refer to the method for detecting the validity of the configuration information in RAM in the above embodiment, and will not be repeated here.
[0108] Step c: if the configuration information in the main partition of the Flash is invalid, retry to synchronize the configuration information in the RAM to the main partition of the Flash.
[0109] If the configuration information in the main partition of the Flash is invalid, it means that the synchronization has failed. At this time, a retry can be performed, that is, the configuration information in the RAM is synchronized to the main partition of the Flash again. Further, after the synchronization is successful, no retries can be performed, or no retries can be performed when the number of retries reaches a preset upper limit, and an error can be reported.
[0110] In this embodiment, after writing the configuration information to be written into RAM, the configuration information in RAM is synchronized to Flash, and the configuration information in Flash is detected to see whether it is valid. If it is invalid, a retry is performed, thereby improving the reliability of the configuration information in Flash and avoiding the occurrence of system startup abnormalities due to invalid configuration information written into Flash.
[0111] Further, based on the above first embodiment, a second embodiment of the configuration information access method of the present invention is proposed. In this embodiment, when a configuration information write request is received in step S10, the step of writing the configuration information to be written corresponding to the configuration information write request into the RAM includes:
[0112] Step S101, when receiving a configuration information write request, detecting whether the configuration information in the RAM is valid;
[0113] Step S102, if the configuration information in the RAM is valid, then writing the configuration information to be written corresponding to the configuration information writing request into the RAM;
[0114] In this embodiment, the configuration information to be written may include only some configuration information items, or may include all configuration information items, depending on the writing scenario and user needs. For example, when the configuration information is written for the first time or all the configuration information needs to be updated, the configuration information to be written includes all items. When only part of the configuration information needs to be updated, the configuration information to be written may include only the items that need to be updated.
[0115] When a configuration information write request is received, the configuration information in the RAM can be checked first to see if it is valid. If the configuration information in the RAM is valid, it means that all configuration information items are included in the RAM and are valid. At this time, the configuration information to be written can be directly written into the RAM. If the configuration information to be written only includes some items, the configuration information to be written can be used to update the corresponding configuration information items in the RAM.
[0116] Step S103, if the configuration information in the RAM is invalid, read and detect whether the configuration information in the Flash is valid;
[0117] Step S104: if the configuration information in the Flash is valid, after synchronizing the configuration information in the Flash to the RAM, write the configuration information to be written corresponding to the configuration information write request into the RAM.
[0118] If the configuration information in RAM is invalid, it means that the configuration information in RAM is wrong, or it is overwritten by other data after power failure and restart. At this time, the configuration information in Flash can be read and detected whether it is valid. If the configuration information in Flash is valid, the configuration information in Flash can be synchronized to RAM first, and then the configuration information to be written can be written to RAM. It should be noted that if the configuration information to be written includes only some items, the configuration information in RAM is still invalid after the invalid configuration information in RAM is updated with some items. Synchronizing the configuration information in RAM to Flash will cause the configuration information in Flash to be invalid. Therefore, in this embodiment, when the configuration information in RAM is detected to be invalid, the valid configuration information in Flash is synchronized to RAM first, so as to ensure that the configuration information to be written is written when the configuration information in RAM is valid, thereby ensuring that the configuration information synchronized to Flash is valid, and then ensuring that the system can start normally.
[0119] It should be noted that when the configuration information to be written includes some configuration information items, after the configuration information to be written is used to update the corresponding configuration information items in the RAM, the CRC check value of the configuration information in the RAM can be recalculated and updated. After the configuration information in the RAM is synchronized to the Flash, the validity of the configuration information in the Flash is detected based on the updated information.
[0120] Further, in one embodiment, step S103 includes:
[0121] Step S1031, if the configuration information in the RAM is invalid, read and detect whether the configuration information in the main partition of the Flash is valid;
[0122] The Flash may be divided into a primary partition and a backup area. When a configuration information write request is received, if it is detected that the configuration information in the RAM is invalid, the configuration information in the primary partition of the Flash may be read and detected first to determine whether it is valid.
[0123] The step S104 includes:
[0124] Step S1041, if the configuration information in the main partition of the Flash is valid, after synchronizing the configuration information in the main partition of the Flash to the RAM, the configuration information to be written corresponding to the configuration information write request is written into the RAM;
[0125] If the configuration information in the main partition of the Flash is valid, the configuration information in the main partition of the Flash can be synchronized to the RAM first, and then the configuration information to be written can be written to the RAM to ensure that the configuration information to be written is written when the configuration information in the RAM is valid, thereby ensuring that the configuration information synchronized to the Flash is valid, and then ensuring that the system can start normally.
[0126] Step S1042, if the configuration information in the primary partition of the Flash is invalid, then read and detect whether the configuration information in the backup area of the Flash is valid;
[0127] Step S1043: if the configuration information in the backup area of the Flash is valid, after synchronizing the configuration information in the backup area of the Flash to the RAM and the main partition of the Flash, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0128] If the configuration information in the main partition of Flash is invalid, you can read and check whether the configuration information in the backup area of Flash is valid. If the configuration information in the backup area of Flash is valid, the configuration information in the backup area of Flash is first synchronized to RAM and the main partition of Flash, and then the configuration information to be written is written to RAM to ensure that the configuration information to be written is written when the configuration information in RAM is valid, thereby ensuring that the configuration information synchronized to Flash is valid, and then ensuring that the system can start normally.
[0129] Furthermore, in one embodiment, after step S103, the following steps are further included:
[0130] Step S105: if the configuration information in the Flash is invalid, the configuration information in the RAM and the Flash is reset to a preset default value, and then the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0131] If the configuration information in RAM is invalid and it is detected that the configuration information in Flash is also invalid, the configuration information in RAM and Flash can be reset to the preset default values. The preset default values are a set of valid configuration information pre-set in the code. Although the configuration information is not necessarily the latest, it can be guaranteed to be valid so that the system can start normally. After resetting the configuration information in RAM and Flash to the preset default values, the configuration information to be written is written to RAM, thereby avoiding the situation where the configuration information synchronized to Flash is also invalid due to the invalid configuration information in RAM when only part of the configuration information items are written. That is, it ensures that the system can start normally.
[0132] It should be noted that, when the Flash is divided into a primary partition and a backup area, the configuration information in the Flash being invalid may mean that the configuration information in both the primary partition and the backup area are invalid.
[0133] In one embodiment, when a configuration information write request is received, the following steps may be followed: Figure 3 The process steps shown write the configuration information to RAM and synchronize it to Flash.
[0134] Further, based on the first and / or second embodiments above, a third embodiment of the configuration information access method of the present invention is proposed. In this embodiment, after step S20, the method further includes:
[0135] Step S50, if the configuration information in the RAM is invalid, read and detect whether the configuration information in the Flash is valid;
[0136] When the system starts, if it is detected that the configuration information in the RAM is invalid, it means that the system may be started after a power failure, or the configuration information in the RAM is wrong. At this time, the configuration information in the Flash can be read and detected to see if it is valid.
[0137] Step S60: If the configuration information in the Flash is valid, the system startup operation is performed according to the configuration information in the Flash, and the configuration information in the Flash is synchronized to the RAM.
[0138] If the configuration information in Flash is valid, the subsequent system startup operations can be performed according to the configuration information in Flash, ensuring that the system can start and run normally. If the configuration information in Flash is valid, the configuration information in Flash can be synchronized to RAM, so that if the system does not power off and restart due to an abnormality during operation, the configuration information can be directly obtained from RAM to perform subsequent system startup operations, thereby improving the system startup speed.
[0139] Further, in one embodiment, the step S50 includes:
[0140] Step S501, if the configuration information in the RAM is invalid, then read and detect whether the configuration information in the main partition of the Flash is valid;
[0141] The Flash can be divided into a primary partition and a backup area. When the system starts, if it is detected that the configuration information in the RAM is invalid, the configuration information in the primary partition of the Flash can be read and detected first to see if it is valid.
[0142] The step S60 comprises:
[0143] Step S601, if the configuration information in the main partition of the Flash is valid, the system startup operation is performed according to the configuration information in the main partition of the Flash, and the configuration information in the main partition of the Flash is synchronized to the RAM;
[0144] If the configuration information in the main partition of Flash is valid, the system startup operation is performed according to the configuration information in the main partition of Flash to ensure that the system can start and run normally. If the configuration information in the main partition of Flash is valid, the configuration information in the main partition of Flash can also be synchronized to RAM, so that if the system is running due to an abnormality and does not power off and restart, the configuration information can be directly obtained from RAM to perform subsequent system startup operations, thereby improving the system startup speed.
[0145] Step S602: if the configuration information in the primary partition of the Flash is invalid, then read and detect whether the configuration information in the backup area of the Flash is valid;
[0146] Step S603: If the configuration information in the backup area of the Flash is valid, the system startup operation is performed according to the configuration information in the backup area of the Flash, and the configuration information in the backup area of the Flash is synchronized to the main partitions of the RAM and the Flash.
[0147] If the configuration information in the main partition of Flash is invalid, the configuration information in the backup area of Flash can be read and checked to see if it is valid. If the configuration information in the backup area of Flash is valid, the system startup operation can be performed according to the configuration information in the backup area of Flash to ensure that the system can start and run normally. If the configuration information in the backup area of Flash is valid, the configuration information in the backup area of Flash can also be synchronized to RAM, so that if the system does not power off and restart due to an abnormality during operation, the configuration information can be directly obtained from RAM to quickly perform subsequent system startup operations, thereby improving the system startup speed. If the configuration information in the backup area of Flash is valid, the configuration information in the backup area of Flash can also be synchronized to the main partition of Flash, so that the next time the power is off and restarted, the valid configuration information can be directly obtained from the main partition of Flash to perform subsequent system startup operations.
[0148] Furthermore, in one embodiment, after step S50, the following steps are further included:
[0149] Step S60: If the configuration information in the Flash is invalid, the system startup operation is performed according to the preset default values, and the preset default values are written into the RAM and the Flash as the configuration information.
[0150] If the configuration information in RAM is invalid, and it is detected that the configuration information in Flash is also invalid, the system startup operation can be performed according to the preset default values. Among them, the preset default values are a set of valid configuration information pre-set in the code. Although the configuration information is not necessarily the latest, it can be guaranteed to be valid so that the system can start normally. In the case that the configuration information in RAM and Flash are both invalid, the preset default values can also be written into RAM as configuration information, so that if the system operation process does not power off and restart due to an abnormality, the configuration information can be quickly obtained directly from RAM to perform subsequent system startup operations, thereby improving the system startup speed. In the case that the configuration information in RAM and Flash are both invalid, the preset default values can also be written into Flash as configuration information, so that when the power is off and restarted next time, the valid configuration information can be directly obtained from Flash to perform subsequent system startup operations, thereby ensuring that the system starts normally.
[0151] It should be noted that, when the Flash is divided into a primary partition and a backup area, the configuration information in the Flash being invalid may mean that the configuration information in both the primary partition and the backup area are invalid.
[0152] In one embodiment, when it is necessary to synchronize configuration information from one of the storage areas of the main partition and the backup area of the RAM and Flash to another storage area, it can be detected whether the synchronization is successful after synchronization, that is, whether the synchronized configuration information is valid. If invalid, retries are performed until the synchronization is successful and the retries are stopped, or an error is reported when the number of retries reaches the upper limit.
[0153] In one embodiment, when the system starts, the following Figure 4 The process steps shown obtain configuration information for subsequent system startup operations.
[0154] In addition, an embodiment of the present invention further provides a configuration information access device, the device comprising:
[0155] A writing module, which is used to write the configuration information to be written corresponding to the configuration information writing request into the RAM when receiving the configuration information writing request, and then synchronize the configuration information in the RAM to the Flash, wherein the attribute of the RAM is configured so that the data is not updated when the power is off and restarted;
[0156] The first detection module is used to detect whether the configuration information in the RAM is valid when the system starts;
[0157] A second detection module is used to execute a system startup operation according to the configuration information in the RAM if the configuration information in the RAM is valid, and detect whether the configuration information in the Flash is consistent with the configuration information in the RAM;
[0158] The synchronization module is used to synchronize the configuration information in the RAM to the Flash if there is any inconsistency.
[0159] Furthermore, the writing module is also used for:
[0160] Synchronize the configuration information in RAM to the main partition of Flash, and then check whether the configuration information in the main partition of Flash is valid;
[0161] If the configuration information in the primary partition of the Flash is valid, the configuration information in the RAM is synchronized to the backup area of the Flash;
[0162] If the configuration information in the primary partition of the Flash is invalid, retry to synchronize the configuration information in the RAM to the primary partition of the Flash.
[0163] Furthermore, the writing module is also used for:
[0164] When receiving a configuration information write request, checking whether the configuration information in the RAM is valid;
[0165] If the configuration information in the RAM is valid, the configuration information to be written corresponding to the configuration information writing request is written into the RAM;
[0166] If the configuration information in RAM is invalid, read and check whether the configuration information in Flash is valid;
[0167] If the configuration information in the Flash is valid, after synchronizing the configuration information in the Flash to the RAM, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0168] Furthermore, the writing module is also used for:
[0169] If the configuration information in RAM is invalid, read and check whether the configuration information in the main partition of Flash is valid;
[0170] If the configuration information in the main partition of the Flash is valid, after synchronizing the configuration information in the main partition of the Flash to the RAM, the configuration information to be written corresponding to the configuration information write request is written into the RAM;
[0171] If the configuration information in the primary partition of the Flash is invalid, read and check whether the configuration information in the backup area of the Flash is valid;
[0172] If the configuration information in the backup area of the Flash is valid, after synchronizing the configuration information in the backup area of the Flash to the RAM and the main partition of the Flash, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
[0173] Furthermore, the device also includes:
[0174] The reset module is used to reset the configuration information in the RAM and the Flash to preset default values if the configuration information in the Flash is invalid, and then write the configuration information to be written corresponding to the configuration information write request into the RAM.
[0175] Furthermore, the device also includes:
[0176] A third detection module is used to read and detect whether the configuration information in the Flash is valid if the configuration information in the RAM is invalid;
[0177] The synchronization module is also used to execute a system startup operation according to the configuration information in the Flash if the configuration information in the Flash is valid, and synchronize the configuration information in the Flash to the RAM.
[0178] Furthermore, the third detection module is also used for:
[0179] If the configuration information in RAM is invalid, read and check whether the configuration information in the main partition of Flash is valid;
[0180] The synchronization module is also used for:
[0181] If the configuration information in the main partition of the Flash is valid, the system startup operation is performed according to the configuration information in the main partition of the Flash, and the configuration information in the main partition of the Flash is synchronized to the RAM;
[0182] If the configuration information in the primary partition of the Flash is invalid, read and check whether the configuration information in the backup area of the Flash is valid;
[0183] If the configuration information in the backup area of the Flash is valid, the system startup operation is performed according to the configuration information in the backup area of the Flash, and the configuration information in the backup area of the Flash is synchronized to the main partitions of the RAM and the Flash.
[0184] Furthermore, the device also includes:
[0185] The writing module is also used for executing the system startup operation according to the preset default values if the configuration information in the Flash is invalid, and writing the preset default values into the RAM and the Flash as the configuration information.
[0186] The extended contents of the specific implementation manner of the configuration information access device of the present invention are basically the same as the above-mentioned configuration information access method embodiments, and will not be elaborated here.
[0187] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a configuration information access program is stored. When the configuration information access program is executed by a processor, the steps of the configuration information access method described below are implemented.
[0188] The various embodiments of the configuration information access device and the computer-readable storage medium of the present invention may all refer to the various embodiments of the configuration information access method of the present invention, and will not be described in detail here.
[0189] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0190] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0191] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0192] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A configuration information access method, characterized in that: The configuration information access method is applied to a Bluetooth headset, and the method comprises the following steps: When receiving a configuration information write request, checking whether the configuration information in the RAM is valid; If the configuration information in the RAM is valid, the configuration information to be written corresponding to the configuration information writing request is written into the RAM; If the configuration information in RAM is invalid, read and check whether the configuration information in Flash is valid; If the configuration information in the Flash is valid, after synchronizing the configuration information in the Flash to the RAM, the configuration information to be written corresponding to the configuration information write request is written into the RAM; Synchronize the configuration information in the RAM to the Flash, wherein the attribute of the RAM is configured so that the data is not updated when the power is not turned off and restarted, wherein the configuration information includes the hardware version number and the calibration value; When the system starts, check whether the configuration information in RAM is valid; If the configuration information in the RAM is invalid, read and check whether the configuration information in the main partition of the Flash is valid; If the configuration information in the main partition of the Flash is valid, the system startup operation is performed according to the configuration information in the main partition of the Flash, and the configuration information in the main partition of the Flash is synchronized to the RAM; If the configuration information in the primary partition of the Flash is invalid, read and check whether the configuration information in the backup area of the Flash is valid; If the configuration information in the backup area of the Flash is valid, the system startup operation is performed according to the configuration information in the backup area of the Flash, and the configuration information in the backup area of the Flash is synchronized to the main partitions of the RAM and the Flash; If the configuration information in the RAM is valid, the system startup operation is performed according to the configuration information in the RAM, and the configuration information in the Flash is detected to be consistent with the configuration information in the RAM; If they are inconsistent, the configuration information in RAM is synchronized to Flash; The steps to synchronize the configuration information in RAM to Flash include: Synchronize the configuration information in RAM to the main partition of Flash, and then check whether the configuration information in the main partition of Flash is valid; If the configuration information in the primary partition of the Flash is valid, the configuration information in the RAM is synchronized to the backup area of the Flash; If the configuration information in the primary partition of Flash is invalid, retry to synchronize the configuration information in RAM to the primary partition of Flash; After the step of synchronizing the configuration information in the RAM to the Flash, the method further includes: Check whether the configuration information in the Flash is valid. If not, retry to synchronize the configuration information in the RAM to the Flash again until the configuration information in the Flash is valid or the number of retries reaches a preset upper limit.
2. The configuration information access method according to claim 1, wherein: If the configuration information in the RAM is invalid, the step of reading and detecting whether the configuration information in the Flash is valid includes: If the configuration information in the RAM is invalid, read and check whether the configuration information in the main partition of the Flash is valid; If the configuration information in the Flash is valid, the step of synchronizing the configuration information in the Flash to the RAM and then writing the configuration information to be written corresponding to the configuration information write request into the RAM includes: If the configuration information in the main partition of the Flash is valid, after synchronizing the configuration information in the main partition of the Flash to the RAM, the configuration information to be written corresponding to the configuration information write request is written into the RAM; If the configuration information in the primary partition of the Flash is invalid, read and check whether the configuration information in the backup area of the Flash is valid; If the configuration information in the backup area of the Flash is valid, after synchronizing the configuration information in the backup area of the Flash to the RAM and the main partition of the Flash, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
3. The configuration information access method according to claim 1, wherein: After the step of reading and detecting whether the configuration information in the Flash is valid if the configuration information in the RAM is invalid, the following steps are also included: If the configuration information in the Flash is invalid, after resetting the configuration information in the RAM and the Flash to preset default values, the configuration information to be written corresponding to the configuration information write request is written into the RAM.
4. The configuration information access method according to claim 3, characterized in that: After the step of reading and detecting whether the configuration information in the backup area of the Flash is valid if the configuration information in the main partition of the Flash is invalid, the method further includes: If the configuration information in the backup area of the Flash is invalid, the system startup operation is performed according to the preset default values, and the preset default values are written into the RAM and the Flash as the configuration information.
5. A configuration information access device, characterized in that: The configuration information access device comprises: a memory, a processor, and a configuration information access program stored in the memory and executable on the processor, wherein the configuration information access program implements the steps of the configuration information access method as claimed in any one of claims 1 to 4 when executed by the processor.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a configuration information access program, and when the configuration information access program is executed by a processor, the steps of the configuration information access method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Remote software upgrading method for in-situ relay protection device
CN104503782A
System with reset function and restart control method thereof
CN105045146A
Method and device for upgrading firmware
CN105094903A
Openwrt-based firmware upgrading method and router
CN107566169A
Communication equipment starting configuration data backup synchronization method
CN111124763A