CN114327289B - Data synchronization method and device and electronic equipment - Google Patents

Data synchronization method and device and electronic equipment Download PDF

Info

Publication number
CN114327289B
CN114327289B CN202111663716.6A CN202111663716A CN114327289B CN 114327289 B CN114327289 B CN 114327289B CN 202111663716 A CN202111663716 A CN 202111663716A CN 114327289 B CN114327289 B CN 114327289B
Authority
CN
China
Prior art keywords
data
request
partition
sector
memory
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111663716.6A
Other languages
Chinese (zh)
Other versions
CN114327289A (en
Inventor
陈丙杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Spreadtrum Communications Tianjin Co Ltd
Original Assignee
Spreadtrum Communications Tianjin Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Spreadtrum Communications Tianjin Co Ltd filed Critical Spreadtrum Communications Tianjin Co Ltd
Priority to CN202111663716.6A priority Critical patent/CN114327289B/en
Publication of CN114327289A publication Critical patent/CN114327289A/en
Application granted granted Critical
Publication of CN114327289B publication Critical patent/CN114327289B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Hardware Redundancy (AREA)

Abstract

The application provides a data synchronization method, a data synchronization device and electronic equipment, wherein the method comprises the following steps: detecting a first request of a first application; when the first request is a write request, judging whether the first request is a write request in a preset write request set or not; if the NV data is a write request in a preset write request set, suspending the synchronous operation, and writing the NV data indicated by the first request into a first NV partition of a first memory; the synchronization operation is an operation of synchronizing NV data to the MCU; and if the NV data is not the write request in the preset write request set, writing the NV data indicated by the first request into the first NV partition after the synchronous operation is completed. The application can reduce the occurrence of the crash of the MODEM caused by the NV data synchronization and improve the user experience.

Description

Data synchronization method and device and electronic equipment
Technical Field
The present application relates to the field of data synchronization technologies, and in particular, to a data synchronization method, a data synchronization device, and an electronic device.
Background
An electronic device (for example, a smart watch) includes a MODEM (MODEM) and a micro control unit (Microcontroller Unit, MCU), and Nonvolatile (NV) data stored in a random access memory (Random Access Memory, RAM) by the MODEM needs to be synchronized into a FLASH memory of the MCU, however, there is a case that the MODEM crashes due to the synchronization of the NV data, which affects user experience.
Disclosure of Invention
The application provides a data synchronization method, a data synchronization device and electronic equipment, which can reduce the occurrence of MODEM crash caused by NV data synchronization and improve user experience.
In a first aspect, an embodiment of the present application provides a data synchronization method, including:
detecting a first request of a first application;
when the first request is a write request, judging whether the first request is a write request in a preset write request set or not;
if the NV data is a write request in a preset write request set, suspending the synchronous operation, and writing the NV data indicated by the first request into a first NV partition of a first memory; the synchronization operation is an operation of synchronizing NV data to the MCU;
and if the NV data is not the write request in the preset write request set, writing the NV data indicated by the first request into the first NV partition after the synchronous operation is completed.
According to the method, when the first request is a write request, if the first request is judged to be the write request in the preset write request set, the synchronous operation is suspended, and the write operation is executed, so that the write operation with high real-time requirement can be arranged in the write request set, the execution efficiency of the write operation with high real-time requirement is prevented from being influenced by the synchronous operation, the condition that a MODEM crashes due to NV data synchronization is reduced, and the user experience is improved.
Optionally, the method further comprises:
and when the first request is not a write request, reading the NV data indicated by the first request from the first NV partition, and sending the read NV data to the first application.
Optionally, the first NV partition includes a plurality of sectors, and the writing the NV data indicated by the first request into the first NV partition of the first memory includes:
and writing the NV data indicated by the first request into the sector of the first NV partition.
Optionally, after writing the NV data indicated by the first request to the sector of the first NV partition, the method further includes:
and setting a first identifier for each sector, wherein the first identifier is used for identifying that the sector is subjected to data change.
Optionally, the first request includes: a synchronization manner of the first request, the synchronization manner including: real-time synchronization or timing synchronization;
after the first identifier is set for each sector, the method further includes:
when the synchronization mode of the first request is real-time synchronization, NV data of the sector is sequentially sent to the MCU according to the sector;
and when receiving the confirmation information fed back by the MCU for each sector, updating the first identification of the sector corresponding to the confirmation information into a second identification, wherein the second identification is used for identifying that the sector is not subjected to data change.
Optionally, the method further comprises:
copying NV data of a readable and writable area in a second NV partition of the first memory to the first NV partition in a starting-up stage and a calibration stage;
the first NV partition and the second partition are respectively used for storing NV data, and the NV data stored in the second NV partition comprises: system parameters; the NV data stored in the first NV partition includes: running data of the application.
Optionally, the method further comprises:
when a timing synchronization period is reached, acquiring sectors provided with a first identifier in the first NV partition and the second NV partition; the second NV partition is located in the first memory;
and sending the NV data of the sector provided with the first identifier to the MCU.
Optionally, the method further comprises:
the MCU receives the NV data of the sector, and updates the backup data of the sector in the second memory according to the NV data of the sector;
and the MCU calculates the check code of the data partition where the backup data are located, and updates the check code of the data partition according to the calculated check code.
Optionally, the first memory is RAM; and/or, the second memory is a FLASH memory.
In a second aspect, an embodiment of the present application provides a data synchronization apparatus, including:
the detection module is used for detecting a first request of a first application;
the judging module is used for judging whether the first request is a write request in a preset write request set or not when the first request is a write request;
the processing module is used for suspending the synchronous operation if the write request is a write request in a preset write request set, and writing the NV data indicated by the first request into a first NV partition of a first memory; the synchronization operation is an operation of synchronizing NV data to the MCU; and if the NV data is not the write request in the preset write request set, writing the NV data indicated by the first request into the first NV partition after the synchronous operation is completed.
In a third aspect, an embodiment of the present application provides an electronic device, including: a MODEM, a first memory, an MCU, and a second memory; the MODEM is respectively connected with the first memory and the MCU, and the second memory is connected with the MCU; the MODEM is configured to perform the method according to any one of the first aspect, and the MCU is configured to perform the method according to the first aspect.
Optionally, the first memory is RAM; and/or, the second memory is a FLASH memory.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium having a computer program stored therein, which when run on a computer, causes the computer to perform the method of any of the first aspects.
In a fifth aspect, the present application provides a computer program for performing the method of the first aspect when the computer program is executed by a computer.
In one possible design, the program in the fifth aspect may be stored in whole or in part on a storage medium packaged with the processor, or in part or in whole on a memory not packaged with the processor.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an electronic device according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a MODEM according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a structure of an MCU according to an embodiment of the present application;
FIG. 4 is a flow chart of one embodiment of a data synchronization method of the present application;
FIG. 5 is a flow chart of another embodiment of the data synchronization method of the present application;
FIG. 6 is a schematic diagram of comparing two partition memory data in RAM before and after optimization according to an embodiment of the present application;
FIG. 7 is a flow chart of a data synchronization method according to another embodiment of the present application;
FIG. 8 is a flowchart of a fourth embodiment of the data synchronization method of the present application;
FIG. 9 is a diagram illustrating an example of a data synchronization method according to the present application;
FIG. 10 is a flowchart of a fifth embodiment of a data synchronization method according to the present application;
FIG. 11 is a schematic diagram of a data partition and a check partition in a FLASH memory according to an embodiment of the present application;
fig. 12 is a schematic structural diagram of an embodiment of the data synchronization device of the present application.
Detailed Description
The terminology used in the description of the embodiments of the application herein is for the purpose of describing particular embodiments of the application only and is not intended to be limiting of the application.
In the existing implementation scheme, in the normal operation process of the electronic equipment (such as a smart watch), when the NV data in the MODEM is changed, the MODEM can be timely synchronized to the MCU side. If the MODEM is performing the NV data synchronization operation, the MODEM may be suspended when the application accesses the NV data, and since the time required for one synchronization operation of the NV data is long, if the application is suspended for too long (for example, 100ms or more), a MODEM crash may occur.
Therefore, the application provides a data synchronization method, a data synchronization device and electronic equipment, which can reduce the occurrence of dead halt of a MODEM caused by NV data synchronization and improve user experience.
The electronic device of the embodiment of the application can be a wearable device, such as a smart watch.
Fig. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present application, as shown in fig. 1, including: MODEM11, RAM12, MCU13, and FLASH memory 14; wherein,,
the MODEM11 is connected with the RAM12, the MCU13 is connected with the FLASH memory 14, the MODEM11 is connected with the MCU13, and specifically, the MODEM11 and the MCU13 may be connected through a serial peripheral interface (serial peripheral interface, SPI) bus to perform data interaction.
The RAM12 includes a fixed NV partition and a running NV partition, each including a number of sectors. The fixed NV partition and the running NV partition are used for storing NV data respectively, the fixed NV partition mainly stores system parameters, and the running NV partition mainly stores application data. The data stored in the Fixed NV partition is not lost when powered down.
FLASH memory, also known as FLASH memory, is a long-life, non-volatile memory that retains stored data information in the event of a power failure. In the embodiment of the application, the FLASH memory comprises a plurality of data partitions (sections), and each data partition is used for storing the data of a plurality of sectors in the RAM. The NV data of which sectors in the RAM are specifically stored in each data partition may be preset, and hereinafter, the NV data stored in the FLASH memory and synchronized in the RAM are referred to as backup data. For example, section1 is used to store data of sections 1-50, section2 is used to store data of sections 51-100, and so on.
The software system running in the MODEM11 may be a hierarchical system, such as cr5+threadx. The software system running in the MCU13 may also be a layered system such as RT Thread. The two systems may include: an application layer, an application framework layer, a physical abstraction layer (HAL), and a kernel layer (kernel). The application layer may include several applications, among others. The application framework layer provides an application programming interface (Application Programming Interface, API) and programming framework for applications of the application layer. The HAL layer is an interface layer between the operating system kernel and the hardware circuitry. The kernel layer is a layer between hardware and software.
The following describes an exemplary implementation structure of the MODEM in combination with the above-described software system structure. As shown in fig. 2, the MODEM may include: the system comprises a first application, a synchronous data sending module and an NV data management module; wherein,,
the first application may be located in an application program layer, and is any application in the MODEM that needs to read and write NV data.
The synchronization data sending module may be located in an application framework layer and is used for performing a synchronization operation, wherein the synchronization operation is to synchronize NV data in the RAM to the MCU.
The NV data management module can be located in an application program framework layer and used as an interface for reading and writing NV data in the RAM by the first application, and particularly realizes reading and writing and management of the NV data in the RAM.
The following describes an exemplary implementation structure of the MCU in combination with the above-described software system structure. As shown in fig. 3, the MCU may include: the FLASH management module is used for receiving the FLASH data; wherein,,
the synchronous data receiving module may be located in an application framework layer and is used for receiving NV data synchronized by the MODEM to the MCU.
The FLASH management module can be positioned in the kernel layer and used for realizing the reading, writing and management of data in the FLASH memory.
The implementation of the data synchronization method according to the embodiment of the present application will be described in detail in the following embodiments in conjunction with the structure of the MODEM shown in fig. 2 and the structure of the MCU shown in fig. 3.
FIG. 4 is a flow chart of one embodiment of a data synchronization method of the present application, as shown in FIG. 4, which may include:
step 401: a first request for a first application is detected.
Step 402: when the first request is a write request, judging whether the first request is a write request in a preset write request set; if it is a write request in the set of preset write requests, step 403 is performed, and if it is not a write request in the set of preset write requests, step 404 is performed.
Step 403: suspending the synchronous operation, and writing the NV data indicated by the first request into a first NV partition of the first memory; the present branching flow ends.
The first memory may be the RAM, and the first NV partition may be a running NV partition.
The synchronization operation in this step is an operation of synchronizing NV data to the MCU, and the paused synchronization operation may be an ongoing synchronization operation.
Step 404: after the synchronization operation is completed, writing the NV data indicated by the first request into the first NV partition, and ending the local partition flow.
Alternatively, the method shown in fig. 4 may be performed by a MODEM.
In the method shown in fig. 4, when the first request is a write request, if it is determined that the first request is a write request in a preset write request set, the synchronization operation of NV data is suspended, and the write operation is performed, so that the write operation with high real-time requirements can be set in the write request set, the execution efficiency of the write operation with high real-time requirements is prevented from being affected by the synchronization operation, and therefore, the occurrence of MODEM crash caused by NV data synchronization is reduced, and user experience is improved.
FIG. 5 is a flow chart of another embodiment of the data synchronization method of the present application. The method is suitable for NV data synchronization between two partitions in the RAM during the starting-up phase and the calibration phase of the electronic equipment. As shown in fig. 5, the method may include:
step 501: and when the electronic equipment is in a starting-up stage or a calibration stage, the NV data management module synchronizes the readable and writable NV data of the readable and writable data area in the fixed NV partition to the running NV partition.
Step 502: the NV data management module formats readable and writable NV data (hereinafter referred to as first synchronization data) synchronized to the running NV partition, and indexes the readable and writable NV data.
Formatting in this step refers to converting NV data into data of a preset data format.
By establishing the index, when the first application needs to perform read/write operation of the NV data, the NV data management module can more conveniently and rapidly find the corresponding NV data from the running NV partition according to the index.
It should be noted that, in the electronic device startup phase or calibration phase, more other steps are further included, which will not be described in detail herein.
As shown in FIG. 6, the top graph is a data schematic of a fixed NV partition and a running NV partition when all NV data of the fixed NV partition is copied to the running NV partition; the lower graph is a data schematic diagram of the fixed NV partition and the running NV partition when the read-write NV data of the fixed NV partition are copied to the running NV partition, and comparison shows that the NV data management module only synchronizes the read-write NV data in the fixed NV partition to the running NV partition.
FIG. 7 is a flowchart of another embodiment of the data synchronization method of the present application, as shown in FIG. 7, the method may include:
step 701: the NV data management module detects a first request for a first application.
When the first application needs to perform a read operation or a write operation on the NV data, a first request is sent to the NV data management module, where the first request may be a read request or a write request, and correspondingly, the NV data management module detects the first request of the first application.
The read request may include: data information to be read is required.
The write request may include: the synchronization method of the write request requires writing of NV data of the running NV partition, and the like.
Alternatively, the setting of the synchronization mode of the write request may be achieved by different values of the same identifier, for example, a synchronization mode identifier bit may be set in the write request, where a 1 indicates that the synchronization mode is real-time synchronization, and a 0 indicates that the synchronization mode is timing synchronization.
Step 702: the NV data management module determines whether the first request is a write request, if not, performs step 703, and if so, performs step 704.
Step 703: and the NV data management module responds to the first request, reads the NV data indicated by the first request from the RAM, and sends the read NV data to the first application, and the branching flow is ended.
In step 702, when it is determined that the first request is not a write request, that is, when it is determined that the first request is a read request, step 703 is performed. In the embodiment of the application, for the read request of the application, whether synchronous operation is currently performed or not, namely whether the NV data is being synchronized to the MCU or not can be considered, the read request of the application can be directly responded, the read operation of the NV data can be realized by matching with the application, and the read request is not required to be responded after the synchronous operation is finished, so that the processing efficiency of the read operation of the first application can be ensured.
Step 704: the NV data management module determines whether a synchronization operation is in progress, and if not, performs step 705, and if so, performs step 706.
The above-mentioned synchronization operation may be performed by the synchronization data transmission module, alternatively, the synchronization data transmission module may be triggered by the NV data management module each time to start the synchronization operation, so that whether the triggered synchronization operation exists currently may be recorded in the NV data management module, so that whether the synchronization operation is being performed may be determined according to the record.
Or the NV data management module may acquire the working state of the synchronous data transmission module, where the working state is used to identify whether the synchronous data transmission module is performing synchronous operation, and correspondingly, the NV data management module may determine whether the synchronous operation is performed according to the acquired working state of the synchronous data transmission module.
Step 705: and the NV data management module writes the data indicated by the first request into the running NV partition, and the branch flow is ended.
Step 706: the NV data management module determines whether the first request is a write request in a set of preset write requests, if not, then step 707 is executed, and if so, step 708 is executed.
Step 707: after waiting for the synchronization operation in step 704 to be completed, the NV data indicated by the first request is written into the running NV partition, and the present partition flow ends.
Step 708: the ongoing synchronization operation in step 704 is suspended, and the NV data indicated by the first request is written into the running NV partition, and the present partition flow ends.
In the method shown in fig. 7, when the first request is a write request, if it is determined that the first request is a write request in a preset write request set, the synchronization operation is suspended, and the write operation is performed, so that the write operation with high real-time requirements can be set in the write request set, and the execution efficiency of the write operation with high real-time requirements is prevented from being affected by the synchronization operation; in addition, when the first request is a read request, whether the synchronous operation is executed or not can be not considered, the read operation can be directly executed, and the NV data is fed back to the first application, so that the processing efficiency of the read operation of the first application is improved; through the processing, the condition that the MODEM crashes caused by NV data synchronization can be reduced, and the user experience is improved.
Fig. 8 is a flowchart illustrating a further embodiment of the data synchronization method of the present application, which may be performed after step 705, step 707, or step 708 of the method shown in fig. 7, for implementing real-time synchronization of the writing of the first request to the NV data of the running NV partition. As shown in fig. 8, the method may include:
step 801: the NV data management module sets a first identifier for each sector written with NV data in the running NV partition, wherein the first identifier is used for identifying the sector to change data.
When writing the NV data indicated by the first request into the running NV partition in step 705, step 707, or step 708, specifically writing the NV data indicated by the first request into a plurality of sectors of the running NV partition. In this step, the NV data management module may set first identifiers for the plurality of sectors written with NV data, respectively, so as to record that the plurality of sectors are written with NV data, that is, change data occurs.
Optionally, a parameter may be set in the NV data management module for each sector, which is referred to as a data change parameter in this embodiment of the present application, and is used to record whether the sector has a data change, if the value of the data change parameter is 0, it indicates that no data change has occurred, and if the value of the data change parameter is 1 (i.e. corresponding to the first identifier), it indicates that a data change has occurred.
Step 802: the NV data management module determines whether the synchronization mode of the first request is real-time synchronization, if yes, step 803 is executed, and if not, the present tributary flow ends.
If the first request is not synchronized in real time, it is indicated that the first request is synchronized in timing, and therefore, the present tributary flow ends, and the data of the sector written with NV data based on the first request is synchronized to the MCU when the timing period of the timing synchronization arrives.
Step 803: and triggering the synchronous data sending module by the NV data management module to sequentially send the NV data of the plurality of sectors written with the NV data to the MCU according to the sectors.
Step 804: after receiving the NV data of a sector, the MCU sends confirmation information aiming at the sector to the NV data management module, and updates the backup data of the sector in the FLASH memory according to the NV data of the sector.
The confirmation information is used for indicating the MCU to complete the NV data receiving of the sector.
Optionally, in this step, the synchronous data receiving module in the MCU may send acknowledgement information for a sector to the NV data management module after receiving NV data of the sector, and the FLASH management module updates backup data of the sector in the FLASH memory according to the NV data of the sector.
Optionally, the confirmation information may be specifically sent from the synchronous data receiving module of the MCU to the synchronous data sending module of the MODEM, and then sent from the synchronous data sending module of the MODEM to the NV data management module of the MODEM.
Step 805: and when the NV data management module receives the confirmation information fed back by the MCU for each sector, updating the first identifier of the sector corresponding to the confirmation information into a second identifier, wherein the second identifier is used for identifying that the sector is not subjected to data change.
Continuing with the example in step 801, in this step, the NV data management module may change the value of the data change parameter of the sector receiving the acknowledgement information from 1 to 0.
The method shown in fig. 8 is illustrated in connection with fig. 9. As shown in fig. 9, assuming that the running NV partition includes N sectors, N >1, respectively referred to as S1 to SN, and the NV data indicated by the first request is written into S2, S3, and S4 of the running NV partition, the synchronous data sending module of the MODEM may send the NV data of the sector S2 to the synchronous data receiving module of the MCU, and the synchronous data receiving module sends the backup data of the sector S2 to the FLASH management module of the MCU, and the FLASH management module updates the backup data of the sector S2 in the FLASH memory; after the NV data of the sector S2 is received, the synchronous data receiving module feeds back an acknowledgement message corresponding to the sector S2 to the synchronous data transmitting module, and the synchronous data transmitting module transmits the acknowledgement message corresponding to the sector S2 to the NV data management module, where the NV data management module may change the data change parameter of the sector S2 from 1 to 0.
Fig. 10 is a flowchart illustrating a third embodiment of a data synchronization method according to the present application, which can achieve timing synchronization of NV data in RAM. As shown in fig. 10, the method may include:
step 1001: and when the timing synchronization period is reached, the NV data management module acquires the fixed NV partition and the sector with the first identifier in the runningNV partition.
Continuing the foregoing example, the NV data management module may record the data change parameter of each sector in the fixed NV partition and the runningNV partition, and in this step, the NV data management module may find the sector with the data change parameter of 1, that is, obtain the sector with the first identifier in the fixed NV partition and the runningNV partition.
Step 1002: and sequentially transmitting the NV data of the sector provided with the first identifier to the MCU according to the sectors.
Step 1003: after receiving the NV data of a sector, the MCU sends confirmation information aiming at the sector to the NV data management module, and updates the backup data of the sector in the FLASH memory according to the NV data of the sector.
Step 1004: and when the NV data management module receives the confirmation information fed back by the MCU for each sector, updating the first identifier of the sector corresponding to the confirmation information into a second identifier, wherein the second identifier is used for identifying that the sector is not subjected to data change.
The implementation of steps 1003 to 1004 may refer to steps 804 to 805, which are not described here in detail.
In the method shown in fig. 9 and fig. 10, the MCU feeds back the acknowledgement information for each sector, after the NV data management module receives the acknowledgement information of a sector, updates the first identifier of the sector to the second identifier, so that if the data synchronization fails or is terminated in the data synchronization process, the sector which is successfully transmitted in the NV data management module is provided with the second identifier, and the sector which is not successfully transmitted is provided with the first identifier, so that when the NV data management module performs real-time synchronization or timing synchronization, the data of the sector which is not successfully transmitted in the current data synchronization can be transmitted to the MCU according to the first identifier, thereby realizing breakpoint continuous transmission of the data synchronization, improving the data synchronization efficiency, and reducing the data volume and the interaction times of interaction between the MODEM and the MCU.
Alternatively, as shown in fig. 11, in an embodiment of the present application, the FLASH memory may be divided into a plurality of data partitions, and a check code (for example, a Cyclic Redundancy Check (CRC) check code) of each data partition is calculated and recorded in the FLASH management module.
Accordingly, in the above steps 804 and 1003, the method may further include:
and after updating the backup data of the sector in the FLASH memory according to the NV data of the sector, the FLASH management module calculates the check code of the data partition where the backup data is located, and updates the check code of the data partition according to the calculated check code.
Referring to fig. 11, the area of the FLASH management module is divided into a plurality of data partitions, each partition calculates a check code, and compared with setting only 1 data partition in the FLASH memory, calculating a check code for 1 data partition can reduce the data amount of the FLASH management module for calculating the check code and shorten the time for calculating the check code.
It is to be understood that some or all of the steps or operations in the above-described embodiments are merely examples, and that embodiments of the present application may also perform other operations or variations of the various operations. Furthermore, the various steps may be performed in a different order presented in the above embodiments, and it is possible that not all of the operations in the above embodiments are performed.
FIG. 12 is a schematic diagram of an embodiment of the data synchronization device of the present application, as shown in FIG. 12, the device may include:
a detecting module 121, configured to detect a first request of a first application;
a judging module 122, configured to judge whether the first request is a write request in a preset write request set when the first request is a write request;
a processing module 123, configured to suspend the synchronization operation if the write request is a write request in the preset write request set, and write NV data indicated by the first request into a first NV partition of the first memory; the synchronization operation is an operation of synchronizing the NV data to the MCU; and if the NV data is not the write request in the preset write request set, writing the NV data indicated by the first request into the first NV partition after the synchronous operation is completed.
Alternatively, the synchronization operation paused by the processing module 123 may be an ongoing synchronization operation.
Optionally, the processing module 123 may be further configured to: and when the first request is not a write request, reading the NV data indicated by the first request from the first NV partition, and sending the read NV data to the first application.
Optionally, the first NV partition includes a plurality of sectors, and the processing module 123 may specifically be configured to: and writing the NV data indicated by the first request into the sector of the first NV partition.
Optionally, the processing module 123 may be further configured to: and setting a first identifier for each sector, wherein the first identifier is used for identifying that the sector is subjected to data change.
Optionally, the first request includes: the synchronization mode of the first request includes: real-time synchronization or timing synchronization;
the processing module 123 may also be configured to: when the synchronization mode of the first request is real-time synchronization, NV data of the sector is sequentially sent to the MCU according to the sector; when receiving the confirmation information fed back by the MCU for each sector, updating the first identifier of the sector corresponding to the confirmation information into a second identifier, wherein the second identifier is used for identifying that the sector is not subjected to data change.
Optionally, the processing module 123 may be further configured to: copying NV data of a readable and writable area in a second NV partition of the first memory to the first NV partition in a starting-up stage and a calibration stage; the first NV partition and the second partition are respectively used for storing NV data, and the NV data stored in the second NV partition comprises: system parameters; the NV data stored by the first NV partition includes: running data of the application.
Optionally, the processing module 123 may be further configured to: when the timing synchronization period is reached, acquiring sectors provided with a first identifier in the first NV partition and the second NV partition; the second NV partition is located in the first memory; and transmitting the NV data of the sector provided with the first identifier to the MCU.
Optionally, the first memory is RAM; and/or the second memory is a FLASH memory.
The apparatus provided by the embodiment shown in fig. 12 may be used to implement the technical solution of the method embodiment shown in fig. 4 to 10 of the present application, and the implementation principle and technical effects may be further referred to in the related description of the method embodiment.
It should be understood that the above division of the modules of the apparatus shown in fig. 12 is merely a division of a logic function, and may be fully or partially integrated into a physical entity or may be physically separated. And these modules may all be implemented in software in the form of calls by the processing element; or can be realized in hardware; it is also possible that part of the modules are implemented in the form of software called by the processing element and part of the modules are implemented in the form of hardware. For example, the detection module may be a separately established processing element or may be implemented integrated in a certain chip of the electronic device. The implementation of the other modules is similar. In addition, all or part of the modules can be integrated together or can be independently implemented. For example, the data processing device may be a chip or a chip module, or the data transmission device may be a chip or a part of a chip module. In implementation, each step of the above method or each module above may be implemented by an integrated logic circuit of hardware in a processor element or an instruction in a software form.
The present application also provides an electronic device including: a MODEM, a first memory, an MCU, and a second memory; the MODEM is respectively connected with the first memory and the MCU, and the second memory is connected with the MCU; the MODEM is used for executing the data synchronization method provided in any one of the above embodiments.
The present application also provides an electronic device, which includes a storage medium, which may be a nonvolatile storage medium, in which a computer executable program is stored, and a central processor connected to the nonvolatile storage medium and executing the computer executable program to implement the method provided in any of the above embodiments.
The present application also provides a computer readable storage medium having a computer program stored therein, which when run on a computer causes the computer to perform the method provided by any of the above embodiments.
Embodiments of the present application also provide a computer program product comprising a computer program which, when run on a computer, causes the computer to perform the method provided by any of the embodiments described above.
In the embodiments of the present application, "at least one" means one or more, and "a plurality" means two or more. "and/or", describes an association relation of association objects, and indicates that there may be three kinds of relations, for example, a and/or B, and may indicate that a alone exists, a and B together, and B alone exists. Wherein A, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of the following" and the like means any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c may represent: a, b, c, a and b, a and c, b and c or a and b and c, wherein a, b and c can be single or multiple.
Those of ordinary skill in the art will appreciate that the various elements and algorithm steps described in the embodiments disclosed herein can be implemented as a combination of electronic hardware, computer software, and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In several embodiments provided by the present application, any of the functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a Read-Only Memory (hereinafter referred to as ROM), a random access Memory (Random Access Memory) and various media capable of storing program codes such as a magnetic disk or an optical disk.
The foregoing is merely exemplary embodiments of the present application, and any person skilled in the art may easily conceive of changes or substitutions within the technical scope of the present application, which should be covered by the present application. The protection scope of the present application shall be subject to the protection scope of the claims.

Claims (13)

1. A method of data synchronization, comprising:
detecting a first request of a first application;
when the first request is a write request, judging whether the first request is a write request in a preset write request set or not;
if the NV data is a write request in a preset write request set, suspending the synchronous operation, and writing the NV data indicated by the first request into a first NV partition of a first memory; the synchronization operation is an operation of synchronizing nonvolatile NV data to the micro control unit MCU;
and if the NV data is not the write request in the preset write request set, writing the NV data indicated by the first request into the first NV partition after the synchronous operation is completed.
2. The method as recited in claim 1, further comprising:
and when the first request is not a write request, reading the NV data indicated by the first request from the first NV partition, and sending the read NV data to the first application.
3. The method of claim 1, wherein the first NV partition comprises a plurality of sectors, and wherein writing the NV data indicated by the first request to the first NV partition of the first memory comprises:
and writing the NV data indicated by the first request into the sector of the first NV partition.
4. The method of claim 3, wherein after writing the NV data indicated by the first request to the sector of the first NV partition, further comprising:
and setting a first identifier for each sector, wherein the first identifier is used for identifying that the sector is subjected to data change.
5. The method of claim 4, wherein the first request comprises: a synchronization manner of the first request, the synchronization manner including: real-time synchronization or timing synchronization;
after the first identifier is set for each sector, the method further includes:
when the synchronization mode of the first request is real-time synchronization, NV data of the sector is sequentially sent to the MCU according to the sector;
and when receiving the confirmation information fed back by the MCU for each sector, updating the first identification of the sector corresponding to the confirmation information into a second identification, wherein the second identification is used for identifying that the sector is not subjected to data change.
6. The method according to any one of claims 1 to 5, further comprising:
copying NV data of a readable and writable area in a second NV partition of the first memory to the first NV partition in a starting-up stage and a calibration stage;
the first NV partition and the second NV partition are respectively used for storing NV data, and the NV data stored in the second NV partition comprises: system parameters; the NV data stored in the first NV partition includes: running data of the application.
7. The method according to any one of claims 1 to 5, further comprising:
when a timing synchronization period is reached, acquiring sectors provided with a first identifier in the first NV partition and the second NV partition; the second NV partition is located in the first memory;
and sending the NV data of the sector provided with the first identifier to the MCU.
8. The method as recited in claim 7, further comprising:
the MCU receives the NV data of the sector, and updates the backup data of the sector in the second memory according to the NV data of the sector;
and the MCU calculates the check code of the data partition where the backup data are located, and updates the check code of the data partition according to the calculated check code.
9. The method of claim 8, wherein the first memory is random access memory, RAM; and/or, the second memory is a FLASH memory.
10. A data synchronization device, comprising:
the detection module is used for detecting a first request of a first application;
the judging module is used for judging whether the first request is a write request in a preset write request set or not when the first request is a write request;
the processing module is used for suspending synchronous operation if the write request is a write request in a preset write request set, and writing the NV data indicated by the first request into a first NV partition of a first memory; the synchronization operation is an operation of synchronizing NV data to the MCU; and if the NV data is not the write request in the preset write request set, writing the NV data indicated by the first request into the first NV partition after the synchronous operation is completed.
11. An electronic device, comprising: a MODEM, a first memory, an MCU, and a second memory; the MODEM is respectively connected with the first memory and the MCU, and the second memory is connected with the MCU; the MODEM is for performing the method of any one of claims 1 to 7.
12. The apparatus of claim 11, wherein the first memory is RAM; and/or, the second memory is a FLASH memory.
13. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program which, when run on a computer, causes the computer to perform the method of any of claims 1 to 9.
CN202111663716.6A 2021-12-31 2021-12-31 Data synchronization method and device and electronic equipment Active CN114327289B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111663716.6A CN114327289B (en) 2021-12-31 2021-12-31 Data synchronization method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111663716.6A CN114327289B (en) 2021-12-31 2021-12-31 Data synchronization method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN114327289A CN114327289A (en) 2022-04-12
CN114327289B true CN114327289B (en) 2023-08-11

Family

ID=81020597

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111663716.6A Active CN114327289B (en) 2021-12-31 2021-12-31 Data synchronization method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN114327289B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108460047A (en) * 2017-02-21 2018-08-28 阿里巴巴集团控股有限公司 Method of data synchronization and equipment
CN110647511A (en) * 2019-09-27 2020-01-03 掌阅科技股份有限公司 Data synchronization method, computing device and computer storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107018185B (en) * 2017-03-28 2020-04-07 清华大学 Synchronization method and device of cloud storage system
CN111274317A (en) * 2020-01-07 2020-06-12 书生星际(北京)科技有限公司 Method and device for synchronizing multi-node data and computer equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108460047A (en) * 2017-02-21 2018-08-28 阿里巴巴集团控股有限公司 Method of data synchronization and equipment
CN110647511A (en) * 2019-09-27 2020-01-03 掌阅科技股份有限公司 Data synchronization method, computing device and computer storage medium

Also Published As

Publication number Publication date
CN114327289A (en) 2022-04-12

Similar Documents

Publication Publication Date Title
US20150213100A1 (en) Data synchronization method and system
CN108319617B (en) Method and device for determining master-slave difference of database and switching control method and device
CN104246767A (en) Telemetry system for a cloud synchronization system
CN108628717A (en) A kind of Database Systems and monitoring method
CN107506266B (en) Data recovery method and system
CN106155943B (en) A kind of method and device of the power down protection of dual control storage equipment
CN108965383B (en) File synchronization method and device, computer equipment and storage medium
CN103475716A (en) Method and system for achieving data sharing through shared storage
CN113204530B (en) Data writing method, device, equipment and medium of distributed file system
CN105550230B (en) The method for detecting and device of distributed memory system node failure
CN102025758B (en) Method, device and system for recovering data copy in distributed system
CN111984421B (en) Data processing method, device and storage medium
CN108228789B (en) Synchronous abnormity recovery method and device triggered by slave node
CN103973727A (en) Data synchronizing method and device
CN104866388B (en) Data processing method and device
CN112905696B (en) Multi-computer-room synchronization method based on transaction identifier, computing device and storage medium
CN114327289B (en) Data synchronization method and device and electronic equipment
CN103581262A (en) Master-and-backup data synchronizing method, device and system
CN103729166A (en) Method, device and system for determining thread relation of program
CN110825758B (en) Transaction processing method and device
CN112084264A (en) Log data synchronization method and device and server
CN111124785A (en) Hard disk fault checking method, device, equipment and storage medium
CN114491145B (en) Metadata design method based on stream storage
CN110008153A (en) A kind of method of data synchronization, device, equipment and readable storage medium storing program for executing
CN115114112A (en) Data synchronization method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant