A method for upgrading the firmware of an electric meter, an electronic device and a storage medium

The online firmware upgrade of the battery meter is solved by controlling the battery meter to upgrade the battery meter firmware in the existing technology, and the optimization calculation of battery meter and health parameters is realized, and the user experience is improved.

CN118444946BActive Publication Date: 2025-04-25HONOR DEVICE CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202311816964.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-26
Publication Date
2025-04-25
Estimated Expiration
2043-12-26

AI Technical Summary

Technical Problem

The firmware of the battery meter in existing electronic devices cannot be upgraded online, and cannot meet the optimization needs of battery power and health parameter calculations brought about by hardware iteration and software diversification.

Method used

The battery meter is controlled to enter full access mode through the processor, back up the current discharge depth and battery chemical capacity data, enter the upgrade mode and write new firmware data, and send the backup data after reset to initialize the power calculation method to ensure the continuity of the power percentage.

Benefits of technology

The online upgrade of the battery meter firmware has been realized, and the calculation methods of battery power and health parameters have been optimized, which has avoided a significant jump in the battery percentage and improved the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118444946B_ABST
    Figure CN118444946B_ABST
Patent Text Reader

Abstract

A method for upgrading the firmware of an electric meter, an electronic device and a storage medium, and relates to the field of terminal technology. The method comprises: a processor sends a backup instruction to the electric meter, and controls the electric meter to enter a full access mode, the backup instruction is used to instruct the electric meter to send backup data to the processor, and the backup data includes the current discharge depth and the current battery chemical capacity; the electric meter is controlled to enter an upgrade mode and firmware data is written to the electric meter; when the upgrade firmware data is written, the electric meter is controlled to exit the upgrade mode. When the electric meter is reset, the backup data is sent to the electric meter. The electric meter is reset after the firmware upgrade is completed; the electric meter receives the backup data sent by the processor, and uses the backup data as the initial data of the electric quantity calculation method. By using this solution, the online firmware upgrade of the electric meter is realized, and it can ensure that the electric quantity before and after the upgrade does not jump, thereby ensuring the user's power consumption experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a firmware upgrade method for an electricity meter, an electronic device, and a storage medium. Background Art

[0002] At present, battery-powered electronic devices generally use fuel gauges to monitor batteries and obtain battery power. The integrated circuit (IC) of the fuel gauge can collect information such as battery cell voltage, battery cell temperature, and battery cell current, calculate battery power (state of charge, SOC), health (state of health, SOH) and other information through Coulomb integration and battery modeling, and communicate with external processors.

[0003] However, the fuel gauges on current electronic devices have the fuel gauge firmware code directly burned into the fuel gauge IC when the device leaves the factory, and the fuel gauge firmware is generally not upgraded when the electronic device performs software upgrades. However, with the iteration of hardware circuits in electronic devices and the diversification of software applications, in order to more accurately obtain battery power, health, full charge capacity (FCC) and other parameters, and optimize the calculation method of parameters, there is also a need to upgrade the fuel gauge firmware. Summary of the invention

[0004] In order to solve the above problems, the present application provides a method for upgrading the firmware of an electric meter, an electronic device and a storage medium, which realize online firmware upgrading of the electric meter.

[0005] In a first aspect, the present application provides a method for upgrading the firmware of a fuel meter, which is applied to a processor, and includes: issuing a backup instruction to the fuel meter, and controlling the fuel meter to enter a full access mode, wherein the backup instruction is used to instruct the fuel meter to send backup data to the processor, wherein the backup data includes a current depth of discharge and a current battery chemical capacity; controlling the fuel meter to enter an upgrade mode and writing firmware data to the fuel meter; when the upgrade firmware data is written, controlling the fuel meter to exit the upgrade mode; and when the fuel meter is reset, sending backup data to the fuel meter.

[0006] The solution provided by the present application can realize online upgrade of the power meter of the electronic device by controlling the processor. For example, the power meter firmware can be upgraded while the electronic device upgrades the system to meet the current online upgrade requirements of the power meter. In addition, before the power meter firmware is upgraded, the backup data is obtained in advance, and the relevant backup data is rewritten into the power meter after the power meter firmware is updated, so that the power meter uses the backup data as the initial data of the power calculation method to initialize the power calculation method, so that the power percentage determined by the power meter after the firmware update is the same as that before the firmware update or there is no obvious jump, which improves the user experience.

[0007] In a possible implementation, sending a backup instruction to the power meter specifically includes: reading an operating mode of the power meter; when the operating mode is a user mode and the version number of the firmware data is greater than the current firmware version number of the power meter, sending a backup instruction to the power meter.

[0008] The working modes of the fuel gauge include upgrade mode and non-upgrade mode. The upgrade mode is also the in-system programming (ISP) mode. The non-upgrade mode is also the user mode, in which the fuel gauge has not started the firmware upgrade.

[0009] In one possible implementation, writing firmware data to the power meter specifically includes: performing firmware data write exception detection when writing firmware data to the power meter; when the firmware data write exception detection determines that a first part of the firmware data is written abnormally, rewriting the first part of the firmware data; when the writing or rewriting of the first part of the firmware data fails, controlling the power meter to re-enter upgrade mode.

[0010] This implementation improves the probability of successful firmware upgrade of the fuel gauge.

[0011] In a possible implementation, the method further includes: when the firmware data write anomaly detection determines that the cumulative number of write anomalies is greater than a preset number, controlling the power meter to exit the upgrade mode.

[0012] In this implementation, since the firmware data writing of the power meter continues to be abnormal for many times, in order to prevent the device from abnormally failing due to repeated firmware data writing, the upgrade mode can be exited. At this time, the power meter can be reset and the power calculation method of the firmware version before the upgrade can be used to re-detect the power percentage.

[0013] In a possible implementation, when the working mode of the electricity meter is the upgrade mode, the method further includes:

[0014] Write firmware data to the fuel gauge;

[0015] When the upgrade firmware data is written and the electricity meter is reset, the backup data is sent to the electricity meter.

[0016] In this implementation, the upgrade process of the fuel meter firmware is abnormally interrupted. The reasons for the interruption may be that the electronic device is out of power, the network is disconnected, the user actively restarts the electronic device, etc. When the electronic device is turned on again, it is necessary to continue to upgrade the fuel meter firmware. In this implementation, the working mode of the fuel meter that the processor can directly read is the upgrade mode, that is, the ISP mode, and the processor directly writes the firmware data to the fuel meter for firmware upgrade.

[0017] In one possible implementation, the backup data also includes a battery status, which is used to indicate the charging or discharging behavior before the battery firmware is updated, the change in power caused by the charging or discharging behavior, and the power before and after the charging or discharging behavior.

[0018] In a second aspect, the present application provides a method for upgrading the firmware of a fuel meter, which is applied to the fuel meter, and the method includes the following steps: after receiving a backup instruction sent by a processor, sending backup data to the processor, the backup data including the current discharge depth and the current battery chemical capacity; entering an upgrade mode and upgrading the firmware according to the firmware data sent by the processor; resetting when the firmware upgrade is completed; receiving the backup data sent by the processor, and using the backup data as the initial data for the fuel calculation method.

[0019] The solution provided by the present application enables the fuel meter of the electronic device to be upgraded online under the control of the processor. For example, the fuel meter firmware can be upgraded while the electronic device upgrades the system to meet the current fuel meter online upgrade requirements. In addition, before the fuel meter firmware is upgraded, backup data is acquired in advance and sent to the processor so that the processor stores the backup data in a memory or other registers. After the fuel meter firmware is updated, the backup data is received and used as the initial data of the fuel calculation method to initialize the fuel calculation method, so that the fuel meter after the firmware update determines the power percentage the same as before the firmware update or there is no obvious jump, thereby improving the user experience.

[0020] In a possible implementation, entering the upgrade mode and performing the upgrade according to the firmware data sent by the processor specifically includes: entering the upgrade mode and reporting an upgrade event to the processor so that the processor starts writing the firmware data; and performing the upgrade according to the firmware data sent by the processor.

[0021] In a possible implementation, backup data sent by a processor is received and used as initial data for an electric quantity calculation method, specifically including: starting a timer after a reset is completed; and when backup data is obtained before the timer expires, using the backup data as initial data for the electric quantity calculation method.

[0022] In a possible implementation, when the timer expires and the backup data is not obtained, the method further includes: initializing a power calculation method and determining a power percentage RSOC.

[0023] In one possible implementation, the backup data also includes a battery status, which is used to indicate the charging or discharging behavior before the battery firmware is updated, the change in power caused by the charging or discharging behavior, and the power before and after the charging or discharging behavior.

[0024] In a third aspect, the present application further provides an electronic device, the electronic device comprising a processor and a fuel gauge chip, and also comprising a memory. The fuel gauge chip stores fuel gauge firmware. The processor is used to call the program stored in the memory to implement the fuel gauge firmware upgrade method provided by the first aspect and any one of the implementations of the first aspect when executing. The fuel gauge chip is used to implement the fuel gauge firmware upgrade method provided by the second aspect and any one of the implementations of the second aspect.

[0025] In a fourth aspect, the present application also provides a storage medium on which a computer program is stored. When the computer program is executed by a processor of an electronic device, the firmware upgrade method provided by the first aspect and any one of the implementations of the first aspect is implemented, or the firmware upgrade method provided by the second aspect and any one of the implementations of the second aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 A flowchart of a method for upgrading the firmware of an electric meter provided in an embodiment of the present application;

[0027] Figure 2 Schematic diagram of the principle provided by the embodiment of this application Figure 1 ;

[0028] Figure 3 Scenario diagram provided for the embodiment of this application Figure 1 ;

[0029] Figure 4 A flowchart of another method for upgrading the firmware of an electric meter provided in an embodiment of the present application;

[0030] Figure 5 A flowchart of a firmware upgrade method for another power meter provided in an embodiment of the present application;

[0031] Figure 6 A schematic diagram of an electronic device provided in an embodiment of the present application;

[0032] Figure 7 A schematic diagram of a software structure provided for an embodiment of the present application. DETAILED DESCRIPTION

[0033] In order to enable persons skilled in the art to more clearly understand the solution of the present application, the application scenario of the technical solution of the present application is first described below.

[0034] The battery fuel gauge can perform the following functions:

[0035] Monitor battery voltage, current, and temperature, and provide them to external systems to facilitate system application decision-making and facilitate safe and accurate charge and discharge control and management;

