[Linux Device Driver] 系統軟重啓無效

0. 背景

問題表現是系統,系統關機狀態下插入USB線,按power設備不能開機;

同時還有一個現象,關機插入USB充電狀態下,拔掉USB,系統無法shut down;

log如下:

[  153.742220] <<GTP-DBG>>[gt1x_power_switch:371]GTP power off.
[  153.811749] <<GTP-INF>>[gt1x_suspend:2253] Suspend end...
[  160.339053] healthd: battery l=58 v=3915 t=25.0 h=2 st=3 c=-896 fc=4200000 cc=0 chg=
[  160.339335] charger: [160339] shutting down
[  160.880636] charger: [160880] shutting down
[  160.880787] charger: [160880] shutting down
[  160.884019] charger: [160883] shutting down
[  161.072181] charger: [161072] shutting down
[  165.856121] charger: [165856] shutting down
[  165.857443] charger: [165857] shutting down
[  165.957515] charger: [165957] shutting down
[  166.144330] charger: [166144] shutting down
[  170.945760] charger: [170945] shutting down
[  170.946590] charger: [170946] shutting down
[  170.962459] charger: [170962] shutting down
[  171.148936] charger: [171148] shutting down
[  172.032289] healthd: battery l=58 v=3913 t=25.0 h=2 st=3 c=-896 fc=4200000 cc=0 chg=
[  172.032574] charger: [172032] shutting down
[  175.933014] charger: [175932] shutting down
[  175.934499] charger: [175934] shutting down
[  176.034951] charger: [176034] shutting down
[  176.165505] charger: [176165] shutting down
[  181.022700] charger: [181022] shutting down
[  181.031062] charger: [181031] shutting down
[  181.042673] charger: [181042] shutting down
[  181.225727] charger: [181225] shutting down
[  186.084580] charger: [186084] shutting down
[  186.090749] charger: [186090] shutting down
[  186.092509] charger: [186092] shutting down
[  186.314631] charger: [186314] shutting down
[  191.201524] charger: [191201] shutting down
[  191.202926] charger: [191202] shutting down
[  191.205084] charger: [191205] shutting down
[  191.404970] charger: [191404] shutting down

1. 硬重啓

其實這個並非無法重啓,只是軟重啓功能失效,使用硬重啓長按power健10幾秒,是可以重啓設備的;

如下修改可以把硬重啓時間從10秒修改到2秒左右;
在這裏插入圖片描述

注意這兩個時間不是隨便填的,可以檢索內核文檔看看;

grep -nr "qcom,s1-timer" ./kernel/msm-4.9/Documentation/

vim ./kernel/msm-4.9/Documentation/devicetree/bindings/input/qpnp-power-on.txt +166


 The below mentioned properties are required only when qcom,support-reset DT
 property is defined and is set to 1.

 - qcom,s1-timer         The debounce timer for the BARK interrupt for
                that reset source. Value is specified in ms.
                Supported values are:
                 - 0, 32, 56, 80, 128, 184, 272, 408, 608, 904
                  1352, 2048, 3072, 4480, 6720, 10256
 - qcom,s2-timer         The debounce timer for the S2 reset specified
                 in ms. On the expiry of this timer, the PMIC
                 executes the reset sequence.
                Supported values are:
                 - 0, 10, 50, 100, 250, 500, 1000, 2000
 - qcom,s2-type          The type of reset associated with this source.
                The supported resets are:
                SOFT(0), WARM(1), SHUTDOWN(4), HARD(7)

沒有特殊的原因不要修改硬重啓時間,原因是時間被改短了,本來開機之後,你按power鍵只是想喚醒下系統,結果直接重啓了。當然,你要是一個項目沒power健,比如用單片機控制,那當我沒說-_-||。

2. 軟重啓解決

一般檢查CAP_SYS_BOOT 權限有沒有提供:

diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc 
index f63db89..380772b 100644 
--- a/rootdir/etc/init.qcom.rc 
+++ b/rootdir/etc/init.qcom.rc 
@@ -917,6 +917,7 @@ service charger /system/bin/charger 
class charger 
user system 
group system graphics input 
+ capabilities SYS_BOOT 
seclabel u:r:charger:s0 

我這個比較特殊,是人爲修改出來的BUG,user 版本和debug版本走不同的init.qcom.rc ,

但是這個權限,之前的大兄弟忘了加,最終修改如下:

diff --git a/device/qcom/common/rootdir/etc/init.qcom.debug.rc 
b/device/qcom/common/rootdir/etc/init.qcom.debug.rc
--- a/device/qcom/common/rootdir/etc/init.qcom.debug.rc
+++ b/device/qcom/common/rootdir/etc/init.qcom.debug.rc
@@ -922,6 +922,7 @@ service charger /system/bin/charger
     class charger
     user system
     group system graphics input
+    capabilities SYS_BOOT
     seclabel u:r:charger:s0

 service vendor.ssr_diag /system/vendor/bin/ssr_diag
diff --git a/device/qcom/common/rootdir/etc/init.qcom.user.rc 
b/device/qcom/common/rootdir/etc/init.qcom.user.rc
--- a/device/qcom/common/rootdir/etc/init.qcom.user.rc
+++ b/device/qcom/common/rootdir/etc/init.qcom.user.rc
@@ -925,6 +925,7 @@ service charger /system/bin/charger
     class charger
     user system
     group system graphics input
+    capabilities SYS_BOOT
     seclabel u:r:charger:s0
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章