Kernel Exception导致手机重启案例分析

news2024/9/23 3:22:12

28c9da71e49cdac84009a7b7179ba59c.gif

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

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

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

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

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

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

6500abb7e8c5454b95d6778263596ee3.jpeg

高温情况下,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 Framework 知识库
https://docs.qq.com/doc/DSXBmSG9VbEROUXF5

友情推荐:

Android 开发干货集锦

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

b536fae6278852ef7f266bf1822de3a5.jpeg

点击阅读原文,为大佬点赞!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/839817.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

网页版Java(Spring/Spring Boot/Spring MVC)五子棋项目(二)前后端实现用户的登录和注册功能【用户模块】

网页版Java五子棋项目&#xff08;二&#xff09;前后端实现用户的登录和注册功能【用户模块】 在用户模块我们要清楚要完成的任务一、MyBatis后端操作数据库1. 需要在数据库创建用户数据库1. 用户id2. 用户名3. 密码4. 天梯积分5. 总场数6. 获胜场数 2. 创建用户类User和数据库…

网络开发-IO模型

基本概念 I/O即数据的读取&#xff08;接收&#xff09;或写入&#xff08;发送&#xff09;操作 通常用户进程中的一个完整I/O分为两个阶段 用户进程空间<-->内核空间内核空间<-->设备空间&#xff08;磁盘、网卡等&#xff09; I/O分为内存I/O、网络I/O和磁盘…

python机器学习(六)决策树(上) 构造树、信息熵的分类和度量、信息增益、CART算法、剪枝

决策树算法 模拟相亲的过程&#xff0c;通过相亲决策图&#xff0c;男的去相亲&#xff0c;会先选择性别为女的&#xff0c;然后依次根据年龄、长相、收入、职业等信息对相亲的另一方有所了解。 通过决策图可以发现&#xff0c;生活中面临各种各样的选择&#xff0c;基于我们的…

考研408 | 【计算机网络】物理层

导图&#xff1a; 一、通信基础 基本概念&#xff1a; 物理层接口特性&#xff1a;物理层解决如何在连接各种计算机的传输媒体上传输数据比特流&#xff0c;而不是指具体的传输媒体。 物理层主要任务&#xff1a;确定与传输媒体接口有关的一些特性 典型的数据通信模型 数据通…

SAP-MM-发票校验的重复校验功能

路径&#xff1a;SPRO-物料管理-后勤发票校验-收入发票-设置重复发票检查 按公司代码设置重复检查&#xff0c;可以按三个方式进行检查&#xff0c;公司代码、参照、发票日期&#xff0c;如果此处未维护就是按供应商&#xff08;XK02&#xff09;的六项进行检查 但是如果两处都…

latex插入不连续的中线

在上面的示例中&#xff0c;\cmidrule(lr){1-3} 表示在第 1 列到第 3 列之间添加不连续的中线&#xff0c;\cmidrule(lr){4-6} 表示在第 4 列到第 6 列之间添加不连续的中线&#xff0c;以此类推。你可以根据需要调整列的范围和对齐方式。

合并两个有序链表(leetcode)

题目 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例 输入&#xff1a;l1 [1,2,4], l2 [1,3,4] 输出&#xff1a;[1,1,2,3,4,4]思路 每次递归都会比较当前两个节点的值&#xff0c;选择较小的节点作为合并后的链…

Java8 文件工具类 FileUtils(持续更新中)

1. Java8 文件处理 使用 Java8 的 java.nio.file 方法&#xff0c;来进行文件处理。 1.1. 读文件 所有内容一次读出来&#xff0c;结果为字符串。 1.1.1. 代码 /*** 读取文件** param path 文件路径* return 文件内容&#xff08;字符串&#xff09;*/public static String…

Python导出SqlServerl数据字典为excel

sql代码 SELECTtableName D.name ,tableIntroduce isnull(F.value, ),sort A.colorder,fieldName A.name,catogary B.name,bytes A.Length,lengths COLUMNPROPERTY(A.id, A.name, PRECISION),scales isnull(COLUMNPROPERTY(A.id, A.name, Scale), 0),isOrNotNull Cas…

