根据拿到的电池曲线,配置具体的数据,比如拿到5组不同温度的电池曲线,温度值分别为50,25,10,0,-10摄氏度。
5组不同温度下的电池曲线
ACTIVE_TABLE = <(5)>;
/* Table numbers per battery */
具体的温度
TEMPERATURE_T0 = <(50)>;
/* Battery temperature T0 */
TEMPERATURE_T1 = <(25)>;
/* Battery temperature T1 */
TEMPERATURE_T2 = <(10)>;
/* Battery temperature T2 */
TEMPERATURE_T3 = <(0)>;
/* Battery temperature T3 */
TEMPERATURE_T4 = <(-10)>;
/* Battery temperature T4 */
通过excel格式化数值,复制粘贴到dtsi中,battery0_profile_tx_num根据实际数量填写。
电池容量 开路电压 电池电阻
{0.1mah, 0.1mv ,0.1mΩ}
battery0_profile_t0_num = <100>;
battery0_profile_t0_col = <3>;
battery0_profile_t0 =
<
0 43370 1150
... ... ...
30370 30200 5900
>;
battery0_profile_t1_num = <100>;
battery0_profile_t1_col = <3>;
battery0_profile_t1 =
<
0 43370 1150
... ... ...
30370 30200 5900
>;
battery0_profile_t2_num = <100>;
battery0_profile_t2_col = <3>;
battery0_profile_t2 =
<
0 43450 1250
... ... ...
30370 30290 6100
>;
battery0_profile_t3_num = <100>;
battery0_profile_t3_col = <3>;
battery0_profile_t3 =
<
0 43430 1825
... ... ...
30370 30900 7375
>;
battery0_profile_t4_num = <100>;
battery0_profile_t4_col = <3>;
battery0_profile_t4 =
<
0 43350 3000
... ... ...
30370 31910 10050
>;
可以通过/proc/battery/dump_log查看配置的电池数据。
echo 102 > /proc/battery/dump_log
cat /proc/battery/dump_log
static int proc_dump_log_show(struct seq_file *m, void *v)
{
int i;
seq_puts(m, "********** Gauge Dump **********\n");
seq_puts(m, "Command Table list\n");
seq_puts(m, "0: dump dtsi\n");
seq_puts(m, "1: dump v-mode table\n");
seq_puts(m, "101: dump gauge hw register\n");
seq_puts(m, "102: kernel table\n");
seq_puts(m, "103: send CHR FULL\n");
seq_puts(m, "104: disable NAFG interrupt\n");
seq_puts(m, "105: show daemon pid\n");
seq_printf(m, "current command:%d\n", gm.proc_cmd_id);
switch (gm.proc_cmd_id) {
case 0:
proc_dump_dtsi(m);
break;
case 1:
case 2:
case 3:
case 4:
wakeup_fg_algo_cmd(
FG_INTR_KERNEL_CMD, FG_KERNEL_CMD_DUMP_LOG,
gm.proc_cmd_id);
for (i = 0; i < 5; i++) {
msleep(500);
if (gm.proc_subcmd_para1 == 1)
break;
}
proc_dump_log(m);
break;
case 101:
gauge_dev_dump(gm.gdev, m, 0);
break;
case 102:
dump_kernel_table(m);
break;
case 103:
wakeup_fg_algo(FG_INTR_CHR_FULL);
break;
case 104:
gauge_set_nag_en(false);
gm.disable_nafg_int = true;
break;
case 105:
seq_printf(m, "Gauge daemon pid:%d\n", gm.g_fgd_pid);
break;
default:
seq_printf(m, "do not support command:%d\n", gm.proc_cmd_id);
break;
}
/*battery_dump_info(m);*/
return 0;
}
mtk官网介绍的是使用gmat合入电池参数,介绍下使用流程
默认下载下来的gmat有1.0和2.0两个版本,以2.0为例,先安装好gmat,然后打开gmat
先导入CFG_GM30_dtsi_table_ext.txt,再导入GM3.0_ZCV_Table_Template_V1.0.xlsx,然后点击产生文件就行。(注意gmat生成的文件在c盘根目录下,所以要以管理员身份运行gmat,可以编辑txt文件的修改保存路径) (plaform可以自行输入,生成的文件以平台命名)
从demo的数据看,每组的电池曲线不是都是100组数据的,但生成的数据都变成了每组100组数据,而且有些数据跟原数据有稍微的差异,应该是进行了优化。
然后在GM3.0_ZCV_Table_Template_V1.0.xlsx基础上,替换成项目的电池参数,不同温度的表格不需要等长,但要以end结尾,另外表格里的数值需要是整数。
电池电量问题可参考FAQ20713
电池dtsi参数可以参考GM3.0_Customization parameter design guide_V1.1.pptx