[RK3288][Android6.0] 調試筆記 --- 通用GPIO驅動控制LED【轉】

來源:互聯網
上載者:User

標籤:csdn   write   oid   完成   解決方案   bin   使用   root   roc   

本文轉載自:http://m.blog.csdn.net/kris_fei/article/details/69553422

Platform: ROCKCHIP
OS: Android 6.0
Kernel: 3.10.92

由於板子沒有lcd無法得知sd卡升級是否完成,因此使用LED顯示.
Recovery中升級完成後控制GPIO輸出高電平點亮LED.

系統內建GPIO控制驅動:
核心已經內建了通用GPIO驅動,可以直接在使用者空間操作.
路徑: /sys/class/gpio
[email protected]:/sys/class/gpio # ls
export
gpiochip0
gpiochip120
gpiochip152
gpiochip184
gpiochip216
gpiochip24
gpiochip248
gpiochip280
gpiochip56
gpiochip88
unexport

比如我要操作GPIO8_A6作為高電平輸出有效, 那麼有以下問題:
1. 對應的gpio number是多少呢?
2. 如何設定成輸出
3. 如何輸出高電平

問題1:
可以通過/sys/kernel/debug/gpio查詢資訊:
[email protected]:/sys/kernel/debug # cat gpio                                       
//snip
GPIOs 184-215, platform/ff770000.pinctrl, gpio6:
 gpio-193 (?                   ) in  hi
 gpio-194 (?                   ) in  hi

GPIOs 216-247, platform/ff770000.pinctrl, gpio7:
 gpio-218 (enable              ) out hi
 gpio-219 (lcd_en              ) in  hi
 gpio-220 (lcd_cs              ) in  hi
 gpio-221 (gslX680 wake pin    ) out hi
 gpio-222 (gslX680 irq pin     ) out lo
 gpio-223 (headset_gpio        ) in  hi
 gpio-233 (?                   ) in  hi
 gpio-234 (?                   ) in  hi

GPIOs 248-279, platform/ff770000.pinctrl, gpio8:

GPIOs 280-311, platform/ff770000.pinctrl, gpio15:

可以看到gpio8是以nubmer為248開始, 那麼GPIO8_A6就是 248 + 6 = 254
接下來就可以匯出gpio了
[email protected]:/sys/class/gpio # echo 254 > export                          
[email protected]:/sys/class/gpio # ls
export
gpio254
......

問題2
[email protected]:/sys/class/gpio/gpio254 # echo out > direction                     
[email protected]:/sys/class/gpio/gpio254 # cat direction                            
out

問題3:
[email protected]:/sys/class/gpio/gpio254 # echo 1 > value                           
[email protected]:/sys/class/gpio/gpio254 # cat value                                
1

解決方案:
init.rc
[[email protected]:~/rk3288/device/rockchip/common/recovery/etc]$ g df
diff --git a/recovery/etc/init.rc b/recovery/etc/init.rc
index efe2a5d..75d7554 100755
--- a/recovery/etc/init.rc
+++ b/recovery/etc/init.rc
@@ -85,6 +85,12 @@ on late-init
 on property:sys.powerctl=*
    powerctl ${sys.powerctl}
 
+#Kris, 170407, GPIO8_A6 -> gpio254, used to inform sd upgrade complete.
+on property:sdupgrade.complete=true
+       write /sys/class/gpio/export 254
+       write /sys/class/gpio/gpio254/direction out
+       write /sys/class/gpio/gpio254/value 1
+
 service ueventd /sbin/ueventd
     critical
     seclabel u:r:ueventd:s0

recovery.cpp
[[email protected]:~/rk3288/bootable/recovery]$ g df
diff --git a/recovery.cpp b/recovery.cpp
index 8299672..a0edc15 100755
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -2285,6 +2285,10 @@ HANDLE_STATUS :
         strcat(kernellogPath, "/kernel.txt");
         save_kernel_log(kernellogPath);
         #endif
+
+       //Kris, 170407, light led on after sd upgrade complete.
+       property_set("sdupgrade.complete", "true");
+
                if (bSDMounted)
             checkSDRemoved();


參考:
http://blog.csdn.net/cjsycyl/article/details/46310939

[RK3288][Android6.0] 調試筆記 --- 通用GPIO驅動控制LED【轉】

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.