[0036] Predict the remaining capacity (RC), full charge capacity (FCC), and state of charge (SOC).

[0037] Predict battery state of health (SOH) to facilitate system decision-making on battery recycling or replacement;

[0038] Provide battery safety warning and protection, such as overcharge, over discharge, high temperature, over current, short circuit protection, etc.

[0039] The battery fuel gauge can also perform other functions, which will not be described here one by one.

[0040] At present, the electricity meters on electronic devices have the electricity meter firmware code directly burned into the electricity meter IC when the device leaves the factory. When the electronic device performs software upgrades later, the firmware of the electricity meter is generally not upgraded. However, with the iteration of hardware circuits in electronic devices and the diversification of software applications, there is also a need to upgrade the firmware of the electricity meter. Therefore, the present application provides a method for upgrading the firmware of the electricity meter, an electronic device and a storage medium. By controlling the electricity meter to enter full access mode through a processor and writing firmware data to the processor, the electronic device can support the upgrade of the firmware of the electricity meter. In addition, the backup data is pre-saved outside the electricity meter before the firmware upgrade, and the backup data is re-written into the electricity meter after the firmware upgrade, so that the electricity quantity of the electricity meter does not jump before and after the firmware upgrade, thereby ensuring the user's electricity consumption experience.

[0041] The following is a detailed description with reference to the accompanying drawings.

[0042] See also Figure 1, which is a flow chart of a method for upgrading the firmware of a power meter provided in an embodiment of the present application.

[0043] The method comprises the following steps:

[0044] S11: The processor sends a backup instruction to the fuel meter and controls the fuel meter to enter the full access mode.

[0045] In one possible implementation, the upgrade of the fuel gauge firmware can be performed along with the upgrade of the entire electronic device. The electronic device can use over-the-air (OTA) technology to upgrade the system. If the upgrade package of the system includes an updated version of the fuel gauge firmware, after upgrading the system software, the electronic device can be restarted to upgrade the new fuel gauge firmware during the startup phase.

[0046] See also Figure 2 , which is a schematic diagram of the principle provided by the embodiment of the present application Figure 1 .

[0047] For battery safety and information security, the fuel gauge is generally set with three security modes: sealed mode, unsealed mode and full access mode.

[0048] In full access mode, the firmware of the fuel gauge can be burned or exported.

[0049] In unlocked and locked modes, the fuel gauge firmware cannot be burned or exported.

[0050] In a possible implementation, both full access mode and unlocked mode can directly enter locked mode. Locked mode can only enter unlocked mode first, and then enter full access mode from unlocked mode. Taking the example of controlling the fuel meter to switch from locked mode to full access mode, first send the password of unlocked mode to ManufacturerAccess() to control the fuel meter to enter unlocked mode. When the fuel meter enters unlocked mode, send the password of full access mode to ManufacturerAccess() to control the fuel meter to enter full access mode.

[0051] ManufacturerAccess() is a read / write SBS command. This behavior is defined by the manufacturer and will not be described in detail here.

[0052] When the fuel gauge firmware needs to be updated, the processor first sends a backup instruction to the fuel gauge. The backup instruction is used to instruct the fuel gauge to send backup data to the processor, and the backup data includes the current depth of discharge and the current battery chemical capacity. The backup data is used as the initial data of the fuel gauge algorithm after the fuel gauge firmware update is completed and reset is completed.

[0053] The processor in the embodiment of the present application may be an audio data signal processor (ADSP) or other types of processors, and the embodiment of the present application does not specifically limit this.

[0054] S12: After receiving the backup instruction sent by the processor, the fuel meter sends the backup data to the processor.

[0055] After receiving the backup instruction, the fuel gauge firmware backs up the current depth of discharge (DoD), battery chemical capacity (qmax) and other information related to the battery status, forms backup data and sends it to the processor so that the processor can save the backup data.

[0056] S13: The processor controls the fuel gauge to enter an upgrade mode and writes firmware data to the fuel gauge.

[0057] The working mode of the fuel gauge generally includes two frames, one is the user mode, that is, the normal working mode, and the other is the upgrade mode, which is also the in-system programming (ISP) mode.

[0058] ISP mode means that blank devices on the circuit board can be programmed with user code without removing the device from the circuit board. Programmed devices can also be erased or reprogrammed using ISP without leaving the system.

[0059] The updated firmware data can be written into the fuel gauge only after the processor controls the fuel gauge to be in ISP mode.

[0060] S14: The fuel gauge enters an upgrade mode and performs a firmware upgrade according to the firmware data sent by the processor.

[0061] S15: After the firmware upgrade data is written, the processor controls the power meter to exit the upgrade mode.

[0062] The firmware data sent by the processor to the electricity meter may include multiple frames of data. When the processor confirms that all frames of data are sent successfully, it determines that the writing of the upgraded firmware data is completed.

[0063] The processor controls the fuel gauge to exit the upgrade mode and enter the user mode.

[0064] S16: The fuel gauge exits the upgrade mode and resets when the firmware upgrade is completed.

[0065] When the fuel gauge firmware upgrade is complete, the processor exits the ISP mode and resets the fuel gauge. After the fuel gauge is reset, it enters the user mode.