差值结构的相互作用能

( A, B )---3*30*2---( 1, 0 )( 0, 1 ) 让网络的输入只有3个节点&#xff0c;AB训练集各由6张二值化的图片组成&#xff0c;让A&#xff0c;B中各有3个点&#xff0c;且不重合&#xff0c;统计迭代次数并排序。 其中有10组数据 差值结构 A-B 迭代次数 构造平均列 平均列…

2.4G芯片G350开发的遥控玩具解决方案

玩具从早期的简单功能&#xff0c;到现如今各种各样的智能操作&#xff0c;发展的速度也是飞速的。随着玩具市场的逐步完善与推进&#xff0c;中国的智能玩具市场也出现了很多远程遥控玩具。遥控玩具也是从最初的有线到现在的无线&#xff0c;从地上跑的到天上飞的&#xff0c;…

vue2-常用的修饰符有哪些应用场景?

1、修饰符是什么&#xff1f; 在程序的世界里&#xff0c;修饰符是用于限定类型以及类型成员的声明的一种 符号。 在vue中&#xff0c;修饰符处理了许多DOM事件的细节&#xff0c;让我们不再需要花大量的时间去处理这些重复的事情&#xff0c;而能有更多的精力专注于程序的逻辑…

安全作业-Race竞争型漏洞、原型链污染

1.race漏洞一直卡在虚拟机安装上(待研究) 2.原型链污染 一、第一题js代码 const express require(express) var hbs require(hbs); var bodyParser require(body-parser); const md5 require(md5); var morganBody require(morgan-body); const app express(); var use…

入侵检测-IDS

1. 什么是IDS&#xff1f; IDS&#xff08;intrusion detection system&#xff09;入侵检测系统&#xff0c;是一种对网络传输进行即时监视&#xff0c;在发现可疑传输时发出警报或者采取主动反应措施的网络安全设备。它会对系统的运行状态进行监视&#xff0c;发现各种攻击企…

外边距实现居中的写法

1、代码实例 2、默认是贴到左侧对齐的&#xff0c;但我们想要把他贴到中间对齐 3、居中的写法 4、这样就可以保证盒子居中了 5、以上写法仅适于行内元素和行内块元素的写法&#xff0c;有没有什么方法适用于行内块元素&#xff1a;可以添加text-align:center进行添加&#xff0…

stl_list类(使用+实现)(C++)

list 一、list-简单介绍二、list的常用接口1.常见构造2.iterator的使用3.Capacity和Element access4.Modifiers5.list的迭代器失效 三、list实现四、vector 和 list 对比五、迭代器1.迭代器的实现2.迭代器的分类&#xff08;按照功能分类&#xff09;3.反向迭代器(1)、包装逻辑…

Julia 日期和时间

Julia 通过 Dates 模块提供了以下三个函数来处理日期和时间&#xff1a; Date&#xff1a;表示日期&#xff0c;精确到日&#xff0c;只显示日期。DateTime&#xff1a;表示日期和时间&#xff0c;精确到毫秒。DateTime&#xff1a;表示日时间&#xff0c;精确到纳秒&#xff…

Unity 3D ScrollRect和ScrollView回弹问题的解决

你是否是这样&#xff1f; Content高度 < 全部Cell加在一起的总高 他就认为你的全部Cell加起来就跟Content一样大&#xff0c;所以才出现了这种完全回弹 我该怎么办&#xff1f; 很简单&#xff0c;改变Content的长度跟所有Cell的和一样大 void RefreshSize(){float allD…

分布式Redis详解

目录 前言安装redis的俩种方法Redis 与 MySQL的区别Redis可以实现那些功能Redis常用的数据类型有序列表的底层是如何实现的?什么是跳跃表 Redis在Spring中的使用 前言 Redis我们最近学习必备工具之一了, 接下来我们将讲解Redis的简单应用 ,以及相关原理 安装redis的俩种方法…