Data processing method and device, electronic equipment and storage medium

By storing the meter data in the electronic device and updating it to the nonvolatile memory under conditions, the problems of short service life and error rewriting of the nonvolatile memory of the meter are solved, and memory stability and battery management efficiency are improved. .

CN119271136APending Publication Date: 2025-01-07GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411346568.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

The nonvolatile memory in existing meters has short service life, and frequent unlocking and write operations increase the risk of error rewrite and system lag, affecting the efficiency of battery management.

Method used

By obtaining the nonvolatile memory data of the battery meter in an electronic device and storing it in memory, the memory data is updated using the battery algorithm module, and the latest data is updated to the nonvolatile memory under certain conditions. , reduce the number of times the nonvolatile memory is directly operated.

Benefits of technology

It extends the service life of non-volatile memory, reduces the risk of data error rewriting, improves the stability of the memory, and avoids the risk of system lag and overcharge.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271136A_ABST
    Figure CN119271136A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a data processing method and device, electronic equipment and a storage medium, the electronic equipment can comprise a voltameter and a memory, the voltameter can comprise a nonvolatile memory, and the electronic equipment can obtain target data stored in the nonvolatile memory of the voltameter and store the target data in the memory. The target data stored in the memory is updated through the at least one battery algorithm module, and the latest target data stored in the memory is updated to the nonvolatile memory under the condition that the target condition is met, so that the operation times of the battery algorithm module on the nonvolatile memory can be reduced, and the operation efficiency of the battery algorithm module on the nonvolatile memory is improved. According to the invention, the validity of the data stored in the nonvolatile memory in the voltameter is ensured, the service life of the nonvolatile memory of the voltameter can be prolonged, the risk that the data of the nonvolatile memory is mistakenly rewritten can be reduced, and the stability of the nonvolatile memory is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of battery technology, and in particular to a data processing method, device, electronic device and storage medium. Background Art

[0002] Electronic devices are generally provided with a fuel meter, which is used to manage the battery. The fuel meter is mainly used to determine the battery power based on the collected information such as battery voltage, battery current, battery temperature, etc. The fuel meter includes a non-volatile memory, which can be used to store battery-related data (such as a Flash memory). At present, the non-volatile memory in the fuel meter has a short service life. Summary of the invention

[0003] The embodiments of the present application disclose a data processing method, device, electronic device and storage medium, which can extend the service life of a non-volatile memory of an electricity meter.

[0004] The embodiment of the present application discloses a data processing method, which is applied to an electronic device, wherein the electronic device includes an electric meter and a memory, and the electric meter includes a non-volatile memory; the method includes:

[0005] Acquire target data stored in the non-volatile memory of the electricity meter, and store the target data in the memory;

[0006] updating the target data stored in the memory through at least one battery algorithm module;

[0007] When the target condition is met, the latest target data stored in the memory is updated to the non-volatile memory.

[0008] The embodiment of the present application discloses a data processing device, which is applied to an electronic device, wherein the electronic device includes an electric meter and a memory, and the electric meter includes a non-volatile memory; the device includes:

[0009] An acquisition module, used for acquiring target data stored in the non-volatile memory of the electricity meter, and storing the target data in the memory;

[0010] A first updating module, configured to update the target data stored in the memory through at least one battery algorithm module;

[0011] The second updating module is used to update the latest target data stored in the memory to the non-volatile memory when the target condition is met.

[0012] An embodiment of the present application discloses an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor implements any one of the data processing methods disclosed in the embodiment of the present application.

[0013] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, any one of the data processing methods disclosed in the embodiment of the present application is implemented.

[0014] Compared with the related art, the embodiments of the present application have the following beneficial effects:

[0015] An embodiment of the present application provides a data processing method, device, electronic device and storage medium. The electronic device may include a fuel meter and a memory. The fuel meter may include a non-volatile memory. The electronic device may obtain target data stored in the non-volatile memory of the fuel meter and store the target data in the memory. The target data stored in the memory is updated through at least one battery algorithm module, that is, the battery algorithm module will not directly operate on the non-volatile memory, but only update the target data in the memory. When the target conditions are met, the latest target data stored in the memory is updated to the non-volatile memory, which can reduce the number of operations (such as reading numbers, writing data, etc.) of the battery algorithm module on the non-volatile memory. While ensuring the validity of the data stored in the non-volatile memory in the fuel meter, the service life of the non-volatile memory of the fuel meter can be extended, and the risk of data in the non-volatile memory being accidentally rewritten can be reduced, thereby improving the stability of the non-volatile memory. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0017] Figure 1 It is a schematic diagram of the architecture of a battery pack provided in the related art;

[0018] Figure 2 It is one of the flowcharts of a data processing method disclosed in the embodiment of the present application;

[0019] Figure 3 This is the second flow chart of a data processing method disclosed in an embodiment of the present application;

[0020] Figure 4 This is a third flow chart of a data processing method disclosed in an embodiment of the present application;

[0021] Figure 5 This is a fourth flow chart of a data processing method disclosed in an embodiment of the present application;

[0022] Figure 6 This is a fifth flow chart of a data processing method disclosed in an embodiment of the present application;

[0023] Figure 7 is a structural schematic diagram of a data processing device disclosed in an embodiment of the present application;

[0024] Figure 8 It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0026] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present application and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.

[0027] Figure 1 FIG. 1 shows a schematic diagram of the architecture of a battery pack provided in the related art. Figure 1 As shown, the battery pack may include components such as a battery cell 101, a charging switch 102, a discharging switch 103, a three-terminal fuse 104, a protection chip, an NTC (Negative Temperature Coefficient) thermistor 105, a current sensing resistor (Rsense) 106, and a fuel gauge 107.

[0028] The charging switch 102 is used to turn on or off the charging path of the battery cell 101, and the discharging switch 103 is used to turn on or off the discharging path of the battery cell 101. The three-terminal fuse 104 is an electrical component used for circuit protection. When the current or voltage of the charging path or the discharging path exceeds the rated value of the three-terminal fuse 104, the fuse in the three-terminal fuse 104 melts, thereby cutting off the circuit.

[0029] The protection chip may include a primary protection module 108 and a secondary protection module 109. The primary protection module 108 is respectively connected to the battery cell 101, the charging switch 102 and the discharging switch 103. The primary protection module 108 is used to control the charging switch 102 or the discharging switch 103 to disconnect when the voltage of the charging path or the discharging path is greater than the first threshold, thereby ensuring the safety of the battery and the device. The secondary protection module 109 is respectively connected to the battery cell 101 and the three-terminal fuse 104. The secondary protection module 109 is used to control the heater of the three-terminal fuse 104 to heat when the voltage of the charging path or the discharging path is greater than the first threshold, so as to blow the fuse in the three-terminal fuse 104 and achieve overvoltage protection.

[0030] The NTC thermistor 105 is used to detect the temperature, and the current sensing resistor 106 is used to measure the current.

[0031] The fuel gauge 107 is used to manage the battery. The fuel gauge 107 is connected to the battery cell 101, the current sensing resistor 106 and the NTC thermistor 105 respectively. The fuel gauge 107 is mainly used to determine the battery charge according to the collected information such as the battery voltage, battery current and battery temperature.

[0032] Exemplarily, the fuel gauge 107 includes multiple physical devices, such as a high-precision ADC (Analog to Digital Converter), and the fuel gauge 107 implements high-precision sampling of battery voltage, battery current, and battery temperature through the ADC. The fuel gauge 107 can also implement low-power operation, communication, and data processing.

[0033] For example, the fuel gauge 107 can accurately model the battery through the application layer and the kernel driver layer, and implement algorithm programming, data processing and calculation of effective information in the form of firmware. The algorithm firmware is stored in the Flash memory of the fuel gauge 107.