[0066] S17: The processor sends the backup data to the fuel meter after the fuel meter is reset.

[0067] In one possible implementation, the processor may be provided with a timer. When the processor controls the fuel meter to exit the upgrade mode, the timer is started to count. The length of time counted by the timer is greater than the time required to reset the fuel meter. When the timer ends, it is considered that the fuel meter reset is completed. At this time, the processor sends backup data to the fuel meter.

[0068] The embodiment of the present application does not specifically limit the timing time of the timer, for example, it can be set to 2 seconds.

[0069] S18: The electricity meter receives the backup data sent by the processor and uses the backup data as initial data for the electricity calculation method.

[0070] The purpose of the power meter using the backup data as the initial data of the power calculation method is to ensure that the power does not jump before and after the firmware upgrade. The details are as follows.

[0071] See also Figure 3 , which is a schematic diagram of a scenario provided by an embodiment of the present application Figure 1 .

[0072] Taking the electronic device as a mobile phone device as an example, the mobile phone device can display a current battery power icon 30 , and the power icon 30 displays a user interface (UI) SOC, referred to as UI SOC.

[0073] The amount of electricity detected by the fuel gauge is called relative state of charge (RSOC). After a series of processes such as calibration, smoothing, and simulation, the RSOC detected by the fuel gauge can be used to obtain the corresponding UI SOC and displayed on the user interface.

[0074] When the power of an electronic device is not upgraded with firmware, before the electronic device is shut down or restarted, the register of the power meter will generate backup data and store it in the register. When the electronic device is restarted, the power meter reads the backup data stored in the register and brings it into the power calculation method for calculation, so that the UI SOC before and after the electronic device is started remains almost unchanged. For example, if the user sets the UI SOC of the electronic device to 50% before restarting, the UI SOC after restarting may still be 50%, or a value that is not much different from 50%, such as 49%.

[0075] The backup data includes the current depth of discharge (DoD), battery chemical capacity (qmax), and other information related to the battery status.

[0076] However, if the fuel meter firmware is upgraded, that is, the power calculation method in the fuel meter chip is updated, and the register of the fuel meter is reset, the backup data stored in the register of the fuel meter will not be retained after the fuel meter firmware is updated. At this time, the fuel meter will restart data collection, calculation of parameters in various backup data, calibration, smoothing and simulation, so that the RSOC re-determined after the fuel meter firmware is updated has a large change, which in turn causes a large change in the UI SOC synchronization of the electronic device. For example, after the fuel meter firmware is updated, the power displayed on the user interface of the electronic device may be 45%, which is a large difference from the 50% before the fuel meter firmware was updated, resulting in a significant jump in the displayed power, which reduces the user experience.

[0077] The solution of the present application backs up the backup data before the fuel meter firmware is upgraded on a device other than the fuel meter, such as a register of a processor or other memory. Even if the register data is cleared after the fuel meter firmware is upgraded, the processor can write the data backup back to the fuel meter chip to complete data initialization, thereby avoiding obvious jumps in the displayed power of the electronic device.

[0078] To sum up, by utilizing the technical solution of the present application, not only can the power meter of an electronic device be controlled by a processor to achieve online upgrades to meet the current online upgrade needs of the power meter, but also the relevant data of the power meter can be backed up in advance before the firmware update, and the relevant backup data can be rewritten into the power meter after the power meter firmware is updated, thereby avoiding obvious jumps in the displayed power of the electronic device and improving the user experience.

[0079] The following is an explanation in conjunction with a specific implementation method.

[0080] See also Figure 4 , which is a flow chart of another method for upgrading the firmware of a power meter provided in an embodiment of the present application.

[0081] In the following description of this application, the processor is ADSP as an example. When the processor is implemented in other ways, the principle is similar and will not be repeated here.

[0082] The method comprises the following steps:

[0083] S21: ADSP determines that the operating mode of the fuel gauge is user mode.

[0084] The ADSP can read the operating mode of the fuel gauge.

[0085] In a possible implementation, when the working mode of the fuel gauge is the user mode, it indicates that the fuel gauge has not been upgraded in firmware at this time.

[0086] In some other possible implementations, the upgrade process of the fuel meter firmware is abnormally interrupted. The reasons for the interruption may be that the electronic device has run out of power, the network is disconnected, the user actively restarts the electronic device, etc. When the electronic device is turned on again, it is necessary to continue to upgrade the fuel meter firmware. In this implementation, the working mode of the fuel meter read by ADSP is the upgrade mode, that is, the ISP mode, then ADSP directly writes firmware data to the fuel meter for firmware upgrade, that is, executes S29.

[0087] S22: The ADSP determines that the version number of the firmware data is greater than the current firmware version number of the fuel gauge.

[0088] ADSP can read the current firmware version number of the fuel gauge, and compare the current firmware version number with the version number of the firmware data. When the current firmware version number is the previous version, that is, the version number is smaller, it is determined that the firmware version needs to be updated.

[0089] For example, ADSP reads that the current firmware version number of the fuel gauge is 1.0, while the version number of the current firmware data is 2.0. Since 1.0 is less than 2.0, that is, 1.0 is the previous version of 2.0, ADSP determines that the fuel gauge needs to be updated with firmware at this time.

[0090] S23: ADSP sends a backup instruction to the power meter.

