高温手机重启案例分析

教育   科技   2024-07-24 08:29   中国  

和你一起终身学习,这里是程序员Android

经典好文推荐,通过阅读本文,您将收获以下知识点:

一、高温触发 Kernel Exception 重启问题
二、解决方案
三、提高电池温度方案

一、 高温触发 Kernel Exception 重启问题

手机 电池温度 默认60度以上高温会触发手机安全机制,让手机管家或者重启。

由温度异常导致手机重启的部分 Log 如下:

高温情况下,Kernel Exception引起的重启问题

二、解决方案

此问题 需要驱动同事修改底层battery.c 文件中的一个地址,不让其写为dead,就不会重启。或者提高电池温度参数。

三、提高电池温度方案

提高电池温度的方案如下:

1.修改mtk_battery_table.h

/alps/kernel-4.4/drivers/misc/mediatek/include/mt-plat/mt6739/include/mach/mtk_battery_table.h

  * ============================================================

*/

+//#define SPROCOMM_NTC //wang add

+#ifdef SPROCOMM_NTC

+#define NTC_COMP_RES 42

+#endif

+

/* Qmax for battery */

#define Q_MAX_L_CURRENT 0

#define Q_MAX_H_CURRENT 10000

@@ [-111,7](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/misc/mediatek/include/mt-plat/mt6739/include/mach/mtk_battery_table.h;h=7cb7b5e7e735a1907b941a6df5755c582ffca0ac;hb=7cb7b5e7e735a1907b941a6df5755c582ffca0ac#l111) [+116,8](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/misc/mediatek/include/mt-plat/mt6739/include/mach/mtk_battery_table.h;h=76ef73904571e7abf677cf9b73783b52131c467a;hb=76ef73904571e7abf677cf9b73783b52131c467a#l116) @@ int g_QMAX_SYS_VOL_T4[TOTAL_BATTERY_NUMBER] = {36000, 36010, 36020, 36030};

#define BIF_NTC_R 16000

#if (BAT_NTC_10 == 1)

-struct FUELGAUGE_TEMPERATURE Fg_Temperature_Table[21] = {

+#define NTC_NUM 25 //wang add 20180528

+struct FUELGAUGE_TEMPERATURE Fg_Temperature_Table[NTC_NUM] = {

{-40, 195652},

{-35, 148171},

{-30, 113347},

@@ [-132,12](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/misc/mediatek/include/mt-plat/mt6739/include/mach/mtk_battery_table.h;h=7cb7b5e7e735a1907b941a6df5755c582ffca0ac;hb=7cb7b5e7e735a1907b941a6df5755c582ffca0ac#l132) [+138,17](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/misc/mediatek/include/mt-plat/mt6739/include/mach/mtk_battery_table.h;h=76ef73904571e7abf677cf9b73783b52131c467a;hb=76ef73904571e7abf677cf9b73783b52131c467a#l138) @@ struct FUELGAUGE_TEMPERATURE Fg_Temperature_Table[21] = {

{45, 4917},

{50, 4161},

{55, 3535},

- {60, 3014}

+ {60, 3014},

+ {65, 2586},

+ {70, 2228},

+ {75, 1925},

+ {80, 1669}

};

#endif

#if (BAT_NTC_47 == 1)

-struct FUELGAUGE_TEMPERATURE Fg_Temperature_Table[21] = {

+#define NTC_NUM 21 //wang add 20180528

+struct FUELGAUGE_TEMPERATURE Fg_Temperature_Table[NTC_NUM] = {

{-40, 1747920},

{-35, 1245428},

{-30, 898485},

2. 修改mtk_ts_battery.c

/alps/kernel-4.4/drivers/misc/mediatek/thermal/common/thermal_zones/mtk_ts_battery.c

@@ [-134,7](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/misc/mediatek/thermal/common/thermal_zones/mtk_ts_battery.c;h=f807c7272f610a9e61307eaebe0057ee0f157490;hb=f807c7272f610a9e61307eaebe0057ee0f157490#l134) [+134,7](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/misc/mediatek/thermal/common/thermal_zones/mtk_ts_battery.c;h=e201c1fc84ba09e04f8d53a5ca11993848df1feb;hb=e201c1fc84ba09e04f8d53a5ca11993848df1feb#l134) @@ static int bat_temp = 21234;

/* static int battery_write_flag=0; */

-#define mtktsbattery_TEMP_CRIT 60000 /* 60.000 degree Celsius */

+#define mtktsbattery_TEMP_CRIT 80000 /* 60.000 degree Celsius */ //wang add 20180528

#define mtktsbattery_dprintk(fmt, args...) \

do { \

@@ [-455,8](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/misc/mediatek/thermal/common/thermal_zones/mtk_ts_battery.c;h=f807c7272f610a9e61307eaebe0057ee0f157490;hb=f807c7272f610a9e61307eaebe0057ee0f157490#l455) [+455,8](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/misc/mediatek/thermal/common/thermal_zones/mtk_ts_battery.c;h=e201c1fc84ba09e04f8d53a5ca11993848df1feb;hb=e201c1fc84ba09e04f8d53a5ca11993848df1feb#l455) @@ static int tsbat_sysrst_set_cur_state(struct thermal_cooling_device *cdev, unsig

pr_debug("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");

pr_debug("*****************************************");

pr_debug("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");

-

- *(unsigned int *)0x0 = 0xdead; /* To trigger data abort to reset the system for thermal protection. */

+ //wang add 20180528

+ //*(unsigned int *)0x0 = 0xdead; /* To trigger data abort to reset the system for thermal protection. */

}

return 0;

}

3. 修改 mtk_battery.c

alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery.c

@@ [-2041,15](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery.c;h=424147210393fd33fb205b40414683f5549b3cc2;hb=424147210393fd33fb205b40414683f5549b3cc2#l2041) [+2041,15](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery.c;h=97a739dc0bbddd02b32c85c1c99da6006e81e746;hb=97a739dc0bbddd02b32c85c1c99da6006e81e746#l2041) @@ unsigned int TempConverBattThermistor(int temp)

int i;

unsigned int TBatt_R_Value = 0xffff;

- if (temp >= Fg_Temperature_Table[20].BatteryTemp) {

- TBatt_R_Value = Fg_Temperature_Table[20].TemperatureR;

+ if (temp >= Fg_Temperature_Table[NTC_NUM - 1].BatteryTemp) {

+ TBatt_R_Value = Fg_Temperature_Table[NTC_NUM - 1].TemperatureR;

} else if (temp <= Fg_Temperature_Table[0].BatteryTemp) {

TBatt_R_Value = Fg_Temperature_Table[0].TemperatureR;

} else {

RES1 = Fg_Temperature_Table[0].TemperatureR;

TMP1 = Fg_Temperature_Table[0].BatteryTemp;

- for (i = 0; i <= 20; i++) {

+ for (i = 0; i < NTC_NUM; i++) {

if (temp <= Fg_Temperature_Table[i].BatteryTemp) {

RES2 = Fg_Temperature_Table[i].TemperatureR;

TMP2 = Fg_Temperature_Table[i].BatteryTemp;

@@ [-2078,13](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery.c;h=424147210393fd33fb205b40414683f5549b3cc2;hb=424147210393fd33fb205b40414683f5549b3cc2#l2078) [+2078,13](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery.c;h=97a739dc0bbddd02b32c85c1c99da6006e81e746;hb=97a739dc0bbddd02b32c85c1c99da6006e81e746#l2078) @@ int BattThermistorConverTemp(int Res)

if (Res >= Fg_Temperature_Table[0].TemperatureR) {

TBatt_Value = -40;

- } else if (Res <= Fg_Temperature_Table[20].TemperatureR) {

- TBatt_Value = 60;

+ } else if (Res <= Fg_Temperature_Table[NTC_NUM - 1].TemperatureR) {

+ TBatt_Value = 80;

} else {

RES1 = Fg_Temperature_Table[0].TemperatureR;

TMP1 = Fg_Temperature_Table[0].BatteryTemp;

- for (i = 0; i <= 20; i++) {

+ for (i = 0; i < (NTC_NUM - 1); i++) {

if (Res >= Fg_Temperature_Table[i].TemperatureR) {

RES2 = Fg_Temperature_Table[i].TemperatureR;

TMP2 = Fg_Temperature_Table[i].BatteryTemp;

@@ [-2098,7](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery.c;h=424147210393fd33fb205b40414683f5549b3cc2;hb=424147210393fd33fb205b40414683f5549b3cc2#l2098) [+2098,7](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery.c;h=97a739dc0bbddd02b32c85c1c99da6006e81e746;hb=97a739dc0bbddd02b32c85c1c99da6006e81e746#l2098) @@ int BattThermistorConverTemp(int Res)

TBatt_Value = (((Res - RES2) * TMP1) + ((RES1 - Res) * TMP2)) / (RES1 - RES2);

}

- bm_trace("[BattThermistorConverTemp] %d %d %d %d %d %d\n", RES1, RES2, Res, TMP1, TMP2, TBatt_Value);

+ bm_trace("[BattThermistorConverTemp] %d %d %d %d %d %d, wwwwwNTC_NUM = %d\n", RES1, RES2, Res, TMP1, TMP2, TBatt_Value, NTC_NUM);

return TBatt_Value;

}

@@ [-2334,8](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery.c;h=424147210393fd33fb205b40414683f5549b3cc2;hb=424147210393fd33fb205b40414683f5549b3cc2#l2334) [+2334,8](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery.c;h=97a739dc0bbddd02b32c85c1c99da6006e81e746;hb=97a739dc0bbddd02b32c85c1c99da6006e81e746#l2334) @@ int force_get_tbat(bool update)

bat_temperature_val = force_get_tbat_internal(update);

- while (counts < 5 && bat_temperature_val >= 60) {

- bm_err("[force_get_tbat]over60 count=%d, bat_temp=%d\n", counts, bat_temperature_val);

+ while (counts < 5 && bat_temperature_val >= 80) {//wang submit 20180524

+ bm_err("[force_get_tbat]over80 count=%d, bat_temp=%d\n", counts, bat_temperature_val);

bat_temperature_val = force_get_tbat_internal(true);

counts++;

}

4.修改 mtk_battery_internal.h

alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery_internal.h

@@ [-34,7](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery_internal.h;h=6c2293cbfad5a14e479c095779d82e88d1032bcb;hb=6c2293cbfad5a14e479c095779d82e88d1032bcb#l34) [+34,7](http://192.168.11.104/gitweb/?p=alps-mp-o1.mp1-V1.git;a=blob;f=alps/kernel-4.4/drivers/power/mediatek/battery/mtk_battery_internal.h;h=304fc84470f8bdfdece2439cc5376b15c0b4dfba;hb=304fc84470f8bdfdece2439cc5376b15c0b4dfba#l34) @@

#define SHUTDOWN_TIME 40

#define AVGVBAT_ARRAY_SIZE 30

#define INIT_VOLTAGE 3450

-#define BATTERY_SHUTDOWN_TEMPERATURE 60

+#define BATTERY_SHUTDOWN_TEMPERATURE 80

/* ============================================================ */

/* typedef and Struct*/

至此,本篇已结束。转载网络的文章,小编觉得很优秀,欢迎点击阅读原文,支持原创作者,如有侵权,恳请联系小编删除。同时感谢您的阅读,期待您的关注。

程序员Android
这是一个专注提供 Java Android 知识体系服务的公众号。 和你一起终身学习,小安愿做你成长道路上的垫脚石,不断垫高你的高度,衬托你的威仪。 风里雨里,我们一直在 Java Android 学习的路上支持你!
 最新文章