[0034] Taking the Android system as an example, the communication and operation between the application layer, the kernel driver layer and the physical hardware can be summarized as follows: the application layer and the kernel driver layer interact with each other through the information exchange method of the user state and the kernel state of Android, and the kernel driver layer interacts with the fuel gauge 107 through the I2C (Inter-Integrated Circuit, integrated circuit bus) communication protocol. Algorithms related to battery management can be integrated into the application layer to monitor, optimize or protect the battery in real time. Algorithms related to battery management need to store some process state quantities in the Flash memory of the fuel gauge 107. The process state quantity may refer to the data generated and used during the operation of the algorithm. The algorithms related to battery management need to determine the current process state quantity based on the process state quantity at the previous moment to realize real-time monitoring, optimization and protection of the battery. Algorithms related to battery management may include but are not limited to silicon loss calculation algorithms, battery expansion prevention algorithms, intelligent charging algorithms, and EU regulations (Eco Design) algorithms.

[0035] Among them, the silicon loss calculation algorithm can be used to evaluate the loss of battery materials (such as silicon-based materials) and calculate the degree of battery aging. By monitoring the battery's internal resistance changes, capacity attenuation, cycle life and other parameters, the silicon loss calculation algorithm can accurately predict the battery's state of health (SOH).

[0036] Among them, the anti-battery expansion algorithm can be used to dynamically determine the charging current and voltage according to the expansion risk, avoiding situations such as overcharging and high-temperature charging that cause increased internal pressure of the battery.

[0037] Among them, the intelligent charging algorithm can be used to dynamically adjust the charging current and voltage, optimize the charging process, make charging faster and more efficient, and reduce damage to the battery.

[0038] Among them, the EU regulations (Eco Design) algorithm can be used to optimize the overall energy efficiency of the device, by reducing energy consumption and optimizing battery management strategies, in line with EU regulations on environmentally friendly design.

[0039] In the related art, the battery management-related algorithms in the application layer store the process status quantity in the Flash memory of the fuel meter 107. It is necessary to first unlock the fuel meter 107, then write the process status quantity to the Flash memory of the fuel meter 107, and then lock the fuel meter 107. In the process from unlocking the fuel meter 107 to locking the fuel meter 107, there is a risk that the Flash memory of the fuel meter 107 is accidentally rewritten. Secondly, unlocking the fuel meter 107 and writing the process status quantity to the Flash memory is equivalent to erasing the Flash memory of the fuel meter 107 by block, which affects the stability and life of the Flash memory (because the Flash memory of the fuel meter 107 can only guarantee a few thousand erasures, including self-writing of its algorithm operation, battery production line testing and information writing, and whole machine custom writing).

[0040] In the above technical solution, different algorithms unlock the power meter 107 and operate the Flash memory according to their corresponding update frequencies. For example, algorithm A, algorithm B, algorithm C, and algorithm D have update frequencies of 1h (hour), 6h, 12h, and 24h, respectively. Then, in 24 hours a day, the total number of operations on the Flash memory is 24+4+2+1=31 times.

[0041] It can be seen that in the above technical solution, each algorithm directly unlocks the fuel meter 107 to operate the Flash memory at a different update frequency. The cumulative number of operations poses a serious challenge to the service life of the Flash memory of the fuel meter 107. The high frequency of unlocking access also increases the risk of the Flash memory being accidentally rewritten. At the same time, it takes about 1 second to unlock once, and each algorithm concurrently unlocks and accesses the fuel meter 107, which will cause serious system jams (for four algorithms, it takes at least 4 seconds to complete the corresponding write operations of each algorithm), especially during fast charging, and there is even a risk of overcharging.

[0042] The embodiments of the present application disclose a data processing method, device, electronic device and storage medium, which can extend the service life of a non-volatile memory of an electricity meter and reduce the use cost of the electronic device.

[0043] In an embodiment of the present application, an electronic device includes a fuel meter and a memory, and the fuel meter includes a non-volatile memory. The electronic device can obtain target data stored in the non-volatile memory of the fuel meter and store the target data in the memory. The target data stored in the memory is updated through at least one battery algorithm module. When the target conditions are met, the latest target data stored in the memory is updated to the non-volatile memory. This can reduce the number of operations of the battery algorithm module on the non-volatile memory. While ensuring the validity of the data stored in the non-volatile memory in the fuel meter, the service life of the non-volatile memory of the fuel meter can be extended, and the risk of data in the non-volatile memory being accidentally overwritten can be reduced, thereby improving the stability of the non-volatile memory.

[0044] Please refer to Figure 2 , which shows one of the flow charts of a data processing method provided in an embodiment of the present application. The method can be applied to electronic devices, wherein the electronic devices may include but are not limited to laptops, tablet computers, smart wearable devices, digital cameras, mobile phones, etc.

[0045] like Figure 2 As shown, the method may include steps 202 to 206 .

[0046] Step 202, obtaining target data stored in the non-volatile memory of the electricity meter, and storing the target data in the internal memory.

[0047] It should be noted that the fuel meter includes a non-volatile memory, which can be embedded in the fuel meter and can be used to store data related to battery management, such as process state quantities corresponding to the above-mentioned algorithms. The non-volatile memory may include but is not limited to Flash memory.

[0048] The memory of an electronic device refers to the high-speed memory in the electronic device used to temporarily store data.

[0049] Exemplarily, the target data stored in the non-volatile memory of the fuel gauge can be the process state quantity obtained by processing the battery algorithm module, or it can be the data configured by the user or the system. It is understandable that the battery algorithm module is a module that can implement the algorithm function of the battery. Among them, the size of the target data is positively correlated with the number of battery algorithm modules, that is, the more battery algorithm modules there are, the more process state quantities will be written into the non-volatile memory. Exemplarily, when the number of battery algorithm modules is 4, the size of the target data can be 32 bytes.

[0050] Exemplarily, when the electronic device is started, the electronic device reads the target data stored in the non-volatile memory of the fuel gauge.

[0051] Exemplarily, when the electronic device starts, the electronic device loads the kernel driver. When the kernel fuel meter driver is initialized, the SoC (System on Chip) of the electronic device reads the target data stored in the non-volatile memory of the fuel meter through the I2C communication protocol and writes the target data into the memory.

[0052] It is understandable that the power meter in the embodiment of the present application may be an independent IC (Integrated Circuit) or a more complex module, such as including a power meter IC and peripheral circuits, which is not limited in the embodiment of the present application.

[0053] Step 204: Update the target data stored in the memory through at least one battery algorithm module.

[0054] It should be noted that the battery algorithm module can estimate the battery state or the battery optimization parameters based on the current target data, and update the estimated new target data to the memory, that is, the algorithm of the battery algorithm module needs to determine the current target data based on the target data at the previous moment. Due to the constraints of the hardware protection mechanism, the battery algorithm module cannot directly operate the data in the non-volatile memory of the fuel meter, but the battery algorithm module can directly operate the target data stored in the memory, thereby increasing the data update speed.

[0055] Exemplarily, the battery algorithm module may include but is not limited to a silicon loss calculation algorithm module, a battery swelling prevention algorithm module, an intelligent charging algorithm module, an EU regulation algorithm module, etc. It is understandable that the silicon loss calculation algorithm module is a module that can implement the function of the silicon loss calculation algorithm, the battery swelling prevention algorithm module is a module that can implement the function of the battery swelling prevention algorithm, the intelligent charging algorithm module is a module that can implement the function of the intelligent charging algorithm, and the EU regulation algorithm module is a module that can implement the function of the EU regulation algorithm. For the functions of the above-mentioned battery algorithms, please refer to the description of the above embodiments, which will not be repeated here.

[0056] Exemplarily, the target data is read from the memory by at least one battery algorithm module, and the read target data is updated by at least one battery algorithm module, and the updated target data is written into the memory, so as to update the target data stored in the memory, so that each battery algorithm module can obtain the target data at the previous moment, and obtain the target data at the current moment based on the target data at the previous moment, so as to realize real-time monitoring, protection or optimization of the battery.

[0057] Exemplarily, writing the updated target data into the memory includes erasing the target data originally stored in the memory and writing the updated target data into the storage area where the target data was originally stored, thereby updating the data in the same storage area from the originally stored target data to the updated target data.

