Multi-battery curve compatible calling method and device

By writing battery characteristic identification information into the non-volatile storage partition of the device motherboard, the battery curve can be automatically matched using the existing storage partition. This solves the problem of inaccurate power display caused by incorrect battery type identification, simplifies hardware design, and supports compatibility with different batteries.

CN121748593APending Publication Date: 2026-03-27GUANGDONG TELEPOWER TELECOM TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-29
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

In existing technologies, devices are prone to errors when identifying battery types, leading to inaccurate power display, power outages, or false power issues, which increases hardware costs.

Method used

Battery characteristic identification information is written to the non-volatile storage partition of the device motherboard, and the battery curve is automatically matched by the bootloader and operating system kernel, utilizing the existing storage partition without adding additional hardware.

Benefits of technology

It achieves automatic battery curve matching without increasing hardware costs, ensures accurate power display, supports broad compatibility with different batteries, and simplifies hardware design.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121748593A_ABST
    Figure CN121748593A_ABST
Patent Text Reader

Abstract

The invention provides a multi-battery curve compatible calling method and a multi-battery curve compatible calling device. Battery characteristic identification information is written into an existing nonvolatile storage partition on an equipment mainboard. When the device is powered on and started, the boot loader reads the battery characteristic identification information and transmits the battery characteristic identification information to the kernel, and the battery driver calls the battery curve matched with the current battery according to the battery characteristic identification information obtained by the kernel. According to the method, the hardware design is simplified, the method can be realized only by utilizing the nonvolatile storage partition which exists when equipment leaves a factory and is used for storing information such as IMEI (International Mobile Equipment Identity), and nearly zero marginal hardware cost is realized. Dependence on battery hardware is broken through, wide compatibility is achieved, and no special requirement on the battery itself exists. According to the technical scheme, only one-time setting needs to be carried out in the initial stage, for a final user, in the whole life cycle, the equipment can automatically call a correct battery curve without mistakes every time the equipment is started up, and batteries with different capacities can be replaced only by resetting after the equipment is started up and then restarting.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of battery, in particular to a multi-battery curve compatible calling method and a multi-battery curve compatible calling device. BACKGROUND

[0002] With the increasing complexity and diversification of portable electronic devices (such as smart phones, laptops, tablets, wearable devices, etc.), the requirements for battery capacity and endurance are also increasing. In order to meet different market positioning, product models and user needs, the same product series often uses battery cells from different suppliers or with different chemical formulas, thus the capacity is different.

[0003] The "power" of the battery is not a directly measurable physical quantity, but is estimated by indirect measurement combined with the battery discharge characteristic curve (hereinafter referred to as "battery curve"). The curve describes the nonlinear relationship between battery voltage and remaining power. If the system incorrectly identifies the battery type and calls the mismatched battery curve for power estimation, it will cause the power display to be seriously inaccurate, resulting in "power outage" (power drop), "virtual power" (displaying power but shutting down quickly), etc. greatly affecting user experience and product reliability.

[0004] Therefore, how to accurately identify the type of battery currently installed at the start of the device and match the correct battery curve for it has become a key engineering technical problem.

[0005] The existing solutions in the prior art include hardware ADC voltage detection identification and ID reading based on communication protocol. Both of these two methods will increase the hardware cost: scheme one needs additional ADC channel and peripheral circuit; scheme two needs to add a storage chip and communication line in the battery. SUMMARY

[0006] In view of the above problems, the present application is proposed in order to provide a multi-battery curve compatible calling method and a corresponding multi-battery curve compatible calling device which overcome the above problems or at least partially solve the above problems.

[0007] The present application discloses a multi-battery curve compatible calling method, the method comprising: writing battery characteristic identification information in an existing non-volatile storage partition on the device motherboard; When the device is powered on, the bootloader reads the battery characteristic identification information from the non-volatile storage partition and transfers the read battery characteristic identification information to the operating system kernel; The battery driver calls the battery curve matched with the current battery according to the battery characteristic identification information obtained by the kernel.

[0008] The application also discloses a multi-battery curve compatible calling device, which comprises: A battery characteristic identification information writing module is used for writing battery characteristic identification information in an existing non-volatile storage partition on a device mainboard; A battery characteristic identification information loading and transferring module is used for guiding a bootloader to read the battery characteristic identification information from the non-volatile storage partition when the device is powered on, and transferring the read battery characteristic identification information to an operating system kernel; A battery curve matching calling module is used for calling a battery curve matched with a current battery according to the battery characteristic identification information obtained by the kernel.

[0009] The application has the following advantages: The hardware design is simplified, and no additional ADC channel, voltage dividing resistor, storage chip (such as EEPROM) and corresponding communication bus circuit are needed, and the non-volatile storage partition (such as NVRAM) for storing IMEI and the like information existing when the device is shipped is used, so that the marginal hardware cost is almost zero. The dependence on the battery hardware is broken, and wide compatibility is realized without any special requirement for the battery itself. Only one-time setting is needed in the initial stage, and for the end user, the device can automatically and correctly call the correct battery curve every time the device is started in the whole life cycle, and only the setting after the start and the restart are needed when the battery with different capacity is replaced. BRIEF DESCRIPTION OF DRAWINGS

[0010] Figure 1 It is a step flow chart of a multi-battery curve compatible calling method provided by the application embodiment; Figure 2 It is a non-volatile storage partition schematic diagram of battery characteristic identification information writing; Figure 3 It is a battery characteristic identification information loading and transferring schematic diagram; Figure 4 It is a schematic diagram of loading all battery curve data for matching calling; Figure 5 It is a battery characteristic identification information corresponding battery curve data grabbing and verifying schematic diagram; Figure 6 It is a battery characteristic identification information storage schematic diagram; Figure 7 It is a structure block diagram of a multi-battery curve compatible calling device provided by the application embodiment. DETAILED DESCRIPTION

[0011] In order to make the above-mentioned purposes, features and advantages of the application more obvious and easy to understand, the application is further described in detail in combination with the drawings and specific embodiments.

[0012] Referring to Figure 1 , a step flow chart of a multi-battery curve compatible calling method provided in an embodiment of the present application is shown, and can specifically include the following steps: Step 101, writing battery characteristic identification information in an existing non-volatile storage partition on a device mainboard; Step 102, when the device is powered on, a bootloader reads the battery characteristic identification information from the non-volatile storage partition, and transmits the read battery characteristic identification information to an operating system kernel; Step 103, a battery driver calls a battery curve matched with a current battery according to the battery characteristic identification information obtained by the kernel.

[0013] In an optional embodiment of the present application, the non-volatile storage partition is a storage partition for storing device identity information that already exists when the device is shipped.

[0014] In an optional embodiment of the present application, when the device is powered on, the bootloader reads the battery characteristic identification information from the non-volatile storage partition, and transmits the read battery characteristic identification information to the operating system kernel, including: The bootloader reads data of a predetermined length starting from a specified offset address in the non-volatile storage partition; The battery characteristic identification information is parsed from the data of the predetermined length; The battery characteristic identification information is added to a start command line of the operating system kernel as a set of key-value parameters.

[0015] In an optional embodiment of the present application, the battery driver calls the battery curve matched with the current battery according to the battery characteristic identification information obtained by the kernel, including: The operating system kernel obtains the battery characteristic identification information by parsing the start command line in an initialization stage; The battery driver locates a corresponding battery curve data node in a device tree according to the battery characteristic identification information, and loads a battery curve stored in the battery curve data node.

[0016] In an optional embodiment of the present application, the method further includes: If the bootloader fails to successfully read the battery characteristic identification information, a predefined default battery characteristic identification information is used as the battery characteristic identification information of the current battery to call a default battery curve.

[0017] In an optional embodiment of the present application, the battery characteristic identification information can be re-written and updated in a whole life cycle of the device to adapt to replacement of different batteries.

[0018] In an optional embodiment of the present invention, the battery characteristic identification information includes battery capacity and battery curve identification information.