[0091] The backup instruction is used to instruct the fuel gauge to send backup data to the processor, where the backup data includes the current discharge depth and the current battery chemical capacity. In another possible implementation, the backup data also includes the battery status.

[0092] The battery status can be used to indicate the current charging or discharging behavior of the battery, the change in power caused by the charging or discharging behavior, and the power before and after the charging or discharging behavior.

[0093] The following is a detailed explanation of the working principle of the electricity meter.

[0094] The first task of the power calculation method is to calculate the remaining capacity (RM or RC), full charge capacity (FCC) and RSOC of the battery, where the three satisfy the following formula (1):

[0095] RSOC=(RM / FCC)*100% (1)

[0096] RSOC, RM, and FCC are all relative concepts defined by the system. 100% and 0% are all relative.

[0097] RSOC = 100% is defined as the battery being fully charged.

[0098] RSOC = 0% is defined as the battery being discharged.

[0099] FCC is defined as the cumulative amount of electricity released from full charge (RSOC = 100%) to empty charge (RSOC = 0%).

[0100] FCC varies in actual applications and may be affected by conditions such as load size and battery temperature. It is not necessarily equal to the nominal capacity (design capacity) of the battery when it leaves the factory.

[0101] RM is defined as the remaining power from the current moment to the moment when RSOC = 0%. RM, like FCC, is affected by load size, battery temperature and other conditions.

[0102] Depth of discharge (DoD) is the percentage of battery discharge to the rated capacity of the battery.

[0103] The battery chemical capacity (qmax) is the current maximum chemical capacity of the battery, and qmax is not fixed.

[0104] When the fuel gauge algorithm is initialized, RM_0 represents the remaining capacity of the battery set during the current initialization, and RM_0 satisfies the following formula:

[0105] RM_0= qmax * (100- DoD)*100% (2)

[0106] When the fuel gauge algorithm is initialized, FCC_0 indicates the full charge capacity set during the current initialization. FCC_0 satisfies the following formula:

[0107] FCC_0=k*qmax (3)

[0108] Here, k is a calibration parameter, and its value is generally slightly less than 1, for example, k=0.96. The value of k may be related to the battery status.

[0109] The real-time discharge depth is expressed by DoDcal, which satisfies the following formula:

[0110] DoDcal= DoD_0+cc / qmax (4)

[0111] The cc in formula (4) is the accumulated value of the current battery charging and discharging capacity, and cc can be detected in real time.

[0112] DoD_0 in formula (4) represents the discharge depth set during the current initialization. When the firmware of the fuel gauge is not updated but the electronic device is restarted, DoD_0 is the discharge depth value stored in the register of the fuel gauge, that is, DoD_0 = DoD at this time, and qmax is the battery chemical capacity value stored in the register of the fuel gauge.

[0113] If the fuel gauge firmware is not updated and only the electronic device is restarted, the fuel gauge will store the depth of discharge (DoD) and the battery chemical capacity (qmax) in the register. After the electronic device is restarted, the fuel gauge can determine the real-time depth of discharge DoDcal according to the depth of discharge (DoD) and the battery chemical capacity (qmax) and the real-time detected cc through formula (4).

[0114] The real-time RM satisfies the following equation:

[0115] RM= qmax * (100- DoDcal)*100% (5)

[0116] Then, the calculation results of equations (3) and (5) are substituted into equation (1) to determine the real-time RSOC, so that the power initialization starting point determined by the power meter after the electronic device is restarted is the same as the RSOC of the power meter before the electronic device is restarted.

[0117] Therefore, when the fuel meter firmware needs to be updated, the solution of the present application records the discharge depth (DoD) and battery chemical capacity (qmax) before the fuel meter is reset in advance, and rewrites the fuel meter as initialization data for the algorithm after the fuel meter firmware is updated and reset. In this way, even if the fuel meter firmware is updated and the register is reset, the fuel calculation method's fuel initialization starting point is the same as the fuel meter's RSOC before the firmware update, thereby avoiding jumps in displayed fuel levels.

[0118] Therefore, the backup command is used to indicate the fuel gauge backup discharge depth (DoD) and battery chemical capacity (qmax), two important parameter values.

[0119] In another possible implementation, the backup instruction may further instruct the fuel gauge to further back up the battery status. The battery status is used to indicate the charging behavior or discharging behavior before the battery firmware is updated, the change in power caused by the charging behavior or discharging behavior, and the power before and after the charging behavior or discharging behavior.

[0120] The battery status can be applied to the firmware algorithm of the fuel gauge to update the battery chemical capacity (qmax), because the battery status of the fuel gauge before the firmware update may affect the battery chemical capacity recalculated after the firmware update. The battery status can be identified by a flag parameter value. For example, when the flag parameter value is 1, 2, 3, and 4, it corresponds to different battery statuses.

[0121] The battery status may be related to the self-learning update strategy of the battery chemical capacity. The specific meanings of the battery status corresponding to different electronic devices and different types of batteries are different, as illustrated below.

[0122] For example, if the RSOC is less than 70% when the charger is last plugged in, and the accumulated charge capacity is greater than or equal to 15%, and the RSOC is less than 70% when charging is terminated, the battery status can be represented by status 1, and the parameter value of the flag bit corresponds to 1.