[0058] In this embodiment, the updated target data processed by at least one battery algorithm module is updated to the internal memory instead of being written into the non-volatile memory of the fuel meter. While ensuring that the at least one battery algorithm module can obtain the process state quantity at the previous moment to determine the current process state quantity, the number of updates of the fuel meter can be reduced, thereby extending the life of the non-volatile memory of the fuel meter.

[0059] In addition, in the related art, when there are multiple battery algorithm modules, if multiple battery algorithm modules operate the non-volatile memory of the fuel meter at the same time, since each operation requires unlocking the fuel meter once, which takes a certain amount of time (such as 1 second, etc.), multiple battery algorithm modules operate the non-volatile memory of the fuel meter at the same time, which will cause the system to freeze. Moreover, during the fast charging process, due to system freezes, even if the battery has approached or reached the upper limit of the safe voltage, the system's response delay will cause charging to continue, so there is still a risk of overcharging.

[0060] In an embodiment of the present application, when there are multiple battery algorithm modules, the multiple battery algorithm modules do not directly operate on the non-volatile memory of the fuel meter, but update the target data in the memory without waiting for the fuel meter to be unlocked. Therefore, there will be no problem of jamming caused by the concurrent operation of multiple battery algorithm modules, and the risk of overcharging due to system jamming can also be reduced.

[0061] Step 206, determine whether the target condition is met, if so, execute step 208; if not, execute step 204.

[0062] It should be noted that the target condition is used to measure whether the timing for updating the data of the fuel gauge has arrived.

[0063] Exemplarily, when the target conditions are not met, the target data stored in the memory may continue to be updated through at least one battery algorithm module, and the data stored in the non-volatile memory may not be updated, so as to ensure the effectiveness and reliability of battery management, reduce the number of updates to the non-volatile memory of the fuel meter, and extend the life of the non-volatile memory.

[0064] Step 208, updating the latest target data stored in the memory to the non-volatile memory.

[0065] It should be noted that when the target conditions are met, the electronic device will update the latest target data stored in the memory to the non-volatile memory. That is, when the target conditions are met, the target data will be updated by at least one battery algorithm module and updated to the non-volatile memory. There is no need to access the non-volatile memory multiple times, which can reduce the risk of the non-volatile memory of the fuel meter being accidentally overwritten. At the same time, it can extend the non-volatile memory of the fuel meter and reduce the occurrence of jamming.

[0066] At the same time, the data stored in the non-volatile memory will not be lost when the electronic device is powered off, restarted, or abnormally shut down. Therefore, when the target conditions are met, the latest target data stored in the memory is updated to the non-volatile memory, which can reduce the loss of target data due to power off, restart, or abnormal shutdown. When the electronic device is restarted, the target data can be obtained from the non-volatile memory, ensuring that the battery algorithm module can continue to operate reliably after the electronic device is inflated without the need for recalibration.

[0067] In some embodiments, when the target condition is met, the electronic device writes the latest target data stored in the internal memory to the non-volatile memory.

[0068] Optionally, when the target condition is met, the electronic device may write the latest target data stored in the memory into a third storage area in the non-volatile memory. The third storage area is different from the storage area where the electronic device obtains the target data from the non-volatile memory of the fuel gauge. In this embodiment, the latest target data is updated to a new storage area in the non-volatile memory, so that the previous target data stored in the non-volatile memory can be retained, so as to facilitate viewing of the previous condition of the battery.

[0069] Optionally, when the target condition is met, the electronic device may erase the target data stored in the fourth storage area in the non-volatile memory, and write the latest target data stored in the memory into the fourth storage area in the non-volatile memory. In this embodiment, before writing the latest target data into the non-volatile memory, the target data stored in the fourth storage area is erased to preserve the accuracy of the latest target data written, thereby saving storage space of the non-volatile memory.

[0070] In an embodiment of the present application, the electronic device can obtain target data stored in the non-volatile memory of the fuel meter and store the target data in the internal memory. The target data stored in the internal memory is updated through at least one battery algorithm module. When the target conditions are met, the latest target data stored in the internal memory is updated to the non-volatile memory. This can reduce the number of operations of the battery algorithm module on the non-volatile memory. While ensuring the validity of the data stored in the non-volatile memory in the fuel meter, the service life of the non-volatile memory of the fuel meter can be extended, and the risk of data in the non-volatile memory being accidentally overwritten can be reduced, thereby improving the stability of the non-volatile memory.

[0071] Please refer to Figure 3 , which shows a second flow chart of a data processing method provided in an embodiment of the present application, such as Figure 3 As shown, the method may include steps 302 to 310.

[0072] Step 302, obtaining target data stored in the non-volatile memory of the electricity meter, and storing the target data in the internal memory.

[0073] For the description of step 302 , reference may be made to the description of step 202 , which will not be repeated here.

[0074] In some embodiments, target data stored in a target storage block in a non-volatile memory of the electricity meter is obtained. It should be noted that the target storage block may be a storage block customized from the non-volatile memory for storing target data.

[0075] In some embodiments, when the target condition is met, the electronic device updates the latest target data stored in the memory to the target storage block in the non-volatile memory.

[0076] In this embodiment, a target storage block is divided in the non-volatile memory of the power meter, and the target data is stored in the dedicated target storage block, thereby avoiding sharing the same storage space with other data (such as firmware, configuration files, etc.), reducing access conflicts, and allowing more efficient reading and writing of target data.

[0077] Step 304: Update the target data stored in the memory through at least one battery algorithm module.

[0078] For the description of step 304 , reference may be made to the description of step 204 , which will not be repeated here.

[0079] In some embodiments, the target data may include sub-data corresponding to at least one battery algorithm module, and the sub-data corresponding to the battery algorithm module is stored in the storage space corresponding to the algorithm module in the memory corresponding to the battery algorithm module. It should be noted that the operation results of different battery algorithm modules and the data required for the operation (such as process state quantity) are different. Therefore, in order to ensure the reliability of the operation of each battery algorithm module, the sub-data corresponding to each battery algorithm module can be obtained from the fuel meter and stored in different storage spaces in the memory, so that each battery algorithm module can obtain reliable updated sub-data based on its corresponding sub-data, thereby ensuring the reliability of the updated target sub-data.

[0080] In some embodiments, the electronic device reads the target sub-data corresponding to the target battery algorithm module from the storage space corresponding to the target battery algorithm module in the memory, and updates the read target sub-data through the target battery algorithm module, and writes the updated target sub-data into the memory, in the storage space corresponding to the target battery algorithm module. Among them, the target battery algorithm module is one of at least one battery algorithm module, that is, one of the multiple battery algorithm modules included in the electronic device. It should be noted that the electronic device can update the sub-data of different bytes (different storage spaces) in the memory respectively through each battery algorithm module to obtain the updated target sub-data, thereby ensuring the reliability of the update.

[0081] Exemplarily, during the startup process of the electronic device, the application layer program will be loaded, and different battery algorithm modules can update the corresponding sub-data stored in the memory. Exemplarily, taking the byte position corresponding to the target battery algorithm module as the position corresponding to the 0th to 3rd bytes as an example, that is, the sub-data required by the target battery algorithm is 4 bytes in total. The target battery algorithm module can read the sub-data corresponding to the position corresponding to the 0th to 3rd bytes in the memory. The target battery algorithm module initializes the relevant variables of the algorithm according to the 4-byte sub-data, and sends the calculated sub-data to the kernel driver layer. The kernel driver layer maps the calculated sub-data to the position corresponding to the 0th to 3rd bytes, and realizes that the sub-data updated by the target battery algorithm module each time is written to the position corresponding to the 0th to 3rd bytes in the memory. In this embodiment, each battery algorithm module realizes the mapping and isolation of sub-data through the kernel driver layer to ensure their independent operation. By mapping a specific byte range, it can be ensured that each battery algorithm module can operate stably.