[0019] This invention invokes different battery curves without incurring any additional hardware costs or relying on special battery pins or communication functions. Its technical concept includes the following three aspects: First, there's the separation and binding of information and its carrier. Key information identifying battery characteristics (such as capacity and curve ID) is separated from the traditional physical battery carrier (such as ID pins and internal chips) and stored instead in a specific non-volatile memory area on the device's motherboard (such as an NVRAM partition), thus binding battery information to the device itself. Second, there's a one-time write and permanent automatic recall process. A logic combining one-time setup with subsequent automatic reading is employed. Authorized personnel write the information using specific methods at specific points in time, such as during production or maintenance. Each time the device powers on, the system firmware (Bootloader and Kernel) automatically reads and transmits the information without user intervention. Finally, there's a cross-system-level collaborative reading and transmission mechanism. A multi-stage, cross-level software reading and transmission path is designed to complete before the operating system fully boots (specifically, Bootloader (e.g., LK) -> Kernel -> Fuel Meter Driver). This ensures that the correct battery curve parameters are in place at the initialization of the fuel meter, guaranteeing the accuracy of fuel quantity calculation from the very first moment of power-on.

[0020] Specifically, refer to Figure 2 The multi-battery curve compatibility calling process is as follows: 1. In vendor / mediatek / proprietary / custom / tps360k_8768 / cgen / cfgfileinc / CFG_PRODUCT_INFO_File.h, add an unsigned char battery_capacity

[64] ; / / 64B partition. Note the size; the offset needs to be calculated when reading the partition from this structure later. Figure 3 .

[0021] 2. In vendor / mediatek / proprietary / bootable / bootloader / lk / app / mt_boot / mt_boot.c, read this data. Pay special attention to mboot_recovery_load_raw_part("proinfo",raw_data, sizeof(raw_data)); The length of raw_data here includes the size of all the partitions above, 170+64+40+64+3+64+64=469. Then memcpy(buf, raw_data + 405, 64); Starting from offset 405, the last 64 is the location where battery_capacity is stored, and read the data in this area.