[0123] For another example, if the RSOC when the battery was last plugged into the charger was less than 70%, the accumulated charge capacity was less than 15%, and the RSOC when charging was terminated was between 50% and 70%, the battery status can be represented by status 2, and the parameter value of the flag bit corresponds to 2.

[0124] S24: The fuel gauge sends backup data to ADSP.

[0125] The fuel gauge obtains the current discharge depth and battery chemical capacity to generate backup data and transmits the backup data back to the ADSP

[0126] In another possible implementation, the backup data sent by the fuel gauge also includes the battery status.

[0127] S25: Fuel gauge reset.

[0128] S26: ADSP controls the fuel gauge to enter the full access mode and controls the fuel gauge to enter the upgrade mode.

[0129] ADSP obtains the permission to burn the firmware of the fuel gauge by controlling the fuel gauge to enter the full access mode, and then can write the firmware to the fuel gauge.

[0130] And ADSP controls the fuel gauge to enter the upgrade mode, that is, the ISP mode.

[0131] S27: The fuel gauge is reset in upgrade mode.

[0132] The fuel gauge enters ISP mode by performing an ISP reset.

[0133] S28: The power meter reports the ISP event to ADSP.

[0134] The fuel gauge informs ADSP that it is in ISP mode by reporting ISP events to ADSP.

[0135] S29: ADSP writes firmware data to the fuel gauge.

[0136] After receiving the ISP event reported by the fuel meter, the ADSP determines that the fuel meter is already in the ISP mode and starts to write firmware data to the fuel meter so that the fuel meter is upgraded according to the firmware data sent by the ADSP.

[0137] S30: After ADSP confirms that all firmware data has been sent successfully, it controls the fuel gauge to exit the upgrade mode and enter the user mode.

[0138] The firmware data may include several frames, and the ADSP sends each frame of data to the fuel gauge in sequence. When the ADSP confirms that the firmware data of the last frame has been successfully sent, it confirms that all the firmware data has been successfully sent.

[0139] The ADSP then controls the fuel gauge to exit upgrade mode and enter user mode.

[0140] S31: After the fuel gauge firmware upgrade is completed, exit the upgrade mode and enter the user mode.

[0141] S32: The fuel gauge is reset and the timer is started.

[0142] In one possible implementation, after the fuel meter completes the firmware upgrade and reset, a timer is started, and the length of time the timer counts is greater than the length of time the ADSP timer counts, to ensure that under normal circumstances, the fuel meter can receive the backup data sent by the ADSP before the timer expires.

[0143] The embodiment of the present application does not specifically limit the timing time of the timer of the electricity meter, for example, it can be set to 3 seconds.

[0144] S33: After the ADSP detects that the fuel gauge has completed resetting, it sends backup data to the fuel gauge.

[0145] ADSP can be provided with a timer. When the processor controls the fuel gauge to exit the upgrade mode, the timer is started to count. The time length of the timer is greater than the time taken to reset the fuel gauge. When the timer ends, it is considered that the fuel gauge reset is completed. At this time, the processor sends the backup data to the fuel gauge.

[0146] The embodiment of the present application does not specifically limit the timing time of the timer, for example, it can be set to 2 seconds.

[0147] S34: The electricity meter obtains the backup data before the timer expires, and brings the backup data into the initialization of the electricity calculation method.

[0148] In another possible implementation, if the power meter still fails to obtain the backup data after the timer expires, it indicates that the backup data transmission is abnormal, such as the backup data is lost. In this case, the method includes the following steps:

[0149] S35: If the power meter still fails to obtain the backup data after the timer expires, the upgrade event is cleared and the power calculation method is initialized.

[0150] At this point, the fuel gauge firmware upgrade has been completed, and the fuel gauge can run the fuel calculation method to re-determine the power percentage. Therefore, the ADSP can clear the ISP event, the fuel gauge initializes the algorithm, and re-performs the data collection, calculation, calibration, smoothing, simulation and other steps to determine the power percentage using the updated firmware algorithm.

[0151] In the embodiments of the present application, the division of the above steps is only for the convenience of explanation and does not constitute a limitation on the technical solution of the present application. In practical applications, appropriate adjustments can be made. For example, the timing of starting the timer of the S32 fuel meter can be before the fuel meter is reset. At this time, the timer time needs to be readjusted in combination with the reset time of the fuel meter.

[0152] In summary, by utilizing the technical solution provided in the embodiment of the present application, the online upgrade of the power meter of the electronic device can be controlled by the processor. For example, the firmware of the power meter can be upgraded while the electronic device OTA upgrades the system to meet the current online upgrade requirements of the power meter. In addition, before the power meter firmware is upgraded, the backup data is acquired in advance and stored in registers and memories outside the power meter, and the relevant backup data is rewritten into the power meter after the power meter firmware is updated, so that the power meter uses the backup data as the initial data of the power calculation method to initialize the power calculation method, so that the power percentage determined by the power meter after the firmware update is the same as that before the firmware update or there is no obvious jump, thereby improving the user experience.

[0153] In S29 of the above embodiment, when the ADSP writes firmware data to the electricity meter, a firmware data writing exception detection may be performed to determine whether the firmware data is successfully written and to ensure that the firmware upgrade is successful, which is described in detail below with reference to the accompanying drawings.