[0082] In some embodiments, the target data stored in the memory is updated by the target battery algorithm module according to the update frequency corresponding to the target battery algorithm module. The target battery algorithm module is one of at least one battery algorithm module. It should be noted that the update frequency may refer to the periodic frequency at which the battery algorithm module calculates the corresponding process state quantity of the battery. The higher the update frequency, the more frequently the battery algorithm module will calculate the corresponding process state quantity.

[0083] Exemplarily, according to the update frequency corresponding to the target battery algorithm module, the target sub-data corresponding to the target battery algorithm module is read from the storage space corresponding to the target battery algorithm module in the memory, the read target sub-data is updated through the target battery algorithm module, and the updated target sub-data is written into the memory, into the storage space corresponding to the target battery algorithm module.

[0084] In this embodiment, each battery algorithm module can update the target data stored in the memory at its corresponding update frequency, that is, it can monitor, optimize or protect the battery in real time at its update frequency, so that the target data processed by at least one battery algorithm module is stored in the memory, and the operation of each battery algorithm module is not affected. The management effect of the battery can be guaranteed, and the number of write times of the fuel meter is reduced, thereby extending the service life of the fuel meter.

[0085] Step 306, determine whether the target condition is met, if so, execute step 308; if not, execute step 304.

[0086] In some embodiments, the target conditions may include an update duration for updating target data stored in the memory reaching a first target duration, the number of times the target data stored in the memory is updated reaching a preset number of times, detecting that the battery voltage of the electronic device is less than a shutdown voltage threshold, detecting that the battery voltage of the electronic device is less than the shutdown voltage threshold for a continuous period of time, reaching a second target duration, and detecting at least one of a shutdown operation for instructing the electronic device to shut down.

[0087] Wherein, when the target condition includes that the update duration for updating the target data stored in the memory reaches the first target duration, the electronic device may update the target data stored in the power meter according to the first target duration. Wherein, the first target duration may be set according to actual needs.

[0088] In some embodiments, the first target duration is determined based on the waiting duration corresponding to each battery algorithm module, wherein the waiting duration corresponding to the battery algorithm module is used to characterize the real-time requirements of the battery algorithm module for the target data, that is, the longest update duration of the target data that the battery algorithm module can tolerate. It should be noted that since the battery algorithm module needs to determine the current target data based on the target data at the previous moment, if the target data stored in the electronic device is acquired a long time ago, it may cause the current target data determined by the battery algorithm module to differ too much from the actual situation of the battery. Therefore, in order to meet the real-time requirements of the battery algorithm module for the target data, the update duration of the non-volatile memory of the fuel meter should be less than the longest update duration corresponding to the battery algorithm module.

[0089] Optionally, the first target duration is the shortest waiting duration among the waiting durations corresponding to the various battery algorithm modules. In this embodiment, the first target duration is set to the shortest waiting duration among the waiting durations corresponding to the various battery algorithm modules, so that the real-time requirements of all battery algorithm modules for target data can be met, and the accuracy of the calculation results of the battery algorithm modules can be ensured. It should be noted that because the waiting duration of each battery algorithm module is longer than the duration corresponding to the update frequency of the corresponding battery algorithm module, even if the latest target data stored in the memory is updated to the non-volatile memory according to the first target duration, relative to each battery algorithm module updating the non-volatile memory according to its corresponding update frequency, the number of updates to the non-volatile memory can be greatly reduced, thereby extending the service life of the non-volatile memory.

[0090] Optionally, the waiting time corresponding to each battery algorithm module can be obtained through a configuration file. It should be noted that the configuration file includes various parameter settings corresponding to the battery algorithm module. Exemplarily, after the kernel driver layer is loaded, the DTSI (Device Tree Source Include) configuration file will be parsed to obtain the waiting time of each battery algorithm module, that is, the longest update time of the target data that each battery algorithm module can tolerate, and the shortest waiting time will be determined as the first target time.

[0091] Exemplarily, at least one battery algorithm module includes a first battery algorithm module, a second battery algorithm module, a third battery algorithm module and a fourth battery algorithm module. The waiting time corresponding to the first battery algorithm module is 1 day, the waiting time corresponding to the second battery algorithm module is 2 days, the waiting time corresponding to the third battery algorithm module is 3 days, and the waiting time corresponding to the fourth battery algorithm module is 4 days. The shortest waiting time among all battery algorithm modules is 1 day. At this time, a fuel gauge update thread can be created and its operation cycle is set to 1 day. Among them, the fuel gauge update thread can be used to update the latest target data stored in the memory to the non-volatile memory.

[0092] In this embodiment, the first target duration is determined based on the waiting time corresponding to each battery algorithm module. While ensuring the reliability of the calculation results of the battery algorithm module, the number of updates of the non-volatile memory of the fuel meter can be reduced as much as possible, so as to extend the service life of the non-volatile memory as much as possible.

[0093] It should be noted that when the target condition includes that the number of times the target data stored in the memory is updated reaches a preset number, the electronic device may update the target data stored in the memory to the non-volatile memory when the number of times the target data stored in the memory is updated reaches a preset number, that is, after the target data in the memory is updated a preset number of times, the latest target data stored in the memory may be updated to the non-volatile memory, which can reduce the number of times the non-volatile memory is updated and extend the service life of the non-volatile memory.

[0094] It should be noted that when the target condition includes detecting that the battery voltage of the electronic device is less than the shutdown voltage threshold, the electronic device may update the target data stored in the fuel gauge when the battery voltage of the electronic device is detected to be less than the shutdown voltage threshold. The shutdown voltage threshold may be set according to actual conditions. When the voltage of the electronic device is less than the shutdown voltage threshold, it indicates that the battery power is too low and the electronic device may shut down automatically. In this embodiment, the electronic device may update the latest target data stored in the memory to the non-volatile memory before the electronic device automatically shuts down, so as to avoid the electronic device automatically shutting down and causing the loss of target data.

[0095] It should be noted that, when the target condition includes the duration of the battery voltage of the electronic device being detected to be less than the shutdown voltage threshold and reaching the second target duration, the electronic device may update the target data stored in the fuel gauge when the battery voltage of the electronic device is detected to be less than the shutdown voltage threshold and reaching the second target duration. The second target duration may be adjusted according to the actual situation of the device.

[0096] Exemplarily, the second target duration is determined based on the third target duration set by the electronic device. It should be noted that the electronic device will automatically shut down when the battery voltage of the electronic device is less than the shutdown voltage threshold and reaches the third target duration. Therefore, the second target duration can be determined based on the third target duration, wherein the second target duration is less than the third target duration, and the difference between the third target duration and the second target duration is less than or equal to the duration threshold. It should be noted that when the battery voltage is too low, that is, the power is too low, the user may charge the electronic device. Setting the second target duration as close to the third target duration as possible can reduce the number of updates to the fuel gauge. At the same time, it should also be ensured that the target data of the fuel gauge has been updated before the third target duration is reached to avoid the risk of target data loss in the memory.

[0097] Exemplarily, the difference between the third target duration and the second target duration may range from 4s (seconds) to 6s. Optionally, the difference between the third target duration and the second target duration may be 4s, 5s or 6s, etc. Exemplarily, if the range of the third target duration may include 55s to 65s, the range of the second target duration may include 50s to 60s. Optionally, the third target duration may be 55s, 60s or 65s, etc. Optionally, the second target duration may be 50s, 55s or 60s, etc.

[0098] Exemplarily, the shutdown voltage threshold may range from 3 V to 3.5 V. Optionally, the shutdown voltage threshold may be 3 V, 3.3 V, or 3.5 V, etc.

[0099] It should be noted that, when a shutdown operation for instructing the electronic device to shut down is detected, the electronic device may update the target data stored in the power meter when the shutdown operation for instructing the electronic device to shut down is detected. Exemplarily, the electronic device may include a shutdown key, and the shutdown operation may include the shutdown key being pressed. In another example, the electronic device may include a touch display screen, and the shutdown operation may include the touch track of the touch display screen satisfying a preset shutdown track.