[0022] +static inline int read_battery_capacity(char *buf) +{ +int tmp = 0; +char raw_data

[469] ; + +if (!buf) return 0; + + / / Read the first 469 bytes of the proinfo partition +mboot_recovery_load_raw_part("proinfo", raw_data, sizeof(raw_data)); + + / / battery_capacity is located at offset 405 and has a length of 64 bytes. + / / Copy data directly to the buffer starting at offset 405 +memcpy(buf, raw_data + 405, 64); + + / / Parse valid data +for (; tmp<64; tmp++) { +if ((buf[tmp] == 0 || buf[tmp]== 0x20)&&tmp>0) +break; +else if (!isalpha(buf[tmp])&&!isdigit(buf[tmp])) +break; +} + +return tmp; +} 3. Next, the data is stored in telpo_battery_buf. If it is empty, a default 7600mAh battery will be used. +static void set_battery_capacity(void) +{ +unsigned int len; + + / / Read battery capacity information +len = (unsigned int)read_battery_capacity(telpo_battery_buf); + +if (len == 0) { + / / If the read fails, use the default value. +pal_log_info("Set battery capacity to default value.\n"); +len = strlen(DEFAULT_BATTERY_CAPACITY); / / Default is 7600 +len = (len<64) ? len : 64; +strncpy(telpo_battery_buf, DEFAULT_BATTERY_CAPACITY, len); +} else { +len = (len<64) ? len : 64; +} + +telpo_battery_buf[len] = '\0'; + + / / Output to kernel command line +pal_log_info("Set battery capacity: %s\n", telpo_battery_buf); +} 4. Input the command line into the kernel. +snprintf(tmpbuf, TMPBUF_SIZE, "%s%s", "androidboot.ztk_telpo_battery=", telpo_battery_buf); +cmdline_append(tmpbuf); 5. After booting up the machine, use `cat / proc / cmdline` to check if the addition was successful. androidboot.ztk_telpo_battery=6000 6. In the kernel, the stored battery capacity is read using saved_command_line and output telpo_battery_capacity for use by the battery driver. +static int __init parse_telpo_battery_from_cmdline(void) +{ +char *cmdline = saved_command_line; +char *param_start, *param_end; +char value_str

[32] = {0}; +int value_len; + +printk("Parsing battery capacity\n"); + +param_start = strstr(cmdline, "androidboot.ztk_telpo_battery="); +if (!param_start) { +telpo_battery_capacity = 0; +return 0; +} + +param_start += strlen("androidboot.ztk_telpo_battery="); +param_end = strchrnul(param_start, ' '); +value_len = min(param_end - param_start, (long)(sizeof(value_str) -1)); + +strncpy(value_str, param_start, value_len); +value_str[value_len] = '\0'; + +if (kstrtoint(value_str, 10,&telpo_battery_capacity)) +telpo_battery_capacity = 0; + +printk("Battery capacity: %d\n", telpo_battery_capacity); +return 0; +} + +subsys_initcall(parse_telpo_battery_from_cmdline); 7. During battery curve initialization, data from different battery curves in the DTS will be called. for (i = 0; i<fg_table_cust_data-> active_table_number; i++) { +printk("telpo_battery_capacity=%d\n",telpo_battery_capacity); +if (telpo_battery_capacity == 6000 || telpo_battery_capacity == 7600|| telpo_battery_capacity == 10000) { +sprintf(node_name, "battery%d_profile_t%d_num_%d", bat_id, i, telpo_battery_capacity); +fg_read_dts_val(np, node_name, +&(fg_table_cust_data->fg_profile[i].size), 1); + + / * compatiable with old dtsi table* / +sprintf(node_name, "battery%d_profile_t%d_col", bat_id, i); +ret = fg_read_dts_val(np, node_name,&(column), 1); +if (ret == -1) +column = 3; + +if (column<3 || column>4) { +bm_err("%s, %s,column:%d ERROR!", +__func__, node_name, column); + / * correction * / +column = 3; +} + +sprintf(node_name, "battery%d_profile_t%d_%d", bat_id, i, telpo_battery_capacity); +fg_custom_parse_table(gm, np, node_name, +fg_table_cust_data->fg_profile[i].fg_profile, column, telpo_battery_capacity); +}else{ sprintf(node_name, "battery%d_profile_t%d_num", bat_id, i); fg_read_dts_val(np, node_name, &(fg_table_cust_data->fg_profile[i].size), 1); Based on the obtained `telpo_battery_capacity`, different DTS (Data Type Templates) are loaded. Note that `battery%d_profile_t%d_num_%d`: the default battery profile will look for data in `battery0_profile_t0_num`, while a custom value will read data from `battery0_profile_t0_num_telpo_battery_capacity`. The DTS needs to have all battery profiles for all capacities pre-loaded beforehand, and then this data is used for reading. Figure 4 .

[0023] 8. Capture the charging log during startup. Search for "Q" to see if the running curve matches your set battery capacity. There will generally be some error, but if it's close, it's correct. The battery capacity in the machine needs to be multiplied by 10, so a 1W battery will result in a 10W curve. Figure 5 .

[0024] 9. Regarding how to define the capacity in the initial partition, write operations can be performed at the system level. The driver verification method is to use the tool AP_META_exe_V3.2324.0 to temporarily write a value. After writing, it can be stored in the machine like an SN or IMEI number, unless formatted and erased. Figure 6 .

[0025] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0026] Reference Figure 7 The diagram illustrates a structural block diagram of a multi-battery curve-compatible calling device provided in an embodiment of the present invention, which may specifically include the following modules: The battery characteristic identification information writing module 701 is used to write battery characteristic identification information into the existing non-volatile storage partition on the device motherboard; The battery characteristic identification information loading and transmission module 702 is used to read the battery characteristic identification information from the non-volatile storage partition and transmit the read battery characteristic identification information to the operating system kernel when the device is powered on and started. The battery curve matching call module 703 is used by the battery driver to call the battery curve that matches the current battery based on the battery characteristic identification information obtained by the kernel.

[0027] In an optional embodiment of the present invention, the non-volatile storage partition is a storage partition that exists at the time the device leaves the factory and is used to store device identity information.

[0028] In an optional embodiment of the present invention, the battery characteristic identification information loading and transmission module is further configured to: The bootloader reads data of a predetermined length starting at a specified offset address from the non-volatile memory partition; Battery characteristic identification information is parsed from the data of the predetermined length; The battery characteristic identification information is added as a set of key-value parameters to the operating system kernel's boot command line.

[0029] In an optional embodiment of the present invention, the battery curve matching calling module is further configured to: During the initialization phase, the operating system kernel obtains battery characteristic identification information by parsing the startup command line; The battery driver locates the corresponding battery curve data node in the device tree based on the battery characteristic identification information and loads the battery curve stored in the battery curve data node.

[0030] In an optional embodiment of the present invention, the battery characteristic identification information loading and transmission module is further configured to: If the bootloader fails to read the battery characteristic identification information, it will use a predefined default battery characteristic identification information as the current battery's battery characteristic identification information to invoke the default battery curve.

[0031] In one optional embodiment of the present invention, the battery characteristic identification information can be rewritten and updated throughout the device's lifecycle to adapt to the replacement of different batteries.

[0032] In an optional embodiment of the present invention, the battery characteristic identification information includes battery capacity and battery curve identification information.

[0033] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0034] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0035] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0036] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A method for compatible multi-battery curve calling, characterized in that, The method includes: Write battery characteristic identification information into the existing non-volatile memory partition on the device's motherboard; When the device is powered on and started, the bootloader reads the battery characteristic identification information from the non-volatile storage partition and passes the read battery characteristic identification information to the operating system kernel; The battery driver uses the battery characteristic identification information obtained from the kernel to call the battery curve that matches the current battery.