[0154] See also Figure 5 , which is a flow chart of another method for upgrading the firmware of a power meter provided in an embodiment of the present application.

[0155] The method comprises the following steps:

[0156] S41: The processor writes firmware data to the fuel gauge frame by frame.

[0157] S42: Determine whether a firmware data writing abnormality occurs.

[0158] If so, execute S43; otherwise, execute S48.

[0159] A write exception means that the firmware data of the current frame fails to be written.

[0160] S43: Determine whether the accumulated number of firmware data writing exceptions is greater than a preset number.

[0161] If so, execute S44; otherwise, execute S46.

[0162] The embodiment of the present application does not specifically limit the preset number of times. For example, the preset number of times can be set to 3 times.

[0163] The purpose of setting the preset number of times is to avoid repeated attempts to write data due to excessive firmware data writing failures, which may cause the fuel gauge firmware upgrade time to be too long or the fuel gauge hardware to be damaged.

[0164] S44: The processor controls the fuel gauge to exit the upgrade mode.

[0165] At this time, the fuel gauge firmware upgrade fails, and the processor controls the fuel gauge to exit the upgrade mode so that the fuel gauge recovers the firmware version before the upgrade.

[0166] S45: After the fuel meter is reset, the processor sends the backup data to the fuel meter.

[0167] After the fuel meter exits the upgrade mode, it is reset. Since the fuel meter was reset when it entered the upgrade mode, the data such as qmax, battery status, and discharge depth stored in the register of the fuel meter are cleared. Therefore, in order to prevent the percentage of power determined after the fuel meter exits the upgrade mode and resets and initializes the algorithm, the processor in the solution of the present application sends backup data to the fuel meter, so that the fuel meter uses the backup data as the initial data of the fuel calculation method to initialize the fuel calculation method.

[0168] S46: Waiting to see whether the first part of firmware data can be rewritten.

[0169] The first part of the firmware data may be the firmware data of a certain frame. At this time, the processor is blocked and waits for rewriting the first part of the firmware data.

[0170] If it can be rewritten, then S42 is executed and the firmware data can be continued to be written; otherwise, S47 is executed.

[0171] S47: The processor controls the fuel gauge to re-enter the upgrade mode.

[0172] When the current frame data is continuously blocked and cannot be written, the processor controls the fuel gauge to re-enter the upgrade mode and starts writing the firmware data frame by frame again.

[0173] S48: When the last frame of firmware data is written, the processor controls the fuel gauge to exit the upgrade mode.

[0174] In summary, by using the solution provided in the embodiment of the present application, it is possible to detect firmware data write anomalies when writing firmware data, which can support multiple firmware data writes and improve the probability of successful firmware upgrade of the fuel gauge. On the other hand, it avoids excessive firmware data write failures leading to continuous attempts to repeatedly write data, which makes the fuel gauge firmware upgrade time too long or the fuel gauge hardware damaged.

[0175] Based on the method provided in the above embodiment, the embodiment of the present application further provides an electronic device, which is described in detail below with reference to the accompanying drawings.

[0176] See also Figure 6 , which is a schematic diagram of an electronic device provided in an embodiment of the present application.

[0177] The electronic device provided in the embodiment of the present application may be a mobile phone, a wearable electronic device (such as a smart watch), a tablet computer, an augmented reality (AR) device or a virtual reality (VR) device, etc. Figure 6 The electronic device is a mobile phone device as an example.

[0178] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.

[0179] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0180] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc.

[0181] The real-time processor 110 of the present application may include an audio data signal processor (ADSP) for updating the fuel gauge firmware.

[0182] The processor 110 may also be provided with a memory for storing instructions and data.

[0183] The charging management module 140 is used to receive charging input from a charger. In some wired charging embodiments, the charging management module 140 can receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it can also power the electronic device through the power management module 141.

[0184] The power management module 141 receives input from the battery 142 and / or the charging management module 140 to provide power for the processor 110 , the internal memory 121 , the display screen 194 , the camera 193 , and the wireless communication module 160 .

[0185] In a possible implementation, a fuel gauge chip is integrated in the power management module 141, and the fuel gauge chip is equipped with fuel gauge firmware. The fuel gauge chip can monitor the battery voltage, current, and temperature, and provide them to the external system to facilitate system application decision-making, and facilitate safe and accurate charge and discharge control and management; predict the remaining battery capacity, full battery capacity, and battery charge state, etc.

[0186] See also Figure 7 , which is a schematic diagram of a software structure provided in an embodiment of the present application.

[0187] The embodiment of the present application takes the Android system of layered architecture as an example to exemplify the software structure of the electronic device 100. The layered architecture divides the software into an application layer, an application framework layer, an Android runtime and a system library, and a kernel layer.

[0188] The application layer includes the power display UI, which can be found in Figure 3 As shown, it is used to display UI SOC.

[0189] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions. It can include the fuel gauge firmware and the fuel gauge upgrade service. The fuel gauge upgrade service is used to implement the update of the fuel gauge firmware version.

[0190] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library contains two parts: one is the function that the Java language needs to call, and the other is the Android core library.

[0191] The kernel layer is the layer between hardware and software. The kernel layer contains at least the fuel gauge driver, ADSP, sensor driver, etc. The opinion layer includes the fuel gauge chip.