[0100] In this embodiment, the electronic device updates the latest target data stored in the memory to the non-volatile memory of the fuel meter before shutting down and / or periodically, which can ensure that these target data can still be obtained from the non-volatile memory of the fuel meter after power failure, restart or abnormal shutdown, thereby greatly reducing the risk of target data loss and ensuring the working reliability of the battery algorithm module.

[0101] Step 308 , determining whether the latest target data stored in the memory is consistent with the target data stored in the non-volatile memory, if not, executing step 310 ; if yes, executing step 304 .

[0102] Exemplarily, when the latest target data stored in the memory is consistent with the target data stored in the non-volatile memory, the electronic device does not update the latest target data stored in the memory to the target data stored in the non-volatile memory.

[0103] It should be noted that the battery status may remain stable in a short period of time. When the target conditions are met, the battery status may not change much or even not change, that is, after being updated by at least one battery algorithm module, the updated target data may remain unchanged. Therefore, when the target conditions are met, the electronic device first determines whether the latest target data stored in the memory is consistent with the target data stored in the non-volatile memory, so as to avoid repeatedly writing the same target data to the non-volatile memory, further reduce the operation of the non-volatile memory, and extend the life of the non-volatile memory.

[0104] In some embodiments, for a target condition including a situation where the update duration for updating target data stored in a memory reaches a first target duration, when it is determined that the latest target data stored in the memory is consistent with the target data stored in a non-volatile memory, the update duration can be set to zero and the update duration can be recounted.

[0105] Step 310, updating the latest target data stored in the memory to the target data stored in the non-volatile memory.

[0106] It should be noted that, when the latest target data stored in the memory is inconsistent with the target data stored in the non-volatile memory, the latest target data stored in the memory is updated to the target data stored in the non-volatile memory to ensure the validity of the target data stored in the non-volatile memory. For the description of the step of updating the latest target data stored in the memory to the target data stored in the non-volatile memory, please refer to the description of step 208, which will not be repeated here.

[0107] In this embodiment, the electronic device first determines whether the latest target data stored in the memory is consistent with the target data stored in the non-volatile memory. When the latest target data stored in the memory is inconsistent with the target data stored in the non-volatile memory, the latest target data stored in the memory is updated to the non-volatile memory, thereby avoiding repeated writing of the same target data, ensuring the operational reliability of each battery algorithm module, and at the same time, minimizing the number of data writes, extending the life of the non-volatile memory, and reducing the use cost of the electronic device.

[0108] In some embodiments, the target condition may include that the update duration of updating the target data stored in the memory reaches a first target duration. By regularly updating the target data stored in the non-volatile memory of the fuel gauge, it is ensured that the latest target data is regularly saved to the non-volatile memory, so that when the electronic device is powered off, restarted, or abnormally shut down, the target data with a relatively recent time can be obtained, thereby avoiding the loss of target data and affecting the management effect of the battery, such as the low accuracy of the calculation result of the battery algorithm module.

[0109] Please refer to Figure 4 , which shows the third flow chart of a data processing method provided by an embodiment of the present application. In this embodiment, the target conditions include the update time for updating the target data stored in the memory reaching the first target time, detecting that the battery voltage of the electronic device is less than the shutdown voltage threshold for a continuous time, reaching the second target time, and detecting a shutdown operation for instructing the electronic device to shut down.

[0110] like Figure 4 As shown, the method may include steps 402 to 414.

[0111] Step 402, obtaining target data stored in the non-volatile memory of the electricity meter, and storing the target data in the internal memory.

[0112] Step 404: Update the target data stored in the memory through at least one battery algorithm module.

[0113] For the description of step 402 to step 404 , please refer to the description of step 202 to step 204 , which will not be repeated here.

[0114] Step 406 , determining whether the update duration for updating the target data stored in the memory reaches the first target duration, if so, executing steps 408 and 410 , if not, continuing to execute step 404 .

[0115] It should be noted that the update duration is the duration of updating the target data stored in the memory. For the description of the first target duration, please refer to the above embodiment, which will not be repeated here.

[0116] Exemplarily, the update duration may refer to the duration since the most recent update of the non-volatile memory of the fuel meter. By determining the update duration, it can be determined whether the target data stored in the non-volatile memory of the current fuel meter can still meet the real-time requirements of each battery algorithm module for the target data. When the update duration reaches the first target duration, the target data stored in the non-volatile memory of the fuel meter is updated, which can avoid the loss of target data due to the shutdown of the electronic device (especially abnormal shutdown), which affects the accuracy of the calculation results of the battery algorithm module, and ensure the effectiveness of battery management.

[0117] Exemplarily, the electronic device can implement timing through software or hardware, that is, determine the update duration. Among them, software timing is to measure time through program code, usually by an operating system, an application or a timer function. Hardware timing is to measure time through an independent hardware timer or timer module, such as the internal timer of the controller, the RTC (Real Time Clock) module, the external clock chip, etc.

[0118] Step 408, updating the latest target data stored in the memory to the non-volatile memory.

[0119] For the description of step 408 , reference may be made to the description of step 208 , which will not be repeated here.

[0120] In some embodiments, when the target conditions are met, the electronic device may remove access restrictions to the fuel meter, update the latest target data stored in the memory to the non-volatile memory, and restore access restrictions to the fuel meter.

[0121] It should be noted that in electronic devices, in order to ensure the security of the target data stored in the fuel meter and prevent accidental modification, the fuel meter usually sets access restrictions. This access restriction can prevent unauthorized access or data from being modified by mistake, but when the target conditions are met, it indicates that the target data stored in the fuel meter needs to be updated, so it is necessary to temporarily lift this access restriction so that the latest target data can be updated to the non-volatile memory of the fuel meter to ensure the reliability of the calculation results of the battery algorithm module.

[0122] In this embodiment, during the process of updating the target data stored in the memory through at least one battery algorithm module, access restrictions are imposed on the fuel meter to prevent the target data stored in the non-volatile memory of the fuel meter from being modified. Only when the target conditions are met, the latest target data stored in the memory is updated to the non-volatile memory, which can ensure that the target data stored in the non-volatile memory of the fuel meter meets the real-time requirements of each battery algorithm module for the target data.

[0123] In some embodiments, updating the latest target data stored in the memory to the non-volatile memory may include, when the target conditions are met, the electronic device may lift the access restriction on the fuel meter, update the latest target data stored in the memory to the target storage block in the non-volatile memory, and restore the access restriction on the fuel meter.

[0124] Optionally, updating the latest target data stored in the memory to the target storage block in the non-volatile memory may include erasing the data in the target storage block in the non-volatile memory, and then writing the latest target data stored in the memory to the target storage block in the non-volatile memory. It should be noted that each battery algorithm module can update the target data stored in the memory according to its corresponding update frequency. When the target conditions are met, the target data stored in the memory after being updated by each battery algorithm module can be written into the non-volatile memory through a one-time data erasure. Instead of each battery algorithm module erasing the data in the non-volatile memory separately and then writing them separately, the number of erasures of the non-volatile memory can be greatly reduced, and the life of the non-volatile memory can be greatly extended.

[0125] Step 410, set the update duration to zero, and re-count the update duration.

[0126] It should be noted that since the target data stored in the non-volatile memory is consistent with the latest target data stored in the internal memory, the update duration should be set to zero at this time so that each update cycle can be accurately identified, that is, it can be accurately determined that when the target data stored in the non-volatile memory is consistent with the latest target data stored in the internal memory, through at least one battery algorithm module, whether the duration for updating the target data stored in the internal memory reaches the first target duration again.

[0127] Exemplarily, after the latest target data stored in the memory is updated to the non-volatile memory, the target data stored in the memory may continue to be updated through at least one battery algorithm module to achieve real-time monitoring, optimization and protection of the battery.

[0128] Exemplarily, when the electronic device determines the first target duration, it may create a power meter update thread, and the cycle duration corresponding to the power meter update thread is the first target duration. Setting the update duration to zero may include setting the duration corresponding to the power meter update thread to zero. When the update duration reaches the first target duration, the power meter update thread updates the latest target data stored in the memory to the non-volatile memory, and sets the duration corresponding to the power meter update thread to zero.

