Data processing methods, apparatus, electronic devices and storage media
By partitioning and storing data in an orderly manner in the integrated circuit system, the problem of data loss caused by power outages due to unstable power supply is solved, the accuracy and rationality of data storage are achieved, and the data storage capacity of the microcontroller and the stability of device functions are improved.
Patent Information
- Application Number
- CN202410161192.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-04
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-02-04
AI Technical Summary
In integrated circuit systems, unstable power supply and frequent power outages can lead to data loss in the microcontroller, affecting device functionality.
By responding to data write commands, the system obtains the target data to be written, its corresponding historical storage area number, and data sequence number. It then determines the target data sequence number and verification parameters and writes them to the target storage area, thereby achieving partitioned and ordered storage and preventing data loss.
Ensure the accuracy and rationality of data storage, avoid chaotic data storage partitioning, reduce microcontroller data loss, improve data storage capacity, reduce development costs, and improve storage space utilization efficiency and read/write lifespan.
Smart Images

Figure CN118034591B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a data processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] With the development of integrated circuits, many devices utilize integrated circuit systems to implement various functions. These systems typically include storage space for data storage; for example, single-chip microcontrollers, chips, and system-on-a-chip (SoCs) all have dedicated storage space or external storage for data storage. In related technologies, the corresponding storage space in an integrated circuit system controls data writing and reading via an external power supply. However, operation under unstable power conditions with frequent power outages can lead to data loss in the microcontroller, affecting device functionality. Summary of the Invention
[0003] This application provides a data processing method, apparatus, electronic device, and storage medium, aiming to solve the problem in the prior art where data loss in a microcontroller affects the function of the device.
[0004] In a first aspect, this application provides a data processing method, characterized in that it includes:
[0005] In response to a data write command, the system obtains the target write data to be written, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data. The target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data.
[0006] The target data sequence number of the target written data is determined based on the historical data sequence number, and the target verification parameters are determined based on the target data sequence number and the target written data.
[0007] The target storage area number of the target data to be written is determined based on the historical storage area number, and the target data to be written, the target data sequence number, and the target verification parameter are written to the target storage area corresponding to the target storage area number.
[0008] In one possible implementation of this application, before determining the target storage area number of the target written data based on the historical storage area number, the method further includes:
[0009] If each of the preset storage area numbers in the preset storage area number sequence contains historical write data, then erase the historical write data in each storage area except for the storage area corresponding to the historical storage area number. The historical storage area number is any one of the preset storage area number sequences, which are arranged in ascending order.
[0010] Determining the target storage area number of the target data to be written based on the historical storage area number includes:
[0011] If the historical storage area number is equal to the last preset storage area number in the preset storage area number sequence, then the first preset storage area number in the preset storage area number sequence is set as the target storage area number of the target data to be written.
[0012] If the historical storage area number is less than the last preset storage area number in the preset storage area number sequence, then the preset storage area number that is one position after the historical storage area number in the preset storage area number sequence is set as the target storage area number of the target data to be written.
[0013] In one possible implementation of this application, determining the target data sequence number of the target written data based on the historical data sequence number includes:
[0014] If the historical data sequence number is equal to the preset sequence number, then the initial data sequence number is set as the target data sequence number of the target data to be written.
[0015] If the historical data sequence number is less than the preset sequence number, the historical data sequence number is superimposed with the sequence number interval parameter to obtain the target data sequence number of the target data to be written.
[0016] After writing the target data, the target data sequence number, and the target verification parameters into the target storage area corresponding to the target storage area number, the method further includes:
[0017] If the target data sequence number is the same as the initial data sequence number, then erase the historical write data stored in other storage areas outside the target storage area.
[0018] In one possible implementation of this application, after determining the target storage area number of the target write data based on the historical storage area number, and writing the target write data, the target data sequence number, and the target verification parameter into the target storage area corresponding to the target storage area number, the method further includes:
[0019] In response to the power-on initialization command, read the write information of the storage area corresponding to each storage area number, wherein the write information includes the write data, as well as the data sequence number and target verification parameter corresponding to the write data;
[0020] Calculate the actual verification parameters of each written information based on the written data and the data sequence number in each written information;
[0021] The target write information is determined based on the similarity between the actual verification parameters and the target verification parameters, as well as the size relationship between the data sequence numbers in each of the write information.
[0022] Based on the target information, perform a power-on initialization operation.
[0023] In one possible implementation of this application, determining the target write information based on the similarity between the actual verification parameters and the target verification parameters, and the size relationship between the data sequence numbers in each of the write information, includes:
[0024] By comparing the size relationship between the data sequence numbers in each of the written information, the first written information corresponding to the largest data sequence number is determined;
[0025] If the actual verification parameter corresponding to the first written information is the same as the target verification parameter included in the first written information, then the first written information is set as the target written information.
[0026] If the actual verification parameter corresponding to the first write information is different from the target verification parameter included in the first write information, then the preset write information is set as the target write information.
[0027] In one possible implementation of this application, the step of calculating the actual verification parameter of each write information based on the write data and the data sequence number in each write information includes:
[0028] Extract the written data and the data sequence number from the written information;
[0029] Calculate the checksum based on the written data and the data sequence number;
[0030] Set the checksum as the actual verification parameter corresponding to the written information.
[0031] Secondly, this application provides a data processing method, including:
[0032] In response to the power-on initialization command, the write information of the storage area corresponding to each storage area number in the preset storage area number sequence is read. The write information includes the write data, as well as the data sequence number and target verification parameter corresponding to the write data.
[0033] Calculate the actual verification parameters of each written information based on the written data and the data sequence number in each written information;
[0034] The target write information is determined based on the similarity between the actual verification parameters and the target verification parameters, as well as the size relationship between the data sequence numbers in each of the write information.
[0035] Based on the target information, perform a power-on initialization operation.
[0036] Thirdly, this application provides a data processing apparatus, the data processing apparatus comprising:
[0037] The response acquisition module is used to respond to the data write command, acquire the target write data to be written, and the historical storage area number and historical data sequence number corresponding to the target historical write data. The target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data.
[0038] The determination module is used to determine the target data sequence number of the target written data based on the historical data sequence number, and to determine the target verification parameters based on the target data sequence number and the target written data;
[0039] The writing module is used to determine the target storage area number of the target write data according to the historical storage area number, and write the target write data, the target data sequence number and the target verification parameter into the target storage area corresponding to the target storage area number.
[0040] Fourthly, this application provides an electronic device, the electronic device comprising:
[0041] one or more processors;
[0042] Memory; and
[0043] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement any of the data processing methods described herein.
[0044] Fifthly, this application provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to perform the steps of any of the data processing methods described herein.
[0045] This application provides a data processing method, apparatus, electronic device, and storage medium. By responding to a data write command, it acquires the target write data to be written, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data. The target historical write data is the historical write data whose data acquisition time is the shortest interval between the acquisition time and the acquisition time of the target write data. Based on the historical data sequence number, it determines the target data sequence number of the target write data, and determines target verification parameters based on the target data sequence number and the target write data. Based on the historical storage area number, it determines the target storage area number of the target write data, and writes the target write data, the target data sequence number, and the target verification parameters into the target storage area corresponding to the target storage area number. This solution obtains the target data to be written when a write command is detected, and determines the write location (i.e., target storage area number) and target data sequence number of the target data by combining the historical storage area number and historical data sequence number corresponding to the historical data with the shortest interval between the acquisition time of the target data. This achieves partitioned and ordered storage of the target data, ensuring the accuracy and rationality of data storage, avoiding data storage partition chaos, and preventing microcontroller data loss and affecting device functionality when the power supply is unstable and frequently loses power, thus improving the microcontroller's data storage capacity. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0047] Figure 1 This is a schematic diagram of a scenario of a data processing method provided in an embodiment of the present application;
[0048] Figure 2 This is a schematic flowchart of an embodiment of the data processing method provided in this application;
[0049] Figure 3 A schematic flowchart of another embodiment of the data processing method provided in this application;
[0050] Figure 4 A schematic flowchart of another embodiment of the data processing method provided in this application;
[0051] Figure 5 A schematic diagram of another implementation scheme of the data processing method provided for the implementation scheme of this application;
[0052] Figure 6 A schematic diagram of one implementation scheme for data reading in the data processing method provided in this application;
[0053] Figure 7 A flowchart illustrating one implementation scheme of the data processing method provided for the implementation scheme of this application;
[0054] Figure 8 A schematic diagram of another implementation scheme of the data processing method provided in this application;
[0055] Figure 9 This is a schematic diagram of an embodiment of the data processing apparatus provided in this application;
[0056] Figure 10 This is a schematic diagram of an embodiment of the electronic device provided in this application. Detailed Implementation
[0057] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0058] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of the stated features. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0059] In this embodiment, "and / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Additionally, the character " / ", unless otherwise specified, generally indicates that the preceding and following associated objects have an "or" relationship.
[0060] In this application, the term "exemplary" is used to mean "serving as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0061] The purpose of a microcontroller's power-down data retention is to preserve some settings or state data when the device loses power, so that it can continue to operate normally or in the state set before the power failure upon power restoration. This is convenient for users in situations with unstable power supply and frequent power outages, without needing to readjust device parameters or set states. However, in actual data retention, power failure and data retention processes may occur simultaneously. Simply performing the data retention action may result in data loss, which could affect device operation. Moreover, for high-precision timed execution devices, frequent write and erase operations can also affect the normal functioning of the device. This patent provides a method to increase the reliability of retained data and reduce data write and erase operations.
[0062] Specifically, embodiments of this application provide a data processing method, apparatus, device, and computer-readable storage medium, which will be described in detail below.
[0063] The data processing method in this embodiment of the invention is applied to a data processing device, which is provided in a data processing equipment. The data processing equipment includes one or more processors, a memory, and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the data processing method. The data processing equipment can be a terminal, such as a mobile phone or a tablet computer, or it can be a server or a service cluster composed of multiple servers.
[0064] like Figure 1 As shown, Figure 1 This is a schematic diagram of a data processing method according to an embodiment of the present application. The data processing scenario in this embodiment includes a data processing device 100 (the data processing device 100 integrates a data processing unit), and the data processing device 100 runs a computer-readable storage medium corresponding to the data processing to perform the data processing steps.
[0065] It is understandable that Figure 1 The data processing device in the scenario of the data processing method shown, or the device included in the data processing device, does not constitute a limitation on the embodiments of the present invention. That is, the number or type of device included in the scenario of the data processing method, or the number or type of device included in each device, does not affect the overall implementation of the technical solution in the embodiments of the present invention, and can all be considered as equivalent substitutions or derivatives of the technical solutions claimed in the embodiments of the present invention.
[0066] In this embodiment of the invention, the data processing device 100 is mainly used for: responding to a data write command, acquiring the target write data to be written, and the historical storage area number and historical data sequence number corresponding to the target historical write data, wherein the target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data; determining the target data sequence number of the target write data according to the historical data sequence number, and determining the target verification parameter according to the target data sequence number and the target write data; determining the target storage area number of the target write data according to the historical storage area number, and writing the target write data, the target data sequence number, and the target verification parameter into the target storage area corresponding to the target storage area number.
[0067] In this embodiment of the invention, the data processing device 100 can be an independent data processing device, or a network or cluster of data processing devices. For example, the data processing device 100 described in this embodiment includes, but is not limited to, computers, network hosts, single network data processing devices, sets of multiple network data processing devices, or cloud data processing devices composed of multiple data processing devices. The cloud data processing device consists of a large number of computers or network data processing devices based on cloud computing.
[0068] Those skilled in the art will understand that Figure 1 The application environment shown is merely one application scenario of the solution in this application and does not constitute a limitation on the application scenario of the solution in this application. Other application environments may include those that are more specific to this application. Figure 1 The more or fewer data processing devices shown, or the network connectivity of the data processing devices, for example Figure 1 Only one data processing device is shown in the diagram. It is understood that the scenario of this data processing method may also include one or more other data processing devices, which are not specifically limited here. The data processing device 100 may also include a memory for storing data.
[0069] Furthermore, in the data processing method scenario of this application, the data processing device 100 may be equipped with a display device, or the data processing device 100 may not have a display device but may be connected to an external display device 200 for communication. The display device 200 is used to output the results of the data processing method executed in the data processing device. The data processing device 100 can access a background database 300 (the background database may be located in the local storage of the data processing device or it may be located in the cloud), and the background database 300 stores information related to data processing.
[0070] It should be noted that Figure 1 The schematic diagram of the data processing method shown is merely an example. The scenarios of the data processing method described in the embodiments of the present invention are intended to more clearly illustrate the technical solutions of the embodiments of the present invention and do not constitute a limitation on the technical solutions provided in the embodiments of the present invention.
[0071] Based on the scenarios described above, embodiments of the data processing methods are proposed.
[0072] like Figure 2 The diagram shown is a flowchart of an embodiment of the data processing method in this application. The data processing method includes steps S201-S203:
[0073] S201. Respond to the data write command, obtain the target write data to be written, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data, wherein the target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data.
[0074] The target data to be written can be the setting data or status data of the electronic device to which the data processing method is applied. For example, in some embodiments of this application, the data processing method is applied to a data processing device, which is located in an electronic device, such as an air conditioner. The target data can be information such as the user-set temperature and the user-set timer start time of the air conditioner, or temperature information collected by sensors during the operation of the air conditioner. This application does not make any specific limitations.
[0075] The target historical data written here, that is, the historical data written, can be understood to be setting data or status data, which will not be elaborated further.
[0076] In this embodiment, the storage unit is partitioned, that is, the storage unit is divided into different areas, and each storage area is associated with a corresponding storage area number for storage area identification. Furthermore, after each data storage, each written data is associated with a data sequence number for data identification, so as to facilitate subsequent data retrieval. The historical storage area number is the storage area number of the storage area where the historical data was written, obtained in response to the historical data write instruction. The historical data sequence number is the data sequence number corresponding to the historical data. That is, it can be understood that the historical data with the shortest interval between the acquisition time of the target data is the data corresponding to the last write, that is, the data corresponding to the last write, is used as the target historical data.
[0077] For example, in one embodiment of this application, the air conditioner detects the user's input of a set temperature via a remote control, that is, generates a data write instruction carrying the set temperature, and further sends the data write instruction to the air conditioner. The air conditioner responds to the data write instruction, determines the target storage unit corresponding to the set temperature, and further obtains the target historical data corresponding to the last write in the target storage unit, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data.
[0078] It is understood that an electronic device may store multiple types of data. For example, it may store setting parameters, configuration parameters, or status parameters of the electronic device. In other embodiments of this application, the electronic device may store different storage units for storing different types of data. For example, setting parameters, configuration parameters, or status parameters may be stored in different storage units, and the different storage units may be further divided into different storage areas. After receiving a data write instruction, the electronic device further determines the target storage unit corresponding to the target data to be written, and further obtains the historical storage area number and historical data sequence number corresponding to the target historical data to be written in the target storage unit.
[0079] It is understood that electronic devices can determine the target storage unit of the target data to be written based on the source of the write instruction or the data type or data format of the target data to be written.
[0080] S202. Determine the target data sequence number of the target written data according to the historical data sequence number, and determine the target verification parameter according to the target data sequence number and the target written data.
[0081] Specifically, in one embodiment of this application, the target data sequence number can be determined according to a preset data sorting rule. For example, a preset sequence number interval can be used, and the sum of the historical data sequence number and the preset sequence number interval can be set as the target data sequence number; or a preset data sequence number can be used, and the data sequence numbers in the preset data sequence number can be used in a cyclical manner according to the storage order of the written data. For example, after determining the historical data sequence number, the data sequence number located after the historical data sequence number in the preset data sequence number can be set as the target data sequence number of the target written data.
[0082] Specifically, after determining the target data sequence number, the electronic device further determines the target verification parameters based on the target data sequence number and the target written data. The calculation method of the target verification parameters is not specifically limited in this application. For example, the target verification parameters can be calculated by odd parity, even parity, etc.
[0083] S203. Determine the target storage area number of the target data to be written based on the historical storage area number, and write the target data to be written, the target data sequence number and the target verification parameter into the target storage area corresponding to the target storage area number.
[0084] Specifically, in one embodiment of this application, the target write data can be written according to a preset write order rule. For example, after obtaining the historical storage area number, the electronic device determines the target storage area number of the target write data based on the historical storage area number and the write order rule. Further, the target write data, the target data sequence number, and the target verification parameters are written into the target storage area corresponding to the target storage area number for storage.
[0085] Furthermore, based on the above implementation plan, see [link to relevant documentation]. Figure 3 , Figure 3 A flowchart illustrating another embodiment of the data processing method provided in this application, the data processing method including steps S301-S306:
[0086] S301. Respond to the data write command, obtain the target write data to be written, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data, wherein the target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data.
[0087] S302. Determine the target data sequence number of the target written data according to the historical data sequence number, and determine the target verification parameter according to the target data sequence number and the target written data.
[0088] The specific implementation methods of steps S301-S302 are described in any of the above implementation schemes.
[0089] S303. If each of the preset storage area numbers in the preset storage area number sequence contains historical write data, then erase the historical write data in each storage area except for the storage area corresponding to the historical storage area number.
[0090] Wherein, the historical storage area number is any one of the preset storage area number sequence, and the preset storage area number sequence is arranged in ascending order;
[0091] In the implementation scheme of this application, after dividing each storage unit into regions, storage area numbers are assigned to each storage area in descending order of size. The corresponding storage area numbers are arranged sequentially to generate a preset storage area number sequence, which facilitates the differentiation of the size relationship of each storage area number.
[0092] Specifically, in the implementation of this application, after obtaining the historical storage area number, the electronic device checks whether all storage areas corresponding to other storage area numbers in the preset storage area number sequence, excluding the historical storage area number, contain historical written data. If all of them do, it means that each storage area in the storage unit contains data. At this time, the data in the storage areas corresponding to other storage area numbers, excluding the historical storage area number, is erased, that is, only the target historical written data is retained.
[0093] S304. If the historical storage area number is equal to the last preset storage area number in the preset storage area number sequence, then the first preset storage area number in the preset storage area number sequence is set as the target storage area number of the target data to be written.
[0094] Specifically, in the implementation of this application, the preset storage area number sequence is arranged in ascending order. That is, if the historical storage area number is equal to the last preset storage area number in the preset storage area number sequence, an erase operation is performed to prevent data from being stored in the first preset storage area number in the storage area number sequence. Furthermore, the first preset storage area number in the preset storage area number sequence is set as the target storage area number for the target data to be written, thereby realizing the cyclical use of each storage area number in the preset storage area number sequence.
[0095] S305. If the historical storage area number is less than the last preset storage area number in the preset storage area number sequence, then the preset storage area number located one position after the historical storage area number in the preset storage area number sequence is set as the target storage area number of the target data to be written.
[0096] S306. Write the target data, the target data sequence number, and the target verification parameters into the target storage area corresponding to the target storage area number.
[0097] Understandably, this solution can avoid data loss during the writing process by retaining the target historical write data from the last write. When a power failure occurs, the target historical write data can be called to run, avoiding electronic device failure. Furthermore, when the data is detected to be full, batch data erasure can be performed, which can reduce the frequency of data erasure and avoid frequent write and erase operations that affect the normal functioning of the device, while also improving the lifespan of the microcontroller.
[0098] Furthermore, based on any of the above implementation schemes, see [link to relevant documentation]. Figure 4 , Figure 4 A flowchart illustrating another embodiment of the data processing method provided in this application, the data processing method including steps S401-S405:
[0099] S401. Respond to the data write command, obtain the target write data to be written, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data, wherein the target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data.
[0100] S402. Determine the target data sequence number of the target written data according to the historical data sequence number, and determine the target verification parameter according to the target data sequence number and the target written data.
[0101] For the specific implementation of steps S401-S402, please refer to any of the implementation schemes.
[0102] S403. If the historical data sequence number is equal to the preset sequence number, then the initial data sequence number is set as the target data sequence number of the target data to be written.
[0103] Specifically, in the implementation of this application, a sequence number range is preset, the smallest sequence number in the sequence number range is set as the initial data sequence number, and the largest sequence number in the sequence number range is set as the preset sequence number. For example, the sequence number range is 0-20, where 0 is the initial data sequence number and 20 is the preset sequence number.
[0104] S404. Write the target data, the target data sequence number, and the target verification parameters into the target storage area corresponding to the target storage area number.
[0105] Understandably, if the historical data sequence number equals the preset sequence number, a data sequence number loop is initiated. Furthermore, the target data, the target data sequence number, and the target verification parameters are written to the target storage area corresponding to the target storage area number.
[0106] S405. Erase the historical write data stored in other storage areas besides the target storage area.
[0107] Furthermore, after writing the target data, the target data sequence number, and the target verification parameters into the target storage area corresponding to the target storage area number, the historical data written in other storage areas besides the target storage area is further erased, that is, only the target data is retained to avoid data sequence number confusion.
[0108] It is understood that in some other embodiments of this application, if the historical data sequence number is less than the preset sequence number, the historical data sequence number is superimposed with the sequence number interval parameter to obtain the target data sequence number of the target written data. For example, the sequence number interval parameter is 1.
[0109] For example, see Figure 5 , Figure 5 A flowchart illustrating another implementation of the data processing method provided in this application.
[0110] Specifically, the steps include:
[0111] The response data write command is executed when the stored data changes (i.e., when the target write data is received). Execution is delayed by 3 seconds, and the preset timer is reset each time the data changes (e.g., 3 seconds). This avoids receiving multiple data response commands in a short period and considers the possibility of accidental operation. The preset waiting time prevents program waste. After the preset time, the following steps are executed from top to bottom:
[0112] a. Let PageX be the current storage location for the latest data (the current storage location for the latest data is the target historical data written).
[0113] b. Check if all Pages (Page: storage area) of the memory partition have been written with data. If so, proceed to step c; otherwise, proceed to step d.
[0114] c. Erase the data of Page X and all other Pages;
[0115] d. Compare whether the memory index (historical data index) in the current memory cache array is 255. If it is, set the memory index to 1; otherwise, increment the memory index by 1.
[0116] c. Compare X and n (the default storage area number of the last digit). If X equals n, then set Y (target storage area number) = 1; otherwise, set Y = X + 1.
[0117] d. Recalculate the checksum using the power-down memory data (target write data) and the memory sequence number (target data sequence number), write the data to Page 1, and execute step f;
[0118] e. Recalculate the checksum using the power-down memory data and memory sequence number, write the data to Page(X+1), and execute step f;
[0119] f. If the memory sequence number is 1, then erase the data in PageX (that is, if the target data sequence number is the initial data sequence number, then erase the historical write data stored in other storage areas outside the target storage area), otherwise proceed to step g;
[0120] g. Writing is complete.
[0121] Furthermore, based on the above implementation scheme, this application also provides an implementation scheme for writing and reading data. For details, please refer to... Figure 6 , Figure 6 This is a flowchart illustrating one implementation scheme of the data reading method provided in this application. After determining the target storage area number of the target data to be written based on the historical storage area number, and writing the target data to be written, the target data sequence number, and the target verification parameter into the target storage area corresponding to the target storage area number, the specific steps include S601-S604:
[0122] S601. In response to the power-on initialization command, read the write information of the storage area corresponding to each storage area number, wherein the write information includes the write data, and the data sequence number and target verification parameter corresponding to the write data.
[0123] Specifically, in the embodiments of this application, after data is written to the storage area in the storage unit, the data in the storage area can be read. For example, when the electronic device is powered off and then powered on again, or simply after power-on, the electronic device will perform data initialization processing, that is, reread each configuration data and / or status data. Furthermore, in response to the power-on initialization command, it will read the write information of the storage area corresponding to each storage area number, as well as the data sequence number and target verification parameters corresponding to the written data. For example, the electronic device can start reading data sequentially from the position of the initial storage area number, or perform data reading and writing simultaneously, without specific limitations.
[0124] S602. Calculate the actual verification parameters of each of the written information based on the written data and the data sequence number in each of the written information.
[0125] Specifically, in one embodiment of this application, the actual verification parameters of each written information are calculated based on the written data and the data sequence number in each written information, specifically including the following steps:
[0126] (1) Extract the write data and the data sequence number from the write information;
[0127] (2) Calculate the checksum based on the written data and the data sequence number;
[0128] (3) Set the checksum as the actual verification parameter corresponding to the written information.
[0129] It is understandable that, during the writing process, the target verification parameters corresponding to the target data to be written can also be implemented using this scheme.
[0130] S603. Determine the target write information based on the similarity between the actual verification parameters and the target verification parameters, as well as the size relationship between the data sequence numbers in each of the write information.
[0131] Specifically, in this embodiment, the electronic device responds to the power-on initialization command, reads the write information corresponding to each storage area's sequence number, further finds the maximum value among the data sequence numbers corresponding to the data stored in each storage area, and calculates the actual verification parameter of the write information based on the write data in the write information corresponding to the maximum value and the data sequence number. Further, by comparing the similarity between the actual verification parameter and the target verification parameter, if they are the same (i.e., the similarity is 100%), it indicates that the data writing and reading are error-free. The write information corresponding to the maximum value is set as the target write information.
[0132] S604. Perform power-on initialization operation according to the target write information.
[0133] Furthermore, in some embodiments of this application, determining the target write information based on the similarity between the actual verification parameters and the target verification parameters, and the size relationship between the data sequence numbers in each of the write information, specifically includes the following steps:
[0134] (1) Compare the size relationship between the data sequence numbers in each of the written information to determine the first written information corresponding to the largest data sequence number;
[0135] (2) If the actual verification parameter corresponding to the first written information is the same as the target verification parameter included in the first written information, then the first written information is set as the target written information.
[0136] (3) If the actual verification parameter corresponding to the first write information is different from the target verification parameter included in the first write information, then the preset write information is set as the target write information.
[0137] It is understood that if the actual verification parameter corresponding to the first write information is different from the target verification parameter included in the first write information, it indicates that the data reading is wrong. In this case, the preset write information is set as the target write information, that is, the preset configuration information and / or status information is set as the target write information.
[0138] This application provides a data processing method that, in response to a data write command, obtains the target write data to be written, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data. The target historical write data is the historical write data whose data acquisition time is the shortest interval between the acquisition time and the acquisition time of the target write data. The method then determines the target data sequence number of the target write data based on the historical data sequence number, and determines target verification parameters based on the target data sequence number and the target write data. Finally, it determines the target storage area number of the target write data based on the historical storage area number, and writes the target write data, the target data sequence number, and the target verification parameters into the target storage area corresponding to the target storage area number. This solution, upon detecting a write command, acquires the target data to be written and, by combining this with the historical storage area number and historical data sequence number corresponding to the historical write data with the shortest interval between the acquisition time of the target data, determines the write location (i.e., the target storage area number) and the target data sequence number of the target data. This achieves partitioned and ordered storage of the target data, ensuring the accuracy and rationality of data storage, avoiding data storage partition chaos, and preventing microcontroller data loss due to unstable power supply and frequent power outages. This partitioned storage approach enhances the microcontroller's data storage capacity, reduces the specification requirements for the microcontroller during development, lowers development costs, improves the utilization efficiency and read / write lifespan of the microcontroller's storage space, and reduces the impact of microcontroller data writing on device operation; thus, it increases data retention reliability.
[0139] Furthermore, based on the above implementation scheme, this application also provides an implementation scheme for a data processing method, see [link to relevant documentation]. Figure 7 , Figure 7 A flowchart illustrating one embodiment of the data processing method provided for the implementation of this application is shown, specifically including steps S701-S704:
[0140] S701: Respond to the power-on initialization command and read the write information of the memory area corresponding to each memory area number in the preset memory area number sequence.
[0141] The write information includes the write data, as well as the data sequence number and target verification parameters corresponding to the write data.
[0142] S702. Calculate the actual verification parameters of each of the written information based on the written data and the data sequence number in each of the written information.
[0143] S703. Determine the target write information based on the similarity between the actual verification parameters and the target verification parameters, as well as the size relationship between the data sequence numbers in each of the write information.
[0144] S704. Perform power-on initialization operation according to the target write information.
[0145] Specifically, the implementation method of the above implementation scheme is shown in any of the above implementation schemes.
[0146] For example, in one embodiment of this application, see [link to relevant documentation]. Figure 8 The data processing methods specifically include:
[0147] (1) Reading data: This action is performed during power-on initialization (i.e., in response to the power-on initialization command, the write information of the memory area corresponding to each memory area number is read). Further, the data of all addresses is read through the following steps, and the latest memory data is compared as the power-down memory data for this power-on. The following steps are performed from top to bottom:
[0148] a. Let X = 1;
[0149] b. Read the memory data DATA1 of PageX, calculate the checksum of the memory data and compare it with the read checksum. If the checksums are the same, proceed to step c; otherwise, proceed to step e.
[0150] c. If DATA2 does not store any memory data or the memory index of DATA2 is smaller than the memory index of DATA1, proceed to step d; otherwise, proceed to step e.
[0151] d.DATA2 stores the data from DATA1;
[0152] Increment the eX value by 1;
[0153] f. Compare X and n. If X is greater than n, proceed to step g; otherwise, proceed to step b.
[0154] g. If DATA2 does not have any saved data, reassign the power-down memory data according to the default initial value; otherwise, execute the data in DATA2 as the power-down memory data.
[0155] h. Data reading finished.
[0156] To better implement the data processing method in the embodiments of this application, based on the data processing method, the embodiments of this application also provide a data processing apparatus, such as... Figure 9 As shown, the data processing device includes modules 901-804:
[0157] The response acquisition module 901 is used to respond to the data writing command, acquire the target write data to be written, and the historical storage area number and historical data sequence number corresponding to the target historical write data. The target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data.
[0158] The determining module 902 is used to determine the target data sequence number of the target written data according to the historical data sequence number, and to determine the target verification parameters according to the target data sequence number and the target written data;
[0159] The writing module 903 is used to determine the target storage area number of the target write data according to the historical storage area number, and write the target write data, the target data sequence number and the target verification parameter into the target storage area corresponding to the target storage area number.
[0160] In some embodiments of this application, before the write module 903 is configured to determine the target storage area number of the target write data based on the historical storage area number, it further includes a function for:
[0161] If each of the preset storage area numbers in the preset storage area number sequence contains historical write data, then erase the historical write data in each storage area except for the storage area corresponding to the historical storage area number. The historical storage area number is any one of the preset storage area number sequences, which are arranged in ascending order.
[0162] The write module 903 is used to determine the target storage area number of the target write data based on the historical storage area number, specifically including the following functions:
[0163] If the historical storage area number is equal to the last preset storage area number in the preset storage area number sequence, then the first preset storage area number in the preset storage area number sequence is set as the target storage area number of the target data to be written.
[0164] If the historical storage area number is less than the last preset storage area number in the preset storage area number sequence, then the preset storage area number that is one position after the historical storage area number in the preset storage area number sequence is set as the target storage area number of the target data to be written.
[0165] In some embodiments of this application, the determining module 902 is configured to determine the target data sequence number of the target written data based on the historical data sequence number, specifically including:
[0166] If the historical data sequence number is equal to the preset sequence number, then the initial data sequence number is set as the target data sequence number of the target data to be written.
[0167] If the historical data sequence number is less than the preset sequence number, the historical data sequence number is superimposed with the sequence number interval parameter to obtain the target data sequence number of the target data to be written.
[0168] After writing the target data, the target data sequence number, and the target verification parameters into the target storage area corresponding to the target storage area number, the method further includes:
[0169] If the target data sequence number is the same as the initial data sequence number, then erase the historical write data stored in other storage areas outside the target storage area.
[0170] In some embodiments of this application, the apparatus further includes a reading module, configured to determine the target storage area number of the target write data based on the historical storage area number, and after writing the target write data, the target data sequence number, and the target verification parameter into the target storage area corresponding to the target storage area number, the reading module is configured to:
[0171] Calculate the actual verification parameters of each written information based on the written data and the data sequence number in each written information;
[0172] The target write information is determined based on the similarity between the actual verification parameters and the target verification parameters, as well as the size relationship between the data sequence numbers in each of the write information.
[0173] Based on the target information, perform a power-on initialization operation.
[0174] In some embodiments of this application, the reading module is used to determine the target write information based on the similarity between the actual verification parameters and the target verification parameters, and the size relationship between the data sequence numbers in each of the write information, specifically including:
[0175] By comparing the size relationship between the data sequence numbers in each of the written information, the first written information corresponding to the largest data sequence number is determined;
[0176] If the actual verification parameter corresponding to the first written information is the same as the target verification parameter included in the first written information, then the first written information is set as the target written information.
[0177] If the actual verification parameter corresponding to the first write information is different from the target verification parameter included in the first write information, then the preset write information is set as the target write information.
[0178] In some embodiments of this application, the reading module is used to calculate the actual verification parameters of each write information based on the write data and the data sequence number in each write information, specifically including:
[0179] Extract the written data and the data sequence number from the written information;
[0180] Calculate the checksum based on the written data and the data sequence number;
[0181] Set the checksum as the actual verification parameter corresponding to the written information.
[0182] Based on the above implementation scheme, this invention also provides an electronic device, such as... Figure 10 As shown, Figure 10 This is a schematic diagram of an embodiment of the electronic device provided in this application.
[0183] Electronic devices include:
[0184] one or more processors;
[0185] Memory; and
[0186] One or more applications, wherein the applications are stored in memory and configured to be executed by a processor from the steps of the data processing method in any of the embodiments described above.
[0187] Specifically, the electronic device may include components such as a processor 1001 with one or more processing cores, a memory 1002 with one or more computer-readable storage media, a power supply 1003, and an input unit 1004. Those skilled in the art will understand that... Figure 10 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0188] The processor 1001 is the data processing center, connecting various parts of the electronic device via various interfaces and lines. It executes software programs and / or modules stored in the memory 1002, and calls data stored in the memory 1002, to perform various functions and process data, thereby providing overall monitoring of the electronic device. It is understood that the processor 1001 communicates with the controller via signal transmission. Optionally, the processor 1001 may include one or more processing cores; preferably, the processor 1001 may integrate an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 1001.
[0189] The memory 1002 can be used to store software programs and modules. The processor 1001 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002. The memory 1002 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1002 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 1002 may also include a memory controller to provide the processor 1001 with access to the memory 1002.
[0190] In some embodiments of this application, the data processing apparatus can be implemented as a computer program, and the computer program can be implemented as follows: Figure 10 The device operates on the electronic device shown. The memory of the electronic device can store various program modules that constitute the data processing method apparatus. The computer program comprised of the various program modules causes the processor to execute the steps of the data processing methods in the various embodiments of this application described in this specification.
[0191] The electronic device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external electronic devices via a network connection. When the computer program is executed by the processor, it implements a data processing method.
[0192] The electronic device also includes a power supply 1003 that supplies power to various components. Preferably, the power supply 1003 can be logically connected to the processor 1001 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 1003 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0193] The electronic device may also include an input unit 1004, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0194] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 1001 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 1002 according to the following instructions, and the processor 1001 runs the applications stored in the memory 1002 to realize various functions, as follows:
[0195] In response to a data write command, the system obtains the target write data to be written, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data. The target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data.
[0196] The target data sequence number of the target written data is determined based on the historical data sequence number, and the target verification parameters are determined based on the target data sequence number and the target written data.
[0197] The target storage area number of the target data to be written is determined based on the historical storage area number, and the target data to be written, the target data sequence number, and the target verification parameter are written to the target storage area corresponding to the target storage area number.
[0198] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0199] Therefore, embodiments of the present invention provide a computer-readable storage medium (hereinafter referred to as the storage medium), which may include: read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any of the data processing methods provided in the embodiments of the present invention. For example, the computer program loaded by the processor can execute the following steps:
[0200] In response to a data write command, the system obtains the target write data to be written, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data. The target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data.
[0201] The target data sequence number of the target written data is determined based on the historical data sequence number, and the target verification parameters are determined based on the target data sequence number and the target written data.
[0202] The target storage area number of the target data to be written is determined based on the historical storage area number, and the target data to be written, the target data sequence number, and the target verification parameter are written to the target storage area corresponding to the target storage area number.
[0203] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the detailed descriptions of other embodiments above, which will not be repeated here.
[0204] In practice, each of the above units or structures can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units or structures, please refer to the previous method embodiments, which will not be repeated here.
[0205] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0206] The data processing method, apparatus, electronic device, and storage medium provided in the embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A data processing method, characterized in that, include: In response to a data write command, the system obtains the target write data to be written, as well as the historical storage area number and historical data sequence number corresponding to the target historical write data. The target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data. The target data sequence number of the target written data is determined based on the historical data sequence number, and the target verification parameters are determined based on the target data sequence number and the target written data. The target storage area number of the target data to be written is determined based on the historical storage area number, and the target data to be written, the target data sequence number, and the target verification parameter are written to the target storage area corresponding to the target storage area number. After determining the target storage area number of the target write data based on the historical storage area number, and writing the target write data, the target data sequence number, and the target verification parameter into the target storage area corresponding to the target storage area number, the method further includes: In response to the power-on initialization command, read the write information of the storage area corresponding to each storage area number, wherein the write information includes the write data, as well as the data sequence number and target verification parameter corresponding to the write data; Calculate the actual verification parameters of each written information based on the written data and the data sequence number in each written information; The target write information is determined based on the similarity between the actual verification parameters and the target verification parameters, as well as the size relationship between the data sequence numbers in each of the write information. Based on the target information, perform a power-on initialization operation.
2. The data processing method according to claim 1, characterized in that, Before determining the target storage area number of the target data to be written based on the historical storage area number, the method further includes: If each of the preset storage area numbers in the preset storage area number sequence contains historical write data, then erase the historical write data in each storage area except for the storage area corresponding to the historical storage area number. The historical storage area number is any one of the preset storage area number sequences, which are arranged in ascending order. Determining the target storage area number of the target data to be written based on the historical storage area number includes: If the historical storage area number is equal to the last preset storage area number in the preset storage area number sequence, then the first preset storage area number in the preset storage area number sequence is set as the target storage area number of the target data to be written. If the historical storage area number is less than the last preset storage area number in the preset storage area number sequence, then the preset storage area number that is one position after the historical storage area number in the preset storage area number sequence is set as the target storage area number of the target data to be written.
3. The data processing method according to claim 1, characterized in that, Determining the target data sequence number of the target data to be written based on the historical data sequence number includes: If the historical data sequence number is equal to the preset sequence number, then the initial data sequence number is set as the target data sequence number of the target data to be written. If the historical data sequence number is less than the preset sequence number, the historical data sequence number is superimposed with the sequence number interval parameter to obtain the target data sequence number of the target data to be written. After writing the target data, the target data sequence number, and the target verification parameters into the target storage area corresponding to the target storage area number, the method further includes: If the target data sequence number is the initial data sequence number, then erase the historical write data stored in other storage areas outside the target storage area.
4. The data processing method according to claim 1, characterized in that, The step of determining the target write information based on the similarity between the actual verification parameters and the target verification parameters, and the size relationship between the data sequence numbers in each of the write information, includes: By comparing the size relationship between the data sequence numbers in each of the written information, the first written information corresponding to the largest data sequence number is determined; If the actual verification parameter corresponding to the first written information is the same as the target verification parameter included in the first written information, then the first written information is set as the target written information. If the actual verification parameter corresponding to the first write information is different from the target verification parameter included in the first write information, then the preset write information is set as the target write information.
5. The data processing method according to claim 1, characterized in that, The step of calculating the actual verification parameters for each piece of written information based on the written data and the data sequence number in each piece of written information includes: Extract the written data and the data sequence number from the written information; Calculate the checksum based on the written data and the data sequence number; Set the checksum as the actual verification parameter corresponding to the written information.
6. A data processing apparatus, characterized in that, The data processing device includes: The response acquisition module is used to respond to the data write command, acquire the target write data to be written, and the historical storage area number and historical data sequence number corresponding to the target historical write data. The target historical write data is the historical write data with the shortest interval between the data acquisition time and the acquisition time of the target write data. The determination module is used to determine the target data sequence number of the target written data based on the historical data sequence number, and to determine the target verification parameters based on the target data sequence number and the target written data; The writing module is used to determine the target storage area number of the target write data according to the historical storage area number, and write the target write data, the target data sequence number and the target verification parameter into the target storage area corresponding to the target storage area number; The read module is used to respond to the power-on initialization command and read the write information of the storage area corresponding to each storage area number. The write information includes the write data, as well as the data sequence number and target verification parameter corresponding to the write data. Calculate the actual verification parameters of each written information based on the written data and the data sequence number in each written information; The target write information is determined based on the similarity between the actual verification parameters and the target verification parameters, as well as the size relationship between the data sequence numbers in each of the write information. Based on the target information, perform a power-on initialization operation.
7. An electronic device, characterized in that, The electronic device includes: One or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the data processing method of any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded by a processor to perform the steps of the data processing method according to any one of claims 1 to 5.
Citation Information
Patent Citations
EEPROM data writing method and device and electronic device
CN110888605A
Method and device for checking data during power failure, storage medium and electronic equipment
CN111897685A