Data management method and device, electronic equipment and storage medium
By configuring the partition selection status in the management partition to specify the read status, data is updated without data transfer, which solves the problems of high performance consumption and waste of storage space in the existing technology, ensuring data accuracy and saving storage space.
Patent Information
- Application Number
- CN202410669870.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-09-06
AI Technical Summary
Existing partition fault tolerance methods require two data transfers when data is updated, resulting in high performance consumption and a waste of storage space.
Specify the read status of multiple partitions by configuring the partition selection status in the management partition. When data is updated, the configuration partition for data update is set to the partition indicated by the configuration partition selection status. Other partitions automatically become backup partitions without data transfer. , reduce performance consumption, speed up update time, and save storage space.
It reduces performance consumption when updating data, speeds up update time, saves storage space, and ensures the correctness of data through adaptive status to avoid program errors.
Smart Images

Figure CN118605801A
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and specifically relates to a data management method, device, electronic device and storage medium. Background Art
[0002] In the prior art, most of the existing partition fault tolerance adopts a backup method for the data in the partition, that is, the partition data before modification is copied to the backup partition.
[0003] When copying partition data, the data of the partition before modification needs to be moved to the backup partition first, and then the data to be modified is written to the primary partition. Moving data twice will cause unnecessary performance consumption. At the same time, three partitions (one primary and two backups) will be generated, wasting storage space. Summary of the invention
[0004] In view of this, the purpose of the present application is to provide a data management method, device, electronic device and storage medium to reduce performance consumption and save storage space.
[0005] In a first aspect, an embodiment of the present application provides a data management method, the method comprising: selecting an update configuration partition from multiple configuration partitions, writing new data to the update configuration partition, the configuration partition being used to store program running data, each of the multiple configuration partitions storing the same running data; setting the partition indicated by the configuration partition selection state in the management partition as the update configuration partition, the configuration partition selection state being used to indicate the configuration partition used when the program is running.
[0006] The data management method provided by the present application specifies the reading status of multiple partitions by configuring the partition selection status in the management partition. When updating data, the configuration partition for data update is set to the partition indicated by the configuration partition selection status, and other partitions automatically become backup partitions. There is no need to move data, which can reduce performance consumption, speed up update time, and save storage space.
[0007] In an optional embodiment of the present application, the method further includes: setting the adaptability status of the updated configuration partition in the management partition, the adaptability status being used to indicate whether the data in the configuration partition can run correctly.
[0008] In the above embodiment, the adaptability status of the update configuration partition is stored in the management partition, so that when reading data, it can be quickly known whether the program can run the data correctly.
[0009] In an optional embodiment of the present application, the method further includes: reading data of the management partition, selecting a target configuration partition according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state; and operating based on the data in the target configuration partition.
[0010] In the above embodiment, the adaptability status data of each configuration partition is stored in advance in the management partition. When reading data, the correct configuration partition can be selected through the adaptability status data in the management partition to avoid program errors.
[0011] In an optional embodiment of the present application, the selecting a target configuration partition based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state includes: if the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is to be changed, selecting the partition indicated by the configuration partition selection state as the target configuration partition; if the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is confirmed, selecting the partition indicated by the configuration partition selection state as the target configuration partition; if the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is to be confirmed, setting the partition indicated by the configuration partition selection state as a new configuration partition; and reselecting the target configuration partition based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0012] In the above embodiment, when the adaptability status is to be changed or confirmed, the partition indicated by the configuration partition selection status is set as the target configuration partition. When the adaptability status is to be changed, the target configuration partition is re-determined among other configuration partitions based on the adaptability status, and the correct configuration partition is selected by polling to avoid program errors.
[0013] In an optional embodiment of the present application, the adaptability state of the updated configuration partition is set to pending change. When the adaptability state indicates pending change, the operation based on the data in the target configuration partition includes: setting the adaptability state of the target configuration partition to pending confirmation, and operating based on the configuration data in the target configuration partition; if the data in the target configuration partition can run normally, setting the adaptability state of the target configuration partition to confirmed; if the data in the target configuration partition cannot run normally, selecting to set the partition indicated by the configuration partition selection state as a new configuration partition; and reselecting the target configuration partition based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0014] In the above embodiment, when the new data in the updated configuration partition is used for operation, the adaptability of the data is checked. If the data is not adaptable, the configuration partition is switched to the backup partition and the operation is performed using the non-updated data.
[0015] In an optional embodiment of the present application, the data of the management partition also includes a verification code, and the method also includes: determining whether the verification code in the management partition is correct; if the verification code in the management partition is correct, selecting the target configuration partition based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0016] In the above embodiment, whether the data in the management partition and the configuration partition is damaged is judged by the check code in the management partition, thereby ensuring the integrity of the data.
[0017] In an optional embodiment of the present application, the method also includes: if the check code in the management partition is incorrect, determining whether it is the first time to read the data in the management partition; if it is the first time to read the data in the management partition, setting the check code in the management partition to a fixed value, setting the configuration partition selection state in the management partition, and setting the adaptability state in the management partition; if it is not the first time to read the data in the management partition, resetting the check code in the management partition to a fixed value, resetting the configuration partition selection state in the management partition, and resetting the adaptability state in the management partition.
[0018] In the above embodiment, after the data error is determined by the check code, the configuration partition selection state and the adaptability state are re-determined to select the configuration partition for data reading to ensure the normal operation of the program.
[0019] In a second aspect, an embodiment of the present application provides a data management device, comprising: an update module, used to select an update configuration partition from multiple configuration partitions, and write new data into the update configuration partition, wherein the configuration partition is used to store program running data, and each of the multiple configuration partitions stores the same running data; a setting module, used to set the partition indicated by the configuration partition selection state in the management partition as the update configuration partition, and the configuration partition selection state is used to indicate the configuration partition used when the program is running.
[0020] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory and a processor, the processor being connected to the memory; the memory being used to store programs; and the processor being used to call the programs stored in the memory to execute a method as described in any one of the first aspects.
[0021] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method described in any one of the first aspects is executed.
[0022] Other features and advantages of the present application will be described in the following description. The purpose and other advantages of the present application can be realized and obtained through the structures specifically pointed out in the written description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The above and other purposes, features and advantages of the present application will be more clear as shown in the drawings.
[0024] Figure 1 A schematic diagram of a data management method provided in an embodiment of the present application is shown;
[0025] Figure 2 A schematic block diagram of a data management device provided in an embodiment of the present application is shown;
[0026] Figure 3 A schematic block diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0027] Hereinafter, embodiments of the present application are described in detail with reference to the accompanying drawings. It should be noted that although the same elements are shown in different drawings, they will be represented by the same reference numerals. In the following description, specific details such as detailed configuration and components are provided to only help fully understand the embodiments of the present application. Therefore, it should be clear to those skilled in the art that various changes and modifications to the embodiments described herein can be made without departing from the scope of the present application. In addition, for clarity and conciseness, the description of well-known functions and configurations is omitted. The terms described below are defined in consideration of the functions in the present application, and may be different according to the user, the user's intention or custom. Therefore, the definition of the term should be determined based on the content throughout this specification.
[0028] The present application may have various modifications and various embodiments, in which the embodiments are described in detail below with reference to the accompanying drawings. However, it should be understood that the present application is not limited to the embodiments, but includes all modifications, equivalents and substitutes within the scope of the present application.
[0029] The terms used herein are only used to describe various embodiments of the present application and are not intended to limit the present application. Unless the context clearly indicates otherwise, the singular form is intended to include the plural form. In the present application, it should be understood that the term "including" or "having" indicates the presence of features, quantities, steps, operations, structural elements, parts or combinations thereof, and does not exclude the presence of one or more other features, quantities, steps, operations, structural elements, parts or combinations thereof, or the possibility of adding one or more other features, quantities, steps, operations, structural elements, parts or combinations thereof.
[0030] Unless defined differently, all terms used herein have the same meaning as understood by a person skilled in the art to which the present application belongs. Unless explicitly defined in the present application, terms (such as those defined in a general dictionary) should be interpreted as having the same meaning as the contextual meaning in the relevant art, and should not be interpreted as having an idealized or overly formal meaning.
[0031] The electronic device according to one embodiment may be one of various types of electronic devices. The electronic device may include, for example, a portable communication device (e.g., a smart phone), a computer, a portable multimedia device, a portable medical device, a camera, a wearable device, or a household appliance. According to one embodiment disclosed, the electronic device is not limited to those described above.
[0032] The terms used in this application are not intended to limit the application, but are intended to include various changes, equivalents or alternatives of corresponding embodiments. Regarding the description of the accompanying drawings, similar reference numerals may be used to represent similar elements or related elements. Unless the relevant context clearly indicates otherwise, the singular form of the noun corresponding to the item may include one or more things. As used herein, each of the phrases such as "A or B", "at least one of A and B", "at least one of A or B", "A, B or C", "at least one of A, B and C" and "at least one of A, B or C" may include all possible combinations of the items listed together in the corresponding one in the phrase. As used herein, terms such as "the 1st", "the 2nd", "the first" and "the second" may be used to distinguish the corresponding component from another component, and are not intended to limit the component in other aspects (e.g., importance or order). It is intended that if an element (e.g., a first element) is referred to as being “coupled with,” “coupled to,” “connected to,” or “connected to” another element (e.g., a second element), with or without the term “operably” or “communicatively,” it indicates that the element may be coupled with the other element directly (e.g., wired), wirelessly, or via a third element.
[0033] As used herein, the term "module" may include a unit implemented in hardware, software, or firmware, and may be used interchangeably with other terms (e.g., "logic," "logic block," "component," and "circuit"). A module may be a single integrated component or its smallest unit or component suitable for performing one or more functions. For example, according to one embodiment, a module may be implemented in the form of an application specific integrated circuit (ASIC).
[0034] To facilitate understanding, the relevant terms and concepts involved in the embodiments of the present application are first introduced below.
[0035] The partition fault tolerance method in the prior art consumes a lot of performance and wastes storage space.
[0036] Based on the above problems, the present application specifies the reading status of multiple partitions by configuring the partition selection status in the management partition. When updating data, the configuration partition for data update is set to the partition indicated by the configuration partition selection status, and other partitions automatically become backup partitions. There is no need to move data, which can reduce performance consumption, speed up update time, and save storage space.
[0037] like Figure 1 As shown, Figure 1 FIG. 1 is a flow chart of a data management method provided by an embodiment of the present application. Figure 1 As shown, the method includes steps 110 to 120:
[0038] Step 110, selecting an updated configuration partition from a plurality of configuration partitions, and writing new data into the updated configuration partition, wherein the configuration partition is used to store program running data, and each of the plurality of configuration partitions stores the same running data.
[0039] A management partition and multiple configuration partitions are set in the system, and the configuration partition is used to store data related to program operation, such as system configuration parameters: IO (input / output) port configuration, serial port baud rate, memory configuration, server website, etc. In the implementation scenario of the method shown in the present application, before new data is written into the update configuration partition, the operation data stored in each of the multiple configuration partitions is the same.
[0040] The management partition is used to store data representing the status of the configuration partition. The status of the partition may include multiple states of the configuration partition, such as configuration partition selection state, adaptability state, data integrity state, etc. This application does not limit the specific data included in the partition state.
[0041] When preparing to update data, select any one of the multiple configuration partitions as the update configuration partition and write the new data into this partition. For example, there are two configuration partitions A and B, both of which store the same system configuration parameters. When preparing to update the configuration parameters, the current partition is determined by the configuration partition selection status in the management partition, and another unused configuration partition, that is, the B configuration partition, is selected as the update configuration partition, and the new configuration parameters are written into the B configuration partition.
[0042] Step 120: Set the partition indicated by the configuration partition selection state in the management partition as the update configuration partition, wherein the configuration partition selection state is used to indicate the configuration partition used when the program is running.
[0043] After the data is written into the update configuration partition, the partition indicated by the configuration partition selection state in the management partition is set as the update configuration partition. The configuration partition selection state is used to indicate the configuration partition that needs to read data when the program is running.
[0044] For example, after writing the new configuration parameters to the B configuration partition, the partition indicated by the configuration partition selection state in the management partition is set as the B configuration partition. When the program is running, due to the restrictions of the configuration partition selection state, the program will read the configuration parameters from the B configuration partition to run. In this way, the configuration parameters are updated. At the same time, since the configuration parameters in the A configuration partition have not changed, the A configuration partition automatically becomes a backup partition of the original configuration parameters.
[0045] The above data management method specifies the reading status of multiple partitions by configuring the partition selection status in the management partition. When updating data, the configuration partition for data update is set to the partition indicated by the configuration partition selection status, and other partitions automatically become backup partitions. There is no need to move data, which can reduce performance consumption, speed up update time, and save storage space.
[0046] Furthermore, the inventors found that the current partition fault tolerance method can only guarantee data integrity, but cannot achieve data adaptability. In the computer field, adaptability means that the data is correct, but the data memory is not suitable for the program. For example, a device includes two modules A and B. During a configuration, the data of module A is given to module B. At this time, the data is correct and can pass the integrity check. However, there is a problem with adaptability. Modules A and B both use incorrect data to run, resulting in program abnormalities.
[0047] In one embodiment of the present application, the method further includes: setting the adaptability status of the updated configuration partition in the management partition, the adaptability status being used to indicate whether the data in the configuration partition can run correctly.
[0048] In view of the problem that the existing technology cannot detect the adaptability of data, a data, namely adaptability status data, can be set for the configuration partition to represent the adaptability of the configuration partition. Adaptability refers to whether the data stored in the configuration partition can be run by the program, and the data is stored in the management partition. By setting the adaptability status in the management partition, the program can judge the adaptability of the configuration partition after reading the data in the management partition, thereby selecting the correct configuration partition to avoid program running errors.
[0049] In the case where the management partition is set with adaptive data, correspondingly, when setting the update configuration partition, the adaptive state of the new data in the update configuration partition also needs to be set.
[0050] In the above embodiment, the adaptability status of the update configuration partition is stored in the management partition, so that when reading data, it can be quickly known whether the program can run the data correctly.
[0051] In one embodiment of the present application, the method further includes: reading data of the management partition, selecting a target configuration partition according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state; and operating based on the data in the target configuration partition.
[0052] In the case where the management partition is provided with adaptability data, the program needs to read the data in the management partition before reading the data in the configuration partition. The read data at least includes the above-mentioned configuration partition selection state and adaptability state.
[0053] A target configuration partition is selected according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state, and data in the target configuration partition is read for operation.
[0054] For example, two configuration partitions (configuration partition A and configuration partition B) and one management partition (occupying a small space, only 12 bytes) are set. The configuration partition selection state in the management partition is represented by the useId character, which represents the partition used by the current program. The adaptability state is represented by the changeFlag character.
[0055] For example, an example of managing partitions is: typedef struct {
[0056] XM_S32useId; / Currently used partition /
[0057] XM_S32changeFlag; / Adaptive state /
[0058] }ManageCfg_s;
[0059] Assume that useId in the management partition is A and changeFlag is confirmed. After reading the data of the management partition, it can be known that the configuration partition indicated by the configuration partition selection status is the A configuration partition, and the adaptability status in the partition has been confirmed, so the A configuration partition is selected as the target configuration partition, and the program reads the data in the A configuration partition for operation.
[0060] In other examples of the present application, for example, there are two configuration partitions A and B, and the management partition may store data: A, no; B, yes. The data indicates that configuration partition A is not adaptable, the data in configuration partition A cannot be correctly run by the program, and the program is abnormal. Configuration partition B is adaptable, the data in configuration partition B can be correctly run by the program, and the program is normal.
[0061] After reading the data of the management partition, the program can determine the adaptability of configuration partitions A and B. When the configuration partition selection state indicates partition A, since configuration partition A is not adaptable, the configuration partition selection state is changed to configuration partition B, and configuration partition B is selected as the target configuration partition. The program reads the data in configuration partition B for operation.
[0062] In the above embodiment, the adaptability status data of each configuration partition is stored in advance in the management partition. When reading data, the correct configuration partition can be selected through the adaptability status data in the management partition to avoid program errors.
[0063] In one embodiment of the present application, the selecting a target configuration partition based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state includes: if the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is to be changed, selecting the partition indicated by the configuration partition selection state as the target configuration partition; if the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is confirmed, selecting the partition indicated by the configuration partition selection state as the target configuration partition; if the adaptability state indicates that it is to be confirmed, setting the partition indicated by the configuration partition selection state as a new configuration partition; and re-selecting the target configuration partition based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0064] The adaptability status of the settings includes: pending change, confirmed, and pending confirmation. Pending change means that the data in the configuration partition is new configuration data and the adaptability of the new configuration needs to be confirmed. Confirmed means that the data in the configuration partition has been confirmed to be adaptable. Pending confirmation means that the data in the configuration partition is interrupted during the adaptability confirmation process.
[0065] In the above example where the management partition is a typedef struct structure, the adaptability status is read from the management partition. If the adaptability status is confirmed, the configuration partition indicated by useId is selected as the target configuration partition, and the program reads the data in the target configuration partition for operation. If useId is A and changeFlag is confirmed, the A configuration partition is selected as the target configuration partition.
[0066] If the adaptability status is to be changed, the configuration partition indicated by useId is also selected as the target configuration partition, and the program reads the data in the target configuration partition for operation. For example, if useId is A and changeFlag is to be changed, then configuration partition A is selected as the target configuration partition.
[0067] If the adaptability status is pending, change the configuration partition indicated by useId and change the adaptability status to confirmed, because the data of the current partition can be upgraded normally under the configuration of another partition, and it can be reversely deduced that the adaptability of the other partition has been verified. In other words, the other partition is the configuration partition before the upgrade, and that configuration partition is also actually used after the adaptability verification. For example, if useId is A and changeFlag is pending, change useId to B and changeFlag to confirmed. At this time, make a selection again based on the configuration partition selection status and adaptability status, and change the partition used by the program to another partition to avoid program errors.
[0068] In other embodiments of the present application, when multiple configuration partitions and the adaptability status of each configuration partition are recorded, the priority of the pending change is pre-set to be higher than the confirmed priority to ensure that the data can be read after the update. For example, there are two configuration partitions A and B, and the adaptability status data that can be stored in the management partition are: A, pending change; B, confirmed, and the configuration partition indicated by the configuration partition selection status is the B partition. Read the data from the management partition, and determine that since the priority of the A configuration partition is pending change, which is higher than the confirmed priority of the B configuration partition, the configuration partition indicated by the configuration partition selection status is modified to the A partition to ensure that the new running data can be used first.
[0069] In the above embodiment, when the adaptability status is to be changed or confirmed, the partition indicated by the configuration partition selection status is set as the target configuration partition. When the adaptability status is to be changed, the target configuration partition is re-determined among other configuration partitions based on the adaptability status, and the correct configuration partition is selected by polling to avoid program errors.
[0070] In one embodiment of the present application, the adaptability state of the updated configuration partition is set to pending change. When the adaptability state indicates pending change, the operation based on the data in the target configuration partition includes: setting the adaptability state of the target configuration partition to pending confirmation, and operating based on the configuration data in the target configuration partition; if the data in the target configuration partition can run normally, setting the adaptability state of the target configuration partition to confirmed; if the data in the target configuration partition cannot run normally, selecting the partition indicated by the configuration partition selection state as a new configuration partition; and reselecting the target configuration partition based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0071] After the data is updated, the adaptability state of the update configuration partition in the management partition is set to pending change.
[0072] Read data from the management partition, and determine that the adaptability state of the configuration partition indicated by the configuration partition selection state is pending change based on the read data. Change the adaptability state of the configuration partition to pending confirmation, and use the configuration partition data for program operation.
[0073] If the program runs correctly, change Pending Confirmation to Confirmed, and you can continue to use the configuration partition in the configuration partition selection state until the data is changed again.
[0074] Assuming that there is a problem with the data in the configuration partition, the program will crash, and the adaptability status will still be pending confirmation and cannot be changed to confirmed. After the program is restarted, the data in the management partition is read, and it can be learned that the adaptability status of the configuration partition indicated by the configuration partition selection status is pending change. Therefore, it is known that the data of the configuration partition indicated by the configuration partition selection status during the last program run caused the crash. Therefore, it is necessary to set the configuration partition indicated by the configuration partition selection status to another new partition, and re-select the target configuration partition based on the new configuration partition selection status and adaptability status.
[0075] For example, there are two configuration partitions A and B, and the management partition is the structure of the above typedef struct. When the configuration partition indicated by the configuration partition selection state is the B configuration partition, and when the adaptability state is to be changed. Change the adaptability state of the B configuration partition to to be confirmed, and use the B configuration partition data for program operation. If the program runs correctly, change the pending confirmation to confirmed. If the program crashes, restart the program, re-read the data of the management partition, obtain the configuration partition selection state and the adaptability state, and when it is determined that the adaptability state of the configuration partition indicated by the configuration partition selection state is to be confirmed, set the partition indicated by the configuration partition selection state to other configuration partitions other than the B configuration partition. Due to the fault-tolerant method used in this application, other configuration partitions are backup partitions for updating the update configuration partition. Therefore, setting the partition to other configuration partitions other than the B configuration partition is to roll back the running data to the original configuration partition, thereby ensuring that the program can run stably.
[0076] A target configuration partition is selected again according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0077] In the above embodiment, when the new data in the updated configuration partition is used for operation, the adaptability of the data is checked. If the data is not adaptable, the configuration partition is switched to the backup partition and the operation is performed using the non-updated data.
[0078] In one embodiment of the present application, the data of the management partition also includes a verification code, and the method also includes: determining whether the verification code in the management partition is correct; if the verification code in the management partition is correct, selecting the target configuration partition based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0079] For example, a form for managing partitions is typedef struct{
[0080] XM_S32check; / check code /
[0081] XM_S32useId; / Currently used partition /
[0082] XM_S32changeFlag; / Adaptive state /
[0083] }ManageCfg_s;
[0084] Before obtaining the data of the configuration partition, read the data in the management partition. After reading the data, first use it to determine whether the verification code in the management partition is correct. If the verification code is correct, select the target partition based on the configuration partition selection status and adaptability status in the management partition.
[0085] In the above embodiment, whether the data in the management partition and the configuration partition is damaged is judged by the check code in the management partition, thereby ensuring the integrity of the data.
[0086] In one embodiment of the present application, the method also includes: if the check code in the management partition is incorrect, determining whether it is the first time to read the data in the management partition; if it is the first time to read the data in the management partition, setting the check code in the management partition to a fixed value, setting the configuration partition selection state in the management partition, and setting the adaptability state in the management partition; if it is not the first time to read the data in the management partition, resetting the check code in the management partition to a fixed value, resetting the configuration partition selection state in the management partition, and resetting the adaptability state in the management partition.
[0087] If the checksum in the management partition is incorrect, it is further determined whether it is the first time to read the data in the management partition, because when the management partition is read for the first time, there is no data in the management partition. For example, when the management partition is started for the first time, there is no data in the management partition, and the checksum will not match.
[0088] If the data in the management partition is read for the first time, the checksum in the management partition is set to a fixed value, and the configuration partition selection state is set. For example, the configuration partition indicated by the configuration partition selection state is set as the default configuration partition. At this time, the default configuration partition also needs to be burned to the specified address, so that the data of the default configuration partition is used for program operation. At the same time, the adaptability state of the configuration partition is also set to facilitate adaptability judgment, such as setting the adaptability state to confirmed.
[0089] If this is not the first time to read the data in the management partition, it means that the data may be damaged. At this time, make sure that there is no lost partition in the management partition, read the data in it for operation, so reset the check code in the management partition, set it to the preset fixed value, and then reset the configuration partition selection status and adaptability status in the management partition.
[0090] For example, when the above-mentioned management partition is in the form of typedef struct, when it is determined that it is not the first startup, the checksum does not match, indicating that the management partition data is wrong. At this time, the configuration data of configuration partition A is first used, and the adaptability state is set to pending confirmation, and the data of configuration partition A is used for program operation. If the program can run normally, change pending confirmation to confirmed. If there is a problem with the data in configuration partition A, it will cause the program to crash. After the program is restarted, the management partition will be read to obtain the adaptability state of configuration partition A as pending confirmation. At this time, change the configuration partition selection state to configuration partition B to switch the configuration partition to partition B, and change the adaptability state to confirmed. Try again to see if it is feasible. So far, both A and B configuration partition data have been tried. As long as one partition information is correct, the program can run normally.
[0091] In the above embodiment, after the data error is determined by the check code, the configuration partition selection state and the adaptability state are re-determined to select the configuration partition for data reading to ensure the normal operation of the program.
[0092] The data management method of the present application occupies a small space, and there is only one management partition that occupies a small space and two configuration partitions. While ensuring data integrity, data copying is reduced and only moved once, that is, only the data to be modified is moved to another partition, and the data is switched by switching the partition used. Here, the configuration management partition data will be changed, the amount of changed data is very small, and the performance consumption is small. In addition, the method of the present application can also verify the adaptability of the configuration data, and data rollback is more convenient. For example, the configuration of product A is updated to product B, and there is no problem in transmitting and saving the data. Product B uses the configuration of product A, which will cause program abnormalities. The related abnormalities cause the device to restart. After the restart, it automatically uses the original normal configuration (no need to move data, only need to modify a small amount of data in the management partition), to avoid program abnormalities all the time.
[0093] like Figure 2 As shown, Figure 2 A data management device 200 provided in an embodiment of the present application is shown, the data management device comprising an update module 210 and a setting module 220;
[0094] The updating module 210 is used to select an updated configuration partition from multiple configuration partitions and write new data into the updated configuration partition, wherein the configuration partition is used to store program running data, and each of the multiple configuration partitions stores the same running data.
[0095] The setting module 220 is used to set the partition indicated by the configuration partition selection state in the management partition as the update configuration partition, wherein the configuration partition selection state is used to indicate the configuration partition used when the program is running.
[0096] In one embodiment of the present application, the device further includes a management module, which is used to set the adaptability state of the updated configuration partition in the management partition, and the adaptability state is used to indicate whether the data in the configuration partition can run correctly.
[0097] In one embodiment of the present application, the device further includes a selection module and an operation module;
[0098] The selection module is used to read the data of the management partition and select a target configuration partition according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state; the operation module is used to operate based on the data in the target configuration partition.
[0099] In one embodiment of the present application, the selection module is specifically used to select the partition indicated by the configuration partition selection state as the target configuration partition if the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is to be changed; select the partition indicated by the configuration partition selection state as the target configuration partition if the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is to be confirmed; set the partition indicated by the configuration partition selection state as a new configuration partition if the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is to be confirmed; and reselect the target configuration partition based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0100] In one embodiment of the present application, the adaptability state of the updated configuration partition is set to pending change, and the operation module is specifically used to set the adaptability state of the target configuration partition to pending confirmation, and operate based on the configuration data in the target configuration partition; if the data in the target configuration partition can run normally, the adaptability state of the target configuration partition is set to confirmed; if the data in the target configuration partition cannot run normally, the partition indicated by the configuration partition selection state is selected as a new configuration partition; and the target configuration partition is reselected based on the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0101] In one embodiment of the present application, the data of the management partition further includes a verification code, and the device further includes a verification module;
[0102] The verification module is used to determine whether the verification code in the management partition is correct; if the verification code in the management partition is correct, a target configuration partition is selected according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
[0103] The verification module is specifically used to determine whether it is the first time to read the data in the management partition if the verification code in the management partition is incorrect; if it is the first time to read the data in the management partition, set the verification code in the management partition to a fixed value, set the configuration partition selection state in the management partition, and set the adaptability state in the management partition; if it is not the first time to read the data in the management partition, reset the verification code in the management partition to a fixed value, reset the configuration partition selection state in the management partition, and reset the adaptability state in the management partition.
[0104] The data management device provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0105] like Figure 3 As shown, Figure 3 A schematic block diagram of an electronic device 300 provided in an embodiment of the present application is shown. The electronic device 300 includes: a processor 310 and a memory 320;
[0106] The processor 310, the memory 320 and each component are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines. The memory 320 is used to store computer programs, such as storing Figure 2 The software function module shown in the figure is the data management device 200. The data management device 200 includes at least one software function module that can be stored in the memory 320 in the form of software or firmware or fixed in the operating system (OS) of the electronic device 300. The processor 310 is used to execute the executable module stored in the memory 320, such as the software function module or computer program included in the data management device 200.
[0107] Among them, the memory 320 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0108] The processor 310 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a microprocessor, etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. Alternatively, the processor 310 may also be any conventional processor, etc.
[0109] The embodiment of the present application further provides a non-volatile computer-readable storage medium (hereinafter referred to as storage medium), on which a computer program is stored. When the computer program is run by a computer such as the electronic device 300 described above, the data management method shown above is executed.
[0110] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0111] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0112] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0113] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a computer-readable storage medium, including several instructions for enabling a computer device (which can be a personal computer, a laptop, a server, or an electronic device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned computer-readable storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0114] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data management method, characterized in that: The method comprises: Selecting an update configuration partition from a plurality of configuration partitions, and writing new data into the update configuration partition, wherein the configuration partition is used to store running data of a program, and each of the plurality of configuration partitions stores the same running data; The partition indicated by the configuration partition selection state in the management partition is set as the update configuration partition, wherein the configuration partition selection state is used to indicate the configuration partition used when the program is running.
2. The method according to claim 1, characterized in that The method further comprises: The adaptability state of the update configuration partition is set in the management partition, and the adaptability state is used to indicate whether the data in the configuration partition can run correctly.
3. The method according to claim 2, characterized in that The method further comprises: Reading data of the management partition, and selecting a target configuration partition according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state; The operation is performed based on the data in the target configuration partition.
4. The method according to claim 3, characterized in that: The selecting a target configuration partition according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state includes: If the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is to be changed, selecting the partition indicated by the configuration partition selection state as the target configuration partition; If the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it has been confirmed, then selecting the partition indicated by the configuration partition selection state as the target configuration partition; If the adaptability state of the configuration partition indicated by the configuration partition selection state indicates that it is to be confirmed, setting the partition indicated by the configuration partition selection state as a new configuration partition; A target configuration partition is reselected according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
5. The method according to claim 4, characterized in that Setting the adaptability state of the update configuration partition to pending change, and when the adaptability state indicates pending change, running based on the data in the target configuration partition includes: Setting the adaptability state of the target configuration partition to pending confirmation, and running based on the configuration data in the target configuration partition; If the data in the target configuration partition can run normally, setting the adaptability state of the target configuration partition to confirmed; If the data in the target configuration partition cannot run normally, selecting to set the partition indicated by the configuration partition selection state as a new configuration partition; A target configuration partition is reselected according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
6. The method according to claim 3, characterized in that The data of the management partition further includes a check code, and the method further includes: Determining whether the verification code in the management partition is correct; If the verification code in the management partition is correct, a target configuration partition is selected according to the configuration partition selection state and the adaptability state of the configuration partition indicated by the configuration partition selection state.
7. The method according to claim 6, characterized in that The method further comprises: If the checksum in the management partition is incorrect, determining whether it is the first time to read the data in the management partition; If the data in the management partition is read for the first time, the checksum in the management partition is set to a fixed value, the configuration partition selection state in the management partition is set, and the adaptability state in the management partition is set; If it is not the first time to read the data in the management partition, the check code in the management partition is reset to a fixed value, the configuration partition selection state in the management partition is reset, and the adaptability state in the management partition is reset.
8. A data management device, characterized in that: include: An update module, used to select an update configuration partition from a plurality of configuration partitions and write new data into the update configuration partition, wherein the configuration partition is used to store program operation data, and each of the plurality of configuration partitions stores the same operation data; The setting module is used to set the partition indicated by the configuration partition selection state in the management partition as the update configuration partition, and the configuration partition selection state is used to indicate the configuration partition used when the program is running.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is connected to the memory; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.