[0129] Exemplarily, when the update duration of the fuel meter reaches the first target duration, the fuel meter update thread determines whether the latest target data stored in the memory is consistent with the target data stored in the non-volatile memory. If they are consistent, it indicates that the target data has not changed during this period, that is, there is no need to change the target data stored in the non-volatile memory of the fuel meter; if they are inconsistent, the fuel meter is unlocked (that is, the access restriction to the fuel meter is lifted), the latest target data stored in the memory is updated to the target storage block in the non-volatile memory, and then the fuel meter is re-locked (the access restriction to the fuel meter is restored), and the timing continues from zero.

[0130] In this embodiment, after the latest target data stored in the internal memory is updated to the non-volatile memory, the update duration is set to zero and the update duration is recounted so that each update cycle can be correctly identified to ensure that the non-volatile memory can be updated regularly.

[0131] Step 412, whether it is detected that the battery voltage of the electronic device is less than the shutdown voltage threshold for a continuous period of time and reaches the second target period of time, if so, execute steps 408 to 410, if not, execute step 404.

[0132] It should be noted that when it is detected that the battery voltage of the electronic device is less than the shutdown voltage threshold for a continuous period of time and reaches the second target time, it means that if the electronic device is not charged, the electronic device will be shut down. In this case, the latest target data stored in the memory is updated to the non-volatile memory, and the update time is set to zero, and the update time is recounted, so that before the third target time is reached, if the user charges the electronic device, that is, the electronic device will not be shut down at this time, the timing accuracy of the update time can also be guaranteed.

[0133] Step 414 , whether a shutdown operation for instructing the electronic device to shut down is detected, if so, execute step 408 ; if not, execute step 404 .

[0134] Exemplarily, when the electronic device detects a shutdown operation for instructing the electronic device to shut down, the electronic device updates the latest target data stored in the memory to the non-volatile memory, and controls the electronic device to shut down. In this embodiment, since the electronic device needs to shut down after updating the data in the non-volatile memory, the timing data will be cleared when the electronic device is turned off and then turned on, so the operation of setting the update duration to zero may not be performed, and when the electronic device is turned on again, the update duration will also be re-timed from zero.

[0135] In this embodiment, when the electronic device determines that the electronic device needs to be shut down, the latest target data stored in the memory can be updated to the non-volatile memory of the power meter, thereby avoiding the loss of the latest target data. At the same time, by regularly updating the latest target data stored in the memory to the non-volatile memory of the power meter, it can be avoided that in the case of abnormal shutdown of the electronic device, the power meter only stores the target data obtained a long time ago, thereby ensuring that the calculation results of each battery algorithm module are affected to a small extent.

[0136] Please refer to Figure 5 , which shows a fourth flow chart of a data processing method provided in an embodiment of the present application, such as Figure 5 As shown, the method may include steps 502 to 508.

[0137] Step 502: Acquire target data stored in the non-volatile memory of the electricity meter, and store the target data stored in the non-volatile memory in the first storage area and the second storage area respectively.

[0138] The memory includes a first storage area and a second storage area. Exemplarily, the data stored in the first storage area can be used for processing and calculation, and the second storage area is used for caching data. The first storage area can be used to store process state quantities obtained by processing at least one battery algorithm module. The data in the second storage area is maintained consistent with the target data stored in the non-volatile memory.

[0139] In some embodiments, the electronic device can read the target data stored in the non-volatile memory of the electricity meter, write the read target data into the second storage area, copy the target data stored in the second storage area, and write the copied target data into the first storage area, so as to store the target data stored in the non-volatile memory in the first storage area and the second storage area respectively. In this embodiment, by copying, the non-volatile memory of the electricity meter is accessed once, so that the first storage area and the second storage area are both stored with the target data, the target data stored in the first storage area meets the requirement of updating the target data, and the target data stored in the second storage area is kept consistent with the target data stored in the non-volatile memory, so that by judging whether the latest target data stored in the first storage area is consistent with the target data stored in the second storage area, it is possible to judge whether the latest target data stored in the first storage area is consistent with the target data stored in the non-volatile memory of the electricity meter, thereby reducing the number of accesses to the electricity meter and reducing the time spent on unlocking.

[0140] Step 504: Update the target data stored in the first storage area through at least one battery algorithm module.

[0141] It should be noted that the description of step 504 may refer to the description of step 404 and will not be repeated here.

[0142] Exemplarily, according to the update frequency corresponding to the target battery algorithm module, the target sub-data corresponding to the target battery algorithm module is read from the storage space corresponding to the target battery algorithm module in the first storage area, the read target sub-data is updated through the target battery algorithm module, and the updated target sub-data is written into the storage space corresponding to the target battery algorithm module in the first storage area to update the target data stored in the first storage area.

[0143] Step 506, determine whether the target condition is met, if so, execute step 508, if not, execute step 504.

[0144] For the description of step 506 , please refer to the description of step 406 , which will not be repeated here in this embodiment.

[0145] Step 508 , determining whether the latest target data stored in the first storage area is consistent with the target data stored in the second storage area, if so, executing step 504 , if not, executing step 510 .

[0146] It should be noted that by judging whether the latest target data stored in the first storage area is consistent with the target data stored in the second storage area, it can be determined whether the latest target data stored in the first storage area is consistent with the target data stored in the non-volatile memory of the power meter, so as to determine whether it is necessary to update the latest target data stored in the first storage area to the non-volatile memory. While ensuring the accuracy of the judgment, the number of accesses to the non-volatile memory of the power meter can be reduced.

[0147] In some embodiments, if the first data corresponding to the target byte in the first storage area is inconsistent with the second data corresponding to the target byte in the second storage area, it is determined that the latest target data stored in the first storage area is inconsistent with the target data stored in the second storage area. Wherein, the target byte is any byte, and if the first data corresponding to each byte is consistent with the second data corresponding to the corresponding byte, it is determined that the latest target data stored in the first storage area is consistent with the target data stored in the second storage area. Wherein, the first data corresponding to the target byte refers to the data located at the target byte in the first storage area, and the second data corresponding to the target byte refers to the data located at the target byte in the second storage area. In this embodiment, by comparing the contents of the two storage areas byte by byte to check whether they are equal, until different bytes are found or all data are compared, it is determined whether the latest target data stored in the first storage area is consistent with the target data stored in the second storage area, so as to ensure the accuracy of the judgment result.

[0148] In other embodiments, a first hash value corresponding to the latest target data stored in the first storage area is calculated, and a second hash value corresponding to the target data stored in the second storage area is calculated. If the first hash value is consistent with the second hash value, it is determined that the latest target data stored in the first storage area is consistent with the target data stored in the second storage area. If the first hash value is inconsistent with the second hash value, it is determined that the latest target data stored in the first storage area is inconsistent with the target data stored in the second storage area. Among them, the first hash value is a hash value corresponding to the latest target data stored in the storage area, and the second hash value is a hash value corresponding to the target data stored in the second storage area. In this embodiment, by calculating the first hash value and the second hash value, and comparing the first hash value and the second hash value, the efficiency of determining whether the latest target data stored in the first storage area is consistent with the target data stored in the second storage area can be improved.

[0149] It is understandable that in addition to the method provided in the above embodiment, other methods may be used to determine whether the latest target data stored in the first storage area is consistent with the target data stored in the second storage area. This embodiment does not specifically limit this, as long as it can be determined whether the latest target data stored in the first storage area is consistent with the target data stored in the second storage area.

[0150] Step 510: Update the latest target data stored in the first storage area to the non-volatile memory.

[0151] It should be noted that the description of step 510 may refer to the description of step 410 and will not be repeated here.

[0152] Exemplarily, when the latest target data stored in the first storage area is inconsistent with the target data stored in the second storage area, updating the latest target data stored in the first storage area to the non-volatile memory may include, when the latest target data stored in the first storage area is inconsistent with the target data stored in the second storage area, updating the target data stored in the second storage area to the latest target data stored in the first storage area, and updating the updated target data stored in the second storage area to the non-volatile memory.

