This article was reproduced from: http://m.blog.csdn.net/kris_fei/article/details/69553422
Platform:rockchip
Os:android 6.0
kernel:3.10.92
Because the board does not have LCD can not know the SD card upgrade is completed, so use LED display.
Control the Gpio output high-lit LEDs after the upgrade is complete in the recovery.
system comes with Gpio control driver:
The kernel has its own generic Gpio driver and can operate directly in user space.
Path:/sys/class/gpio
[Email Protected]:/sys/class/gpio # ls
Export
Gpiochip0
gpiochip120
gpiochip152
gpiochip184
gpiochip216
Gpiochip24
gpiochip248
gpiochip280
Gpiochip56
Gpiochip88
Unexport
For example, if I want to operate the GPIO8_A6 as a high-level output, then there are the following issues:
1. What is the corresponding Gpio number?
2. How to set the output
3. How to Output High level
Question 1:
Information can be queried via/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:
You can see that Gpio8 starts with a nubmer of 248, then GPIO8_A6 is 248 + 6 = 254
Then we can export the Gpio.
[Email Protected]:/sys/class/gpio # echo 254 > Export
[Email Protected]:/sys/class/gpio # ls
Export
gpio254
......
Question 2
[Email protected]:/sys/class/gpio/gpio254 # echo out > direction
[Email protected]:/sys/class/gpio/gpio254 # Cat Direction
Out
Question 3:
[Email protected]:/sys/class/gpio/gpio254 # echo 1 > value
[Email protected]:/sys/class/gpio/gpio254 # cat Value
1
Workaround:
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 @@ -85,6 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 @@ -2285,6:
strcat (Kernellogpath, "/kernel.txt");
Save_kernel_log (Kernellogpath);
#endif
+
+//kris, 170407, light LEDs on after SD upgrade complete.
+ Property_set ("Sdupgrade.complete", "true");
+
if (bsdmounted)
Checksdremoved ();
Reference:
http://blog.csdn.net/cjsycyl/article/details/46310939
[RK3288] [Android6.0] Debug Notes---Universal GPIO driver control led "turn"