[0192] The electronic device provided in the embodiment of the present application can realize online upgrade of the power meter of the electronic device through the processor to meet the current online upgrade requirements of the power meter. It can also avoid obvious jumps in the displayed power of the electronic device by pre-backing up the relevant data of the power meter before the firmware is updated, and rewriting the relevant backup data into the power meter after the power meter firmware is updated, thereby improving the user experience.

[0193] Based on the firmware upgrade method of the power meter provided in the above embodiments, an embodiment of the present application further provides a storage medium, on which a program is stored, and when the program is executed by an electronic device, the firmware upgrade method of the power meter provided in the above embodiments is implemented.

[0194] Storage media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of storage media include, but are not limited to, parameter random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), electrically-erasable programmable read-only memory (EEPROM), flash memory, or other memory technologies.

[0195] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0196] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for upgrading the firmware of an electric meter, characterized in that: Applied to a processor, the method comprises: Sending a backup instruction to the fuel meter and controlling the fuel meter to enter a full access mode, wherein the backup instruction is used to instruct the fuel meter to send backup data to the processor, wherein the backup data includes a current depth of discharge and a current battery chemical capacity; Controlling the fuel gauge to enter an upgrade mode and writing firmware data to the fuel gauge; When the firmware data is written, controlling the electricity meter to exit the upgrade mode; When the electricity meter is reset, the backup data is sent to the electricity meter, and the backup data is used as initial data of the electricity calculation method.

2. The method according to claim 1, characterized in that The sending of the backup instruction to the electricity meter specifically includes: Reading the working mode of the fuel gauge; When the working mode is a non-upgrade mode and the version number of the firmware data is greater than the current firmware version number of the electricity meter, a backup instruction is sent to the electricity meter.

3. The method according to claim 1, characterized in that The step of writing firmware data to the electricity meter specifically includes: When writing firmware data to the electricity meter, performing firmware data writing abnormality detection; When the firmware data writing abnormality detection determines that the first part of the firmware data is written abnormally, rewriting the first part of the firmware data; When the rewriting of the first part of the firmware data fails, the electricity meter is controlled to re-enter the upgrade mode.

4. The method according to claim 3, characterized in that The method further comprises: When it is determined that the accumulated number of occurrences of write anomalies is greater than a preset number, the electricity meter is controlled to exit the upgrade mode.

5. The method according to claim 2, characterized in that: When the working mode of the electricity meter is the upgrade mode, the method further includes: writing the firmware data into the fuel gauge; When the firmware data is written and the electricity meter is reset, the backup data is sent to the electricity meter.

6. The method according to any one of claims 1 to 5, characterized in that The backup data also includes a battery status, where the battery status is used to indicate the charging behavior or discharging behavior before the battery firmware is updated, the change in power caused by the charging behavior or discharging behavior, and the power corresponding to before and after the charging behavior or discharging behavior.

7. A method for upgrading the firmware of an electric meter, characterized in that: Applied to a fuel gauge, the method comprises: After receiving the backup instruction sent by the processor, the backup data is sent to the processor, the backup data including the current discharge depth and the current battery chemical capacity; Entering an upgrade mode and performing a firmware upgrade according to the firmware data sent by the processor; Reset after the firmware upgrade is completed; The backup data sent by the processor is received, and the backup data is used as initial data of the power calculation method.

8. The method according to claim 7, characterized in that The step of entering the upgrade mode and performing firmware upgrade according to the firmware data sent by the processor specifically includes: Entering an upgrade mode and reporting an upgrade event to the processor so that the processor starts writing the firmware data; Firmware is upgraded according to the firmware data sent by the processor.

9. The method according to claim 7, characterized in that: The receiving the backup data sent by the processor and using the backup data as initial data of the power calculation method specifically includes: After the reset is completed, start the timer; When the backup data is acquired before the timer expires, the backup data is used as initial data of the power calculation method.

10. The method according to claim 9, characterized in that When the timer expires and the backup data is not obtained, the method further includes: Initialize the power calculation method and determine the power percentage RSOC.

11. The method according to any one of claims 7 to 10, characterized in that: The backup data also includes a battery status, where the battery status is used to indicate the charging behavior or discharging behavior before the battery firmware is updated, the change in power caused by the charging behavior or discharging behavior, and the power corresponding to before and after the charging behavior or discharging behavior.

12. An electronic device, characterized in that: The electronic device comprises a processor and a fuel gauge chip, wherein the processor is used to implement the firmware upgrade method of the fuel gauge according to any one of claims 1 to 6, and the fuel gauge chip is used to implement the firmware upgrade method of the fuel gauge according to any one of claims 7 to 11.

13. A storage medium, characterized in that: The storage medium stores a program, and when the program is executed by the electronic device, the method for upgrading the firmware of the fuel gauge according to any one of claims 1 to 6 or the method for upgrading the firmware of the fuel gauge according to any one of claims 7 to 11 is implemented.

Citation Information

Patent Citations

  • Battery capacity measurement method and device, computer device and storage medium

    CN107153165A

  • Mobile terminal power quantity display control method, device, storage medium and mobile terminal

    CN107295175A

  • Battery software remote upgrading method, device and equipment and storage medium

    CN115729588A

  • Bootloader system of embedded software and upgrading method

    CN115951939A