2. The method according to claim 1, characterized in that, The non-volatile storage partition is a storage partition that exists at the time the device leaves the factory and is used to store the device's identity information.

3. The method according to claim 1, characterized in that, When the device powers on and starts up, the bootloader reads the battery characteristic identification information from the non-volatile storage partition and passes the read battery characteristic identification information to the operating system kernel, including: The bootloader reads data of a predetermined length starting at a specified offset address from the non-volatile memory partition; Battery characteristic identification information is parsed from the data of the predetermined length; The battery characteristic identification information is added as a set of key-value parameters to the operating system kernel's boot command line.

4. The method according to claim 3, characterized in that, The battery driver, based on the battery characteristic identification information obtained from the kernel, calls the battery curve that matches the current battery, including: During the initialization phase, the operating system kernel obtains battery characteristic identification information by parsing the startup command line; The battery driver locates the corresponding battery curve data node in the device tree based on the battery characteristic identification information and loads the battery curve stored in the battery curve data node.

5. The method according to claim 1, characterized in that, The method further includes: If the bootloader fails to read the battery characteristic identification information, it will use a predefined default battery characteristic identification information as the current battery's battery characteristic identification information to invoke the default battery curve.

6. The method according to claim 1, characterized in that, Battery characteristic identification information can be rewritten and updated throughout the device's lifecycle to accommodate different battery replacements.

7. The method according to claim 1, characterized in that, The battery characteristic identification information includes battery capacity and battery curve identification information.

8. A multi-battery curve compatible calling device, characterized in that, The device includes: The battery characteristic identification information writing module is used to write battery characteristic identification information into the existing non-volatile storage partition on the device motherboard; The battery characteristic identification information loading and transmission module is used to read the battery characteristic identification information from the non-volatile storage partition when the device is powered on and started, and to transmit the read battery characteristic identification information to the operating system kernel. The battery curve matching module is used by the battery driver to call the battery curve that matches the current battery based on the battery characteristic identification information obtained by the kernel.

9. The apparatus according to claim 8, characterized in that, The battery characteristic identification information loading and transmission module is also used for: The bootloader reads data of a predetermined length starting at a specified offset address from the non-volatile memory partition; Battery characteristic identification information is parsed from the data of the predetermined length; The battery characteristic identification information is added as a set of key-value parameters to the operating system kernel's boot command line.

10. The apparatus according to claim 9, characterized in that, The battery curve matching module is also used for: During the initialization phase, the operating system kernel obtains battery characteristic identification information by parsing the startup command line; The battery driver locates the corresponding battery curve data node in the device tree based on the battery characteristic identification information and loads the battery curve stored in the battery curve data node.