Data backup method, device and storage medium
By performing dual backup of non-volatile data in the vehicle-controlled ECU, and using the combination of FLASH and EEPROM, the problem of insufficient data storage reliability in the prior art is solved, and higher data security and system stability are achieved.
Patent Information
- Application Number
- CN202111143584.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2041-09-28
AI Technical Summary
In the existing vehicle control electronic control unit (ECU), the management mechanism based on peripheral EEPROM and FLASH simulated EEPROM is insufficient to store non-volatile data, and data failure or damage is easily caused by interference or interruption.
By synchronously writing nonvolatile data to two random access memories and writing FLASH and EEPROM respectively within the remaining time of the system periodic tasks, dual backup is realized, and the writing process of the two storage media is optimized to improve data reliability.
It improves the storage reliability of non-volatile data, reduces the differences in the writing process, and ensures the normal operation and power-off time requirements of the vehicle control ECU.
Smart Images

Figure CN113791936B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a data backup method, device, and storage medium. Background Art
[0002] The vehicle electronic control unit (ECU) can control the running state of the vehicle and collect driving data generated during driving. These data include some data with non-volatile storage requirements (Non Volatile DATA, NV DATA). Currently, non-volatile memory (Non Volatile Memory, NVM) management components can be used to manage and maintain NV DATA. Depending on the storage medium, there are currently two ways to manage NV DATA, including a management mechanism based on an external electrically erasable programmable read only memory (EEPROM) and a management mechanism based on FLASH emulated EEPROM.
[0003] For the management mechanism of peripheral EEPROM, the microcontroller unit (MCU) communicates with the EEPROM peripheral chip through the serial peripheral interface (SPI). The SPI between the MCU and the peripheral may be interfered or interrupted, which may cause the failure of the stored data. For the management mechanism of FLASH emulated EEPROM, if the relevant FLASH operation is accidentally interrupted, it may cause the FLASH error correction code (ECC) error, resulting in the failure of the entire FLASH block, causing larger-scale data damage. It can be seen that the reliability of the data stored by the two existing management mechanisms for NVDATA is insufficient. Summary of the invention
[0004] The present application provides a data backup method, device and storage medium, which realizes the backup of non-volatile data by combining the management mechanism of FLASH emulated EEPROM with the management mechanism of peripheral EEPROM, thereby improving the reliability of non-volatile data storage.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, the present application provides a data backup method, comprising: when non-volatile data writing is detected, the non-volatile data is synchronously written into a first random access memory and a second random access memory of a microcontroller unit; within the remaining time of executing a system periodic task, the non-volatile data in the first random access memory is written into the FLASH of the microcontroller unit, and the non-volatile data in the second random access memory is written into the EEPROM of a microcontroller unit peripheral by executing a preset periodic task.
[0007] In the technical solution provided by the present application, when non-volatile data writing is detected, the non-volatile data is synchronously written into two random access memories, and then the non-volatile data in the two random access memories are respectively written into two different storage media (FLASH and EEPROM). Since the possibility of non-volatile data written into two storage media failing or being damaged at the same time is low, the technical solution of the present application performs double backup of non-volatile data through two storage media, which can improve the reliability of non-volatile data storage. In addition, due to the restrictions on storage objects of the existing FLASH emulation EEPROM management mechanism and the peripheral EEPROM management mechanism, the writing process requirements are quite different, so the writing process of the two mechanisms is also optimized in the present application, and the writing of the FLASH emulation EEPROM management mechanism is realized within the remaining time of executing the system periodic task (corresponding to the non-volatile data in the first random access memory being written into the FLASH of the microcontroller unit in the present application). In addition, the writing of the management mechanism of the peripheral EEPROM is realized by presetting periodic tasks (corresponding to writing the non-volatile data in the second random access memory into the EEPROM of the microcontroller peripheral in this application). In this way, the difference between the writing process of the two mechanisms can be reduced, so as to better complete the dual mechanism writing to ensure the normal operation of the vehicle control ECU and the power-on and power-off time requirements.
[0008] Optionally, in a possible design, the data backup method provided by the present application may further include:
[0009] Read the non-volatile data in the FLASH into the first random access memory, and read the non-volatile data in the peripheral EEPROM into the second random access memory;
[0010] Performing consistency check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory;
[0011] When it is determined that the nonvolatile data in the first random access memory is consistent with the nonvolatile data in the second random access memory, the nonvolatile data in the first random access memory or the nonvolatile data in the second random access memory is read to the micro control unit.
[0012] Optionally, in another possible design, after the above “performing consistency check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory”, the following may be included:
[0013] When it is determined that the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are inconsistent, comparing the time stamps of the non-volatile data in the first random access memory and the non-volatile data in the second random access memory;
[0014] According to the sequence of the timestamps, the non-volatile data in the first random access memory or the non-volatile data in the second random access memory is read to the micro control unit.
[0015] Optionally, in another possible design, before the above “performing consistency check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory”, the following may be included:
[0016] Performing validity check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory;
[0017] It is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are valid data.
[0018] Optionally, in another possible design, after the above “validity check of the non-volatile data in the first random access memory and the non-volatile data in the second random access memory”, the following steps may be included:
[0019] When it is determined that the non-volatile data in the first random access memory is valid data and the non-volatile data in the second random access memory is invalid data, the non-volatile data in the first random access memory is read into the micro control unit;
[0020] Alternatively, when it is determined that the non-volatile data in the second random access memory is valid data and the non-volatile data in the first random access memory is invalid data, the non-volatile data in the second random access memory is read to the micro control unit.
[0021] Optionally, in another possible design, after the above “validity check of the non-volatile data in the first random access memory and the non-volatile data in the second random access memory”, the following steps may be included:
[0022] When it is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are invalid data, the preset data is read into the micro control unit.
[0023] Optionally, in another possible design method, the above-mentioned "writing the non-volatile data in the first random access memory into the FLASH of the microcontroller unit" may include: when receiving the first feedback information, writing the non-volatile data in the first random access memory into the FLASH; the first feedback information is used to indicate that the writing of the non-volatile data into the FLASH is completed; the above-mentioned "writing the non-volatile data in the second random access memory into the EEPROM of the microcontroller unit peripheral" may include: when receiving the second feedback information, writing the non-volatile data in the second random access memory into the peripheral EEPROM; the second feedback information is used to indicate that the writing of the non-volatile data into the peripheral EEPROM is completed.
[0024] In a second aspect, the present application provides a data backup device, including: a detection module and a writing module;
[0025] A detection module, used to detect whether non-volatile data is written;
[0026] A writing module, used for synchronously writing the non-volatile data into the first random access memory and the second random access memory of the micro control unit when the detection module detects that the non-volatile data is written;
[0027] The writing module is also used to write the non-volatile data in the first random access memory into the FLASH of the micro control unit within the remaining time of executing the system periodic task, and write the non-volatile data in the second random access memory into the EEPROM of the micro control unit peripheral by executing the preset periodic task.
[0028] Optionally, in a possible design, the data backup device provided by the present application may further include: a reading module and a verification module;
[0029] The reading module is used to read the non-volatile data in the FLASH into the first random access memory, and read the non-volatile data in the peripheral EEPROM into the second random access memory;
[0030] The verification module is used to perform consistency verification on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory;
[0031] The reading module is also used to read the non-volatile data in the first random access memory or the non-volatile data in the second random access memory to the micro control unit when it is determined that the non-volatile data in the first random access memory is consistent with the non-volatile data in the second random access memory.
[0032] Optionally, in another possible design, the data backup device provided by the present application may further include: a comparison module;
[0033] A comparison module, configured to compare the timestamps of the non-volatile data in the first random access memory and the non-volatile data in the second random access memory when it is determined that the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are inconsistent;
[0034] The reading module is also used to read the non-volatile data in the first random access memory or the non-volatile data in the second random access memory to the micro control unit according to the sequence of the timestamps.
[0035] Optionally, in another possible design, the verification module is further used to:
[0036] Performing validity check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory;
[0037] It is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are valid data.
[0038] Alternatively, in another possible design,
[0039] The reading module is also used for, when it is determined that the non-volatile data in the first random access memory is valid data and the non-volatile data in the second random access memory is invalid data, reading the non-volatile data in the first random access memory to the micro control unit;
[0040] Alternatively, the reading module is further used to read the non-volatile data in the second random access memory to the micro control unit when it is determined that the non-volatile data in the second random access memory is valid data and the non-volatile data in the first random access memory is invalid data.
[0041] Alternatively, in another possible design,
[0042] The reading module is also used to read the preset data into the micro control unit when it is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are invalid data.
[0043] Optionally, in another possible design, the write module is specifically used to: write the non-volatile data in the first random access memory to the FLASH when first feedback information is received; the first feedback information is used to indicate that the writing of the non-volatile data to the FLASH is completed; the write module is also specifically used to: write the non-volatile data in the second random access memory to the external EEPROM when second feedback information is received; the second feedback information is used to indicate that the writing of the non-volatile data to the external EEPROM is completed.
[0044] In a third aspect, the present application provides a data backup device, comprising a memory, a processor, a bus and a communication interface; the memory is used to store computer execution instructions, and the processor is connected to the memory through a bus; when the data backup device is running, the processor executes the computer execution instructions stored in the memory, so that the data backup device performs the data backup method provided in the first aspect above.
[0045] Optionally, the data backup device may be a chip system for implementing data backup. The chip system is used to support the data backup device to implement the functions involved in the first aspect, for example, receiving, sending or processing the data and / or information involved in the above-mentioned data backup method. The chip system includes a chip and may also include other discrete devices or circuit structures.
[0046] In a fourth aspect, the present application provides a computer-readable storage medium, in which instructions are stored. When a computer executes the instructions, the computer executes the data backup method provided in the first aspect.
[0047] In a fifth aspect, the present application provides a computer program product, which includes computer instructions. When the computer instructions are executed on a computer, the computer executes the data backup method provided in the first aspect.
[0048] It should be noted that the above computer instructions may be stored in whole or in part on a computer-readable storage medium, wherein the computer-readable storage medium may be packaged together with the processor of the data backup device, or may be packaged separately from the processor of the data backup device, which is not limited in this application.
[0049] The description of the second, third, fourth and fifth aspects of the present application can refer to the detailed description of the first aspect; and the beneficial effects of the description of the second, third, fourth and fifth aspects can refer to the beneficial effect analysis of the first aspect, which will not be repeated here.
[0050] In this application, the name of the above-mentioned data backup device does not limit the device or functional module itself. In actual implementation, these devices or functional modules may appear with other names. As long as the functions of each device or functional module are similar to those of this application, they fall within the scope of the claims of this application and their equivalent technologies.
[0051] These and other aspects of the present application will become more apparent from the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A schematic diagram of the architecture of a data backup system provided in an embodiment of the present application;
[0053] Figure 2 A flowchart of a data backup method provided in an embodiment of the present application;
[0054] Figure 3 A flowchart of another data backup method provided in an embodiment of the present application;
[0055] Figure 4 A flowchart of another data backup method provided in an embodiment of the present application;
[0056] Figure 5 A schematic diagram of the structure of a data backup device provided in an embodiment of the present application;
[0057] Figure 6 A schematic diagram of the structure of another data backup device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0058] The data backup method, device and storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0059] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0060] The terms "first" and "second" and the like in the specification and drawings of this application are used to distinguish different objects, or to distinguish different processing of the same object, rather than to describe a specific order of objects.
[0061] In addition, the terms "including" and "having" and any variations thereof mentioned in the description of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.
[0062] It should be noted that, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0063] In the description of the present application, unless otherwise specified, “plurality” means two or more.
[0064] The vehicle control ECU can control the running status of the vehicle and collect driving data generated during driving. These data contain some NV DATA. At present, NVM management components can be used to manage and maintain NV DATA. Depending on the storage medium, there are currently two ways to manage NV DATA, including a management mechanism based on peripheral EEPROM and a management mechanism based on FLASH emulated EEPROM.
[0065] For the management mechanism of the peripheral EEPROM, the MCU communicates with the EEPROM peripheral chip through SPI. The SPI between the MCU and the peripheral may be interfered or interrupted, which may cause the failure of the stored data. For the management mechanism of the FLASH emulated EEPROM, if the relevant FLASH operation is accidentally interrupted, it may cause the ECC error of the FLASH, resulting in the failure of the entire FLASH block, causing larger-scale data damage. It can be seen that the reliability of the data stored by the two existing management mechanisms for NV DATA is insufficient.
[0066] In response to the problems existing in the above-mentioned prior art, an embodiment of the present application provides a data backup method, which can improve the reliability of non-volatile data storage by performing double backup of non-volatile data through two storage media, and by optimizing the storage mechanism of the two storage media, it can better complete the dual mechanism writing to ensure the normal operation of the vehicle control ECU and the power-on and power-off time requirements.
[0067] The data backup method provided in the embodiment of the present application can be applicable to a data backup system, which may include a data backup device, a first random access memory (RAM), a second random access memory, FLASH, and an external EEPROM.
[0068] Exemplarily, the data backup device may be an NVM management component. Figure 1 The data backup system may include an NVM management component, a first random access memory, a second random access memory, a FLASH, and an external EEPROM. The NVM management component, the first random access memory, the second random access memory, the FLASH, and the external EEPROM are different storage media of the same MCU.
[0069] like Figure 1 As shown, read and write operations can be implemented between the NVM management component and the first random access memory, read and write operations can be implemented between the NVM management component and the second random access memory, read and write operations can be implemented between the first random access memory and FLASH, and read and write operations can be implemented between the second random access memory and the external EEPROM.
[0070] The following is combined with the above Figure 1 The data backup system shown illustrates the data backup method provided by the present application.
[0071] Reference Figure 2 The data backup method provided in the embodiment of the present application includes S201-S203:
[0072] S201, detecting whether non-volatile data is written.
[0073] Non-volatile data is data that requires non-volatile storage.
[0074] S202: When non-volatile data writing is detected, the non-volatile data is synchronously written into a first random access memory and a second random access memory of the micro control unit.
[0075] S203, within the remaining time of executing the system periodic task, write the non-volatile data in the first random access memory into the FLASH of the micro control unit, and write the non-volatile data in the second random access memory into the EEPROM of the micro control unit peripheral by executing the preset periodic task.
[0076] The system periodic tasks may be some original periodic tasks of the microcontroller unit. When non-volatile data writing is detected, the non-volatile data in the first random access memory may be written into the FLASH of the microcontroller unit using the remaining duration of the system periodic tasks.
[0077] For example, if the time interval between the first cycle and the second cycle of the system periodic task is 10ms, the time required to execute the system periodic task in the first cycle is 5ms, and the time required to execute the system periodic task in the second cycle is 7ms. In this way, the non-volatile data in the first random access memory can be written into the FLASH of the micro control unit within the remaining time of 5ms in the first cycle, and the non-volatile data in the first random access memory can be written into the FLASH of the micro control unit within the remaining time of 3ms in the second cycle.
[0078] Optionally, in a possible implementation, the optimization of the management mechanism of FLASH emulation EEPROM can be achieved by setting the priority of the system periodic task and the task of writing the non-volatile data in the first random access memory into the FLASH of the micro control unit. Specifically, it can be determined that the priority of the system periodic task is higher than the priority of the FLASH emulation EEPROM operation task, so that the system periodic task can be executed first in order of priority, and the non-volatile data in the first random access memory can be written into the FLASH of the micro control unit within the remaining time of executing the system periodic task, so as to ensure that the original system periodic task is not affected.
[0079] The preset periodic task may be a pre-determined periodic task, which is specifically used to execute the writing of the non-volatile data in the second random access memory into the EEPROM of the microcontroller peripheral. The period of the preset periodic task may be determined according to the duration of the busy state of the peripheral EEPROM. Exemplarily, if the busy state of the peripheral EEPROM is 4ms, the period of the preset periodic task may be 5ms. In this way, the MCU may execute other tasks in the 4ms busy state of the peripheral EEPROM, and after the busy state is released, the preset periodic task is scheduled again to write the non-volatile data in the second random access memory into the EEPROM of the microcontroller peripheral.
[0080] Optionally, the data backup method provided in the embodiment of the present application may also include: reading the non-volatile data in the FLASH to a first random access memory, and reading the non-volatile data in the peripheral EEPROM to a second random access memory; performing a consistency check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory; and when it is determined that the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are consistent, reading the non-volatile data in the first random access memory or the non-volatile data in the second random access memory to the micro control unit.
[0081] Since the non-volatile data is backed up by a dual mechanism in the embodiment of the present application, the consistency check can be performed on the dual-backed non-volatile data in the process of reading the non-volatile data. If the non-volatile data in the first random access memory and the second random access memory are consistent, it means that the non-volatile data stored by the two mechanisms are not damaged, and the data update time is the same. At this time, the non-volatile data stored by either mechanism can be read.
[0082] Optionally, the data backup method provided in the embodiment of the present application may further include: when it is determined that the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are inconsistent, comparing the timestamps of the non-volatile data in the first random access memory and the non-volatile data in the second random access memory; and reading the non-volatile data in the first random access memory or the non-volatile data in the second random access memory to the micro control unit according to the order of the timestamps.
[0083] The embodiment of the present application optimizes the writing process of the two mechanisms and reduces the difference in the writing process, but there are still slight differences between the two writing mechanisms. In this way, there may be a difference between the writing time of non-volatile data from the first random access memory to FLASH and the writing time of non-volatile data from the second random access memory to the peripheral EEPROM, and the non-volatile data in the first random access memory and the non-volatile data in the second random access memory may be inconsistent. Therefore, in the embodiment of the present application, the timestamps of the non-volatile data stored in the two mechanisms can be compared, and the non-volatile data with a newer timestamp can be read into the microcontroller unit.
[0084] Optionally, before performing consistency check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory, the data backup method provided in the embodiment of the present application may also include: performing validity check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory; and determining that the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are both valid data.
[0085] Since the process of writing the non-volatile data in the first random access memory into the FLASH of the microcontroller unit may cause the stored data to become invalid, and the process of writing the non-volatile data in the second random access memory into the EEPROM of the microcontroller unit peripheral may also cause the stored data to become invalid, before performing a consistency check on the double-backed up data, the validity of the double-backed up data may be checked separately.
[0086] Optionally, in a possible implementation, when it is determined that the non-volatile data in the first random access memory is valid data and the non-volatile data in the second random access memory is invalid data, the non-volatile data in the first random access memory is read to the micro control unit.
[0087] Optionally, in another possible implementation, when it is determined that the non-volatile data in the second random access memory is valid data and the non-volatile data in the first random access memory is invalid data, the non-volatile data in the second random access memory is read to the micro control unit.
[0088] Optionally, in yet another possible implementation, when it is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are invalid data, the preset data is read into the micro control unit.
[0089] Among them, the preset data is data determined in advance by humans based on demand.
[0090] For example, the vehicle control ECU can control the running state of the vehicle according to the non-volatile data, and different values of non-volatile data can correspond to different vehicle speeds. In the case that both the double-backed non-volatile data are invalid data, in order to avoid the vehicle from stopping, the vehicle can be driven according to the preset data. The preset data may not be the best driving data, for example, it can correspond to the limp mode of the vehicle, but it can ensure that the vehicle is still in the driving state.
[0091] Optionally, when the first feedback information is received, the non-volatile data in the first random access memory can be written to FLASH; the first feedback information is used to indicate that the writing of the non-volatile data to FLASH is completed; when the second feedback information is received, the non-volatile data in the second random access memory can be written to the external EEPROM; the second feedback information is used to indicate that the writing of the non-volatile data to the external EEPROM is completed.
[0092] In summary of the above description, in the data backup method provided by the embodiment of the present application, when non-volatile data writing is detected, the non-volatile data is synchronously written into two random access memories, and then the non-volatile data in the two random access memories are respectively written into two different storage media (FLASH and EEPROM). Since the possibility of non-volatile data written into two storage media being simultaneously invalid or damaged is low, the technical solution of the present application performs double backup of non-volatile data through two storage media, which can improve the reliability of non-volatile data storage. In addition, due to the restrictions on storage objects of the existing FLASH emulation EEPROM management mechanism and the peripheral EEPROM management mechanism, the writing process requirements are quite different, so the writing process of the two mechanisms is also optimized in the present application, and the writing of the FLASH emulation EEPROM management mechanism is realized within the remaining time of executing the system periodic task (corresponding to the non-volatile data in the first random access memory being written into the FLASH of the micro control unit in the present application). In addition, the writing of the management mechanism of the peripheral EEPROM is realized by presetting periodic tasks (corresponding to writing the non-volatile data in the second random access memory into the EEPROM of the microcontroller peripheral in this application). In this way, the difference between the writing process of the two mechanisms can be reduced, so as to better complete the dual mechanism writing to ensure the normal operation of the vehicle control ECU and the power-on and power-off time requirements.
[0093] Based on the above description, Figure 3 As shown, the embodiment of the present application also provides a data backup method, including S301-S306:
[0094] S301 , when non-volatile data writing is detected, the non-volatile data is synchronously written into a first random access memory and a second random access memory of a micro control unit.
[0095] After step S301, steps S302 and S304 are executed.
[0096] S302: within the remaining time of executing the system periodic task, write the non-volatile data in the first random access memory into the FLASH of the micro control unit.
[0097] S303: Determine that writing of non-volatile data into FLASH is completed.
[0098] Step S306 is executed after step S303.
[0099] S304, writing the non-volatile data in the second random access memory into the EEPROM of the micro control unit peripheral by executing a preset periodic task.
[0100] S305 , determining that the writing of non-volatile data into the peripheral EEPROM is completed.
[0101] S306: Determine that the double backup of non-volatile data is completed.
[0102] Optional, such as Figure 4 As shown, the embodiment of the present application also provides a data backup method, including S401-S4014:
[0103] S401, the microcontroller unit starts running and initializes FLASH and EEPROM.
[0104] After step S401, steps S402 and S405 are executed.
[0105] S402: Read the non-volatile data in the FLASH into the first random access memory.
[0106] S403: Determine whether reading the non-volatile data into the first random access memory is completed.
[0107] S404: Perform validity check on the non-volatile data in the first random access memory.
[0108] After step S404, step S408 is executed.
[0109] S405: Read the non-volatile data in the EEPROM into the second random access memory.
[0110] S406: Determine whether reading the non-volatile data into the second random access memory is completed.
[0111] S407: Perform validity check on the non-volatile data in the second random access memory.
[0112] S408: Determine whether the non-volatile data in the first random access memory and the second random access memory are both valid data.
[0113] When it is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are valid data, step S409 is executed; when it is determined that invalid data exists in the non-volatile data in the first random access memory and the non-volatile data in the second random access memory, step S4012 is executed.
[0114] S409: Determine whether the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are consistent.
[0115] When it is determined that the non-volatile data in the first random access memory is consistent with the non-volatile data in the second random access memory, step S4010 is executed; when it is determined that the non-volatile data in the first random access memory is inconsistent with the non-volatile data in the second random access memory, step S4011 is executed.
[0116] S4010, reading the non-volatile data in the first random access memory or the second random access memory to the micro control unit.
[0117] S4011, read the non-volatile data with a newer timestamp to the micro control unit.
[0118] S4012: Determine whether the non-volatile data in the first random access memory and the second random access memory are both invalid data.
[0119] When it is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are invalid data, step S4013 is executed; when it is determined that valid data exists in the non-volatile data in the first random access memory and the non-volatile data in the second random access memory, step S4014 is executed.
[0120] S4013, setting the non-volatile data in the first random access memory and the second random access memory as preset data, and reading the preset data into the micro control unit.
[0121] S4014, reading valid data from both the first random access memory and the non-volatile data in the second random access memory to the micro control unit.
[0122] It can be understood that the EEPROM involved in the embodiments of the present application is an EEPROM of the MCU peripheral.
[0123] like Figure 5 As shown, the embodiment of the present application also provides a data backup device, for example, the data backup device can be Figure 1The NVM management component in the data backup system involved. The data backup device may include: a detection module 11 and a writing module 12.
[0124] The detection module 11 executes S201 in the above method embodiment, and the writing module 12 executes S202 and S203 in the above method embodiment.
[0125] Specifically, the detection module 11 is used to detect whether non-volatile data is written;
[0126] The writing module 12 is used to synchronously write the non-volatile data into the first random access memory and the second random access memory of the micro control unit when the detection module 11 detects that the non-volatile data is written;
[0127] The writing module 12 is also used to write the non-volatile data in the first random access memory into the FLASH of the micro control unit within the remaining time of executing the system periodic task, and write the non-volatile data in the second random access memory into the EEPROM of the micro control unit peripheral by executing the preset periodic task.
[0128] Optionally, in a possible implementation, the data backup device provided by the present application may further include: a reading module and a verification module;
[0129] The reading module is used to read the non-volatile data in the FLASH into the first random access memory, and read the non-volatile data in the peripheral EEPROM into the second random access memory;
[0130] The verification module is used to perform consistency verification on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory;
[0131] The reading module is also used to read the non-volatile data in the first random access memory or the non-volatile data in the second random access memory to the micro control unit when it is determined that the non-volatile data in the first random access memory is consistent with the non-volatile data in the second random access memory.
[0132] Optionally, in another possible implementation, the data backup device provided by the present application may further include: a comparison module;
[0133] A comparison module, configured to compare the timestamps of the non-volatile data in the first random access memory and the non-volatile data in the second random access memory when it is determined that the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are inconsistent;
[0134] The reading module is also used to read the non-volatile data in the first random access memory or the non-volatile data in the second random access memory to the micro control unit according to the sequence of the timestamps.
[0135] Optionally, in another possible implementation, the verification module is further used to:
[0136] Performing validity check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory;
[0137] It is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are valid data.
[0138] Optionally, in another possible implementation,
[0139] The reading module is also used for, when it is determined that the non-volatile data in the first random access memory is valid data and the non-volatile data in the second random access memory is invalid data, reading the non-volatile data in the first random access memory to the micro control unit;
[0140] Alternatively, the reading module is further used to read the non-volatile data in the second random access memory to the micro control unit when it is determined that the non-volatile data in the second random access memory is valid data and the non-volatile data in the first random access memory is invalid data.
[0141] Optionally, in another possible implementation,
[0142] The reading module is also used to read the preset data into the micro control unit when it is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are invalid data.
[0143] Optionally, in another possible implementation, the write module 12 is specifically used for: writing the non-volatile data in the first random access memory into the FLASH when receiving the first feedback information; the first feedback information is used to indicate that the writing of the non-volatile data into the FLASH is completed; the write module 12 is also specifically used for: writing the non-volatile data in the second random access memory into the external EEPROM when receiving the second feedback information; the second feedback information is used to indicate that the writing of the non-volatile data into the external EEPROM is completed.
[0144] Optionally, the data backup device may further include a storage module, and the storage module is used to store program codes of the data backup device, etc.
[0145] like Figure 6As shown, an embodiment of the present application also provides a data backup device, including a memory 41, a processor 42 (42-1 and 42-2), a bus 43 and a communication interface 44; the memory 41 is used to store computer execution instructions, and the processor 42 is connected to the memory 41 through the bus 43; when the data backup device is running, the processor 42 executes the computer execution instructions stored in the memory 41, so that the data backup device executes the data backup method applied to the MCU as provided in the above embodiment.
[0146] In a specific implementation, as an embodiment, the processor 42 may include one or more central processing units (CPUs), such as Figure 6 As an embodiment, the data backup device may include multiple processors 42, such as Figure 6 42-1 and processor 42-2 are shown in FIG. Each CPU in these processors 42 may be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). The processor 42 here may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0147] The memory 41 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 41 may exist independently and be connected to the processor 42 via a bus 43. The memory 41 may also be integrated with the processor 42.
[0148] In a specific implementation, the memory 41 is used to store the data in the present application and the computer execution instructions corresponding to the software program for executing the present application. The processor 42 can perform various functions of the data backup device by running or executing the software program stored in the memory 41 and calling the data stored in the memory 41.
[0149] The communication interface 44 uses any transceiver or other device for communicating with other devices or communication networks, such as a control system, a radio access network (RAN), a wireless local area network (WLAN), etc. The communication interface 44 may include a receiving unit to implement a receiving function, and a sending unit to implement a sending function.
[0150] The bus 43 may be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus. The bus 43 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0151] The explanation of the relevant contents in this embodiment can refer to the above method embodiment, which will not be repeated here.
[0152] Through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0153] An embodiment of the present application also provides a computer-readable storage medium, in which instructions are stored. When a computer executes the instructions, the computer executes the data backup method applied to the MCU provided in the above embodiment.
[0154] Among them, the computer-readable storage medium, for example, can be but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, RAM, ROM, an erasable programmable read only memory (EPROM), a register, a hard disk, an optical fiber, a CD-ROM, an optical storage device, a magnetic storage device, or any suitable combination of the above, or any other form of computer-readable storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application-specific integrated circuit (ASIC). In an embodiment of the present application, the computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, device or device.
[0155] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application 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 backup method, characterized in that: include: When non-volatile data writing is detected, the non-volatile data is synchronously written into a first random access memory and a second random access memory of the micro control unit; During the remaining time of executing the system periodic task, the non-volatile data in the first random access memory is written into the FLASH of the micro control unit, and the non-volatile data in the second random access memory is written into the EEPROM of the micro control unit peripheral by executing the preset periodic task; Wherein, the method further comprises: Reading the non-volatile data in the FLASH into the first random access memory, and reading the non-volatile data in the EEPROM of the peripheral device into the second random access memory; Performing a consistency check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory; When it is determined that the nonvolatile data in the first random access memory is consistent with the nonvolatile data in the second random access memory, the nonvolatile data in the first random access memory or the nonvolatile data in the second random access memory is read to the micro control unit.
2. The data backup method according to claim 1, characterized in that: After performing consistency check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory, the method further includes: When it is determined that the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are inconsistent, comparing the timestamps of the non-volatile data in the first random access memory and the non-volatile data in the second random access memory; According to the sequence of the timestamps, the non-volatile data in the first random access memory or the non-volatile data in the second random access memory is read to the micro control unit.
3. The data backup method according to claim 1, characterized in that: Before performing consistency check on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory, the method further includes: Performing validity verification on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory; It is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are valid data.
4. The data backup method according to claim 3, characterized in that: After performing validity verification on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory, the method further includes: When it is determined that the non-volatile data in the first random access memory is valid data and the non-volatile data in the second random access memory is invalid data, reading the non-volatile data in the first random access memory into the micro control unit; Alternatively, when it is determined that the non-volatile data in the second random access memory is valid data and the non-volatile data in the first random access memory is invalid data, the non-volatile data in the second random access memory is read to the micro control unit.
5. The data backup method according to claim 3, characterized in that: After performing validity verification on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory, the method further includes: When it is determined that both the non-volatile data in the first random access memory and the non-volatile data in the second random access memory are invalid data, preset data is read into the micro control unit.
6. The data backup method according to any one of claims 1 to 5, characterized in that: Writing the non-volatile data in the first random access memory into the FLASH of the micro control unit comprises: writing the non-volatile data in the first random access memory into the FLASH upon receiving first feedback information; the first feedback information is used to indicate that the writing of the non-volatile data into the FLASH is completed; The step of writing the non-volatile data in the second random access memory into the EEPROM of the microcontroller peripheral comprises: upon receiving second feedback information, writing the non-volatile data in the second random access memory into the EEPROM of the peripheral; the second feedback information is used to indicate that the writing of the non-volatile data into the EEPROM of the peripheral is completed.
7. A data backup device, characterized in that: include: A detection module, used to detect whether non-volatile data is written; A writing module, used for synchronously writing the non-volatile data into the first random access memory and the second random access memory of the micro control unit when the detection module detects that the non-volatile data is written; The writing module is further used to write the non-volatile data in the first random access memory into the FLASH of the micro control unit within the remaining time of executing the system periodic task, and write the non-volatile data in the second random access memory into the EEPROM of the micro control unit peripheral by executing the preset periodic task; The device further comprises: A reading module, used for reading the non-volatile data in the FLASH into the first random access memory, and reading the non-volatile data in the peripheral EEPROM into the second random access memory; A verification module, used for performing consistency verification on the non-volatile data in the first random access memory and the non-volatile data in the second random access memory; The reading module is also used to read the non-volatile data in the first random access memory or the non-volatile data in the second random access memory to the micro control unit when it is determined that the non-volatile data in the first random access memory is consistent with the non-volatile data in the second random access memory.
8. A data backup device, characterized in that: It includes a memory, a processor, a bus and a communication interface; the memory is used to store computer-executable instructions, and the processor is connected to the memory via the bus; When the data backup device is running, the processor executes the computer execution instructions stored in the memory, so that the data backup device executes the data backup method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when a computer executes the instructions, the computer executes the data backup method according to any one of claims 1 to 6.