[0153] In this embodiment, it is possible to ensure that the data stored in the second storage area is consistent with the target data stored in the non-volatile memory of the power meter, and to ensure that the latest target data stored in the first storage area is consistent with the judgment result of the target data stored in the second storage area, the latest target data stored in the first storage area, and the comparison result with the target data stored in the non-volatile memory, thereby ensuring the reliability of the update.

[0154] In this embodiment, by setting the first storage area and the second storage area, it is possible to determine whether the latest target data stored in the first storage area is consistent with the target data stored in the non-volatile memory of the power meter by comparing the latest target data stored in the first storage area with the target data stored in the second storage area. There is no need to unlock the power meter and obtain the target data stored in the non-volatile memory of the power meter again for comparison, which improves the update efficiency and reduces the risk of the power meter being accidentally overwritten.

[0155] Please refer to Figure 6 , which shows the fifth flow chart of a data processing method provided in an embodiment of the present application. In this embodiment, there are three battery algorithm modules, namely a first battery algorithm module, a second battery algorithm module and a third battery algorithm module. The electronic device can be a mobile phone, and the mobile phone includes a SoC.

[0156] like Figure 6 As shown, the method may include steps 602 to 636.

[0157] Step 602, the mobile phone starts.

[0158] Step 604 , the SoC reads the target data of the target storage block of the Flash memory of the fuel meter into the second storage area in the memory through the I2C communication protocol to obtain the first target data A.

[0159] Exemplarily, the target data is 32 bytes of data.

[0160] Step 606: The SoC copies the first target data A to the first storage area in the memory to obtain the second target data B.

[0161] Step 608, the first battery algorithm module reads the sub-data corresponding to the first battery algorithm module in the second target data B, initializes the relevant variables of the first battery algorithm module according to the sub-data, and sends the calculated sub-data to the kernel driver layer.

[0162] Step 610, the second battery algorithm module reads the sub-data corresponding to the second battery algorithm module in the second target data B, initializes the relevant variables of the second battery algorithm module according to the sub-data, and sends the calculated sub-data to the kernel driver layer.

[0163] Step 612, the third battery algorithm module reads the sub-data corresponding to the third battery algorithm module in the second target data B, initializes the relevant variables of the third battery algorithm module according to the sub-data, and sends the calculated sub-data to the kernel driver layer.

[0164] Step 614: the kernel driver layer maps the received sub-data sent by each battery algorithm module to the storage space in the first storage area corresponding to each battery algorithm module.

[0165] Step 616 , determining whether the duration corresponding to the power meter update thread reaches the first target duration, if so, executing step 618 ; if not, continuing to execute step 616 .

[0166] In this embodiment, the mobile phone can detect in real time whether the duration corresponding to the power meter update thread reaches the first target duration.

[0167] Step 618, determine whether the second target data B is consistent with the first target data A, if not, execute steps 620 to 622; if yes, execute step 622.

[0168] Step 620 , update the first target data A to the second target data B, unlock the electricity meter, then set the second target data B to the target storage block in the Flash memory of the electricity meter, and then lock the electricity meter.

[0169] Step 622, setting the duration corresponding to the power meter update thread to 0.

[0170] Step 624, determine whether the duration that the battery voltage is less than the shutdown voltage threshold reaches the second target duration, if so, execute step 626; if not, continue to execute step 624.

[0171] It should be noted that the mobile phone can detect in real time whether the duration of the battery voltage being less than the shutdown voltage threshold reaches the second target duration. When the duration of the battery voltage being less than the shutdown voltage threshold reaches the third target duration, the mobile phone shuts down.

[0172] Step 626 , determining whether the second target data B is consistent with the first target data A, if not, executing step 628 .

[0173] Exemplarily, if the second target data B is the same as the first target data A, the mobile phone does not execute the update of the first target data A to the second target data B, unlocks the power meter, and then sets the second target data B to the target storage block in the Flash memory of the power meter, and then locks the power meter. If the second target data B is the same as the first target data A, the mobile phone can choose to set the duration corresponding to the power meter update thread to 0, that is, the mobile phone can set the duration corresponding to the power meter update thread to 0, or it can not set the duration corresponding to the power meter update thread to 0.

[0174] Step 628, update the first target data A to the second target data B, unlock the fuel meter, then set the second target data B to the target storage block in the Flash memory of the fuel meter, then lock the fuel meter, and set the duration corresponding to the fuel meter update thread to 0.

[0175] Step 630, determine whether the power off button is pressed, if so, execute step 632; if not, continue to execute step 630.

[0176] It should be noted that the mobile phone can detect in real time whether the power off button is pressed.

[0177] Step 632, determine whether the second target data B is consistent with the first target data A, if not, execute steps 634 to 636; if yes, execute step 636.

[0178] Step 634 , update the first target data A to the second target data B, unlock the electricity meter, then set the second target data B to the target storage block in the Flash memory of the electricity meter, and then lock the electricity meter.

[0179] Step 636, turn off the mobile phone.

[0180] In this embodiment, the fuel meter operation Flash memory can be periodically unlocked according to the first target time, which can greatly reduce the life risk and the risk of being accidentally overwritten; at the same time, by uniformly managing the Flash memory of the fuel meter operated by each battery algorithm module, the risk of battery overcharging caused by jamming during concurrent operation of each battery algorithm module can be effectively avoided, and the problem of reduced service life of the Flash memory due to high-frequency unlocking of the fuel meter by different battery algorithm modules can be effectively solved. The risk of data stored in the Flash memory being accidentally overwritten can also be greatly reduced, and the problem of battery overcharging caused by jamming due to waiting for the fuel meter to be unlocked when different battery algorithm modules are running concurrently can be effectively solved.

[0181] Please refer to Figure 7 , which shows a schematic diagram of the structure of a data processing device disclosed in an embodiment of the present application. The device can be applied to an electronic device. The electronic device may include but is not limited to a laptop computer, a tablet computer, a smart wearable device, a digital camera, a mobile phone, etc. The electronic device may include a power meter and a memory, and the power meter may include a non-volatile memory.

[0182] like Figure 7 As shown, the data processing device 700 may include an acquisition module 710, a first update module 720, and a second update module 730. The acquisition module 710 is used to acquire target data stored in a non-volatile memory of the fuel gauge and store the target data in the memory. The first update module 720 is used to update the target data stored in the memory through at least one battery algorithm module. The second update module 730 is used to update the latest target data stored in the memory to the non-volatile memory when the target condition is met.

[0183] In some embodiments, the target condition includes at least one of the following:

[0184] The update duration of updating the target data stored in the memory reaches a first target duration;

[0185] The target data stored in the memory is updated a preset number of times;

[0186] It is detected that the battery voltage of the electronic device is less than the shutdown voltage threshold;

[0187] Detecting that the duration for which the battery voltage of the electronic device is less than the shutdown voltage threshold reaches a second target duration;

[0188] A shutdown operation for instructing the electronic device to shut down is detected.

[0189] In some embodiments, the first target duration is determined according to the waiting duration corresponding to each battery algorithm module, and the waiting duration is used to characterize the real-time requirements of the corresponding battery algorithm module for the target data.

[0190] In some embodiments, the target condition includes that the update duration of updating the target data stored in the memory reaches a first target duration. The data processing device 700 may also include a zeroing module. The zeroing module is used to set the update duration to zero and recount the update duration after the latest target data stored in the memory is updated to the non-volatile memory.

[0191] In some embodiments, the second update module 730 includes a judgment unit and a first update unit. The judgment unit is used to judge whether the latest target data stored in the memory is consistent with the target data stored in the non-volatile memory. The first update unit is used to update the latest target data stored in the memory to the non-volatile memory if the latest target data stored in the memory is inconsistent with the target data stored in the non-volatile memory.

[0192] In some embodiments, the memory includes a first storage area and a second storage area. The acquisition module 710 includes a storage unit, the first update module 720 includes a second update unit, and the judgment unit includes a judgment subunit and a determination subunit. The storage unit is used to store the target data stored in the non-volatile memory in the first storage area and the second storage area, respectively. The second update unit is used to update the target data stored in the first storage area through at least one battery algorithm module. The judgment subunit is used to determine whether the latest target data stored in the first storage area is consistent with the target data stored in the second storage area. The determination subunit is used to determine that the latest target data stored in the memory is inconsistent with the target data stored in the non-volatile memory if the latest target data stored in the first storage area is inconsistent with the target data stored in the second storage area.

[0193] In some embodiments, the target data includes sub-data corresponding to at least one battery algorithm module. The first update module 720 includes a reading unit and a third update unit. The reading unit is used to read the target sub-data corresponding to the target battery algorithm module from the storage space corresponding to the target battery algorithm module in the memory; wherein the target battery algorithm module is one of the at least one battery algorithm module. The third update unit is used to update the read target sub-data through the target battery algorithm module, and write the updated target sub-data into the memory, in the storage space corresponding to the target battery algorithm module.

[0194] In some embodiments, the first update module 720 includes a fourth update unit. The fourth update unit is used to update the target data stored in the memory through the target battery algorithm module according to the update frequency corresponding to the target battery algorithm module, and the target battery algorithm module is one of the at least one battery algorithm module.

[0195] In some embodiments, the second update module 730 includes an unlocking unit, a fifth updating unit, and a locking unit. The unlocking unit is used to release the access restriction to the fuel gauge. The fifth updating unit is used to update the latest target data stored in the memory to the non-volatile memory. The locking unit is used to restore the access restriction to the fuel gauge.

[0196] In some embodiments, the acquisition module 710 includes an acquisition unit, and the second update module 730 includes a sixth update unit. The acquisition unit is used to acquire the target data stored in the target storage block in the non-volatile memory of the power meter. The sixth update unit is used to update the latest target data stored in the memory to the target storage block in the non-volatile memory.

[0197] In an embodiment of the present application, the electronic device may include a fuel meter and a memory, the fuel meter may include a non-volatile memory, and the data processing device includes an acquisition module 710, a first update module 720, and a second update module 730. The acquisition module 710 may acquire target data stored in the non-volatile memory of the fuel meter and store the target data in the memory, the first update module 720 updates the target data stored in the memory through at least one battery algorithm module, and the second update module 730 updates the latest target data stored in the memory to the non-volatile memory when the target condition is met, which can reduce the number of operations of the battery algorithm module on the non-volatile memory, while ensuring the validity of the data stored in the non-volatile memory in the fuel meter, the service life of the non-volatile memory of the fuel meter can be extended, and the risk of the data in the non-volatile memory being accidentally rewritten can be reduced, thereby improving the stability of the non-volatile memory.

[0198] See also Figure 8 , Figure 8 Schematic diagram of the structure of an electronic device disclosed in the embodiment of the present application. Figure 8 As shown, the electronic device 800 may include:

[0199] Fuel meter 810;

[0200] Memory 820;

[0201] A memory 830 storing executable program codes;

[0202] a processor 840 coupled to the memory 830;

[0203] The processor 840 calls the executable program code stored in the memory 830 to execute any data processing method disclosed in the embodiments of the present application.

[0204] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by the processor, the processor implements any one of the data processing methods disclosed in the embodiment of the present application.

[0205] An embodiment of the present application discloses a program product, including a computer program. When the computer program is executed by the processor, the processor implements any data processing method disclosed in the embodiment of the present application.

[0206] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required for the present application.

[0207] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0208] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0209] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0210] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several requests for a computer device (which can be a personal computer, a server or a network device, etc., specifically a processor in a computer device) to perform some or all of the steps of the above-mentioned methods of various embodiments of the present application.

[0211] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0212] The above is a detailed introduction to a data processing method, device, electronic device and storage medium disclosed in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. At the same time, for those of ordinary skill in the art, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A data processing method, characterized in that: Applied to an electronic device, the electronic device includes a power meter and a memory, the power meter includes a non-volatile memory; the method includes: Acquire target data stored in the non-volatile memory of the electricity meter, and store the target data in the memory; updating the target data stored in the memory through at least one battery algorithm module; When the target condition is met, the latest target data stored in the memory is updated to the non-volatile memory.

2. The method according to claim 1, characterized in that: The target condition includes at least one of the following: The update duration for updating the target data stored in the memory reaches a first target duration; The target data stored in the memory is updated a preset number of times; Detecting that the battery voltage of the electronic device is less than a shutdown voltage threshold; Detecting that the duration for which the battery voltage of the electronic device is less than the shutdown voltage threshold reaches a second target duration; A shutdown operation for instructing the electronic device to shut down is detected.

3. The method according to claim 2, characterized in that The first target duration is determined according to the waiting duration corresponding to each of the battery algorithm modules, and the waiting duration is used to characterize the real-time requirements of the corresponding battery algorithm module for target data.

4. The method according to claim 2, characterized in that: The target condition includes that the update duration for updating the target data stored in the memory reaches a first target duration; After updating the latest target data stored in the memory to the non-volatile memory, the method further includes: The update duration is set to zero, and the update duration is counted again.

5. The method according to claim 1, characterized in that The updating of the latest target data stored in the memory to the non-volatile memory includes: Determining whether the latest target data stored in the memory is consistent with the target data stored in the non-volatile memory; If they are inconsistent, the latest target data stored in the memory is updated to the non-volatile memory.

6. The method according to claim 5, characterized in that The memory includes a first storage area and a second storage area; The storing the target data in the memory comprises: storing the target data stored in the non-volatile memory in the first storage area and the second storage area respectively; The updating of the target data stored in the memory by at least one battery algorithm module includes: updating the target data stored in the first storage area through at least one battery algorithm module; The determining whether the latest target data stored in the memory is consistent with the target data stored in the non-volatile memory includes: Determining whether the latest target data stored in the first storage area is consistent with the target data stored in the second storage area; If not, it is determined that the latest target data stored in the memory is inconsistent with the target data stored in the non-volatile memory.

7. The method according to claim 1, characterized in that The target data includes sub-data corresponding to the at least one battery algorithm module respectively; The updating of the target data stored in the memory by at least one battery algorithm module includes: Reading target sub-data corresponding to the target battery algorithm module from a storage space corresponding to the target battery algorithm module in the memory; wherein the target battery algorithm module is one of the at least one battery algorithm module; The read target sub-data is updated through the target battery algorithm module, and the updated target sub-data is written into the memory, in the storage space corresponding to the target battery algorithm module.

8. The method according to claim 1, characterized in that The updating of the target data stored in the memory by at least one battery algorithm module includes: The target data stored in the memory is updated by a target battery algorithm module according to an update frequency corresponding to the target battery algorithm module, and the target battery algorithm module is one of the at least one battery algorithm module.

9. The method according to any one of claims 1 to 8, characterized in that: The updating of the latest target data stored in the memory to the non-volatile memory includes: Unrestricting access to the fuel gauge; Updating the latest target data stored in the memory to the non-volatile memory; Restore access restrictions to the fuel gauge.

10. The method according to claim 1, characterized in that The acquiring target data stored in the non-volatile memory of the electricity meter comprises: Acquire target data stored in a target storage block in a non-volatile memory of the electricity meter; The updating of the latest target data stored in the memory to the non-volatile memory includes: The latest target data stored in the memory is updated to the target storage block in the non-volatile memory.

11. A data processing device, characterized in that: Applied to an electronic device, the electronic device includes a power meter and a memory, the power meter includes a non-volatile memory; the device includes: An acquisition module, used for acquiring target data stored in the non-volatile memory of the electricity meter, and storing the target data in the memory; A first updating module, configured to update the target data stored in the memory through at least one battery algorithm module; The second updating module is used to update the latest target data stored in the memory to the non-volatile memory when the target condition is met.

12. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor implements the method according to any one of claims 1 to 10.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.