This is an old revision of the document!
Table of Contents
Power Off and Wake Up using GPIO Key Button
This functionality is available with following version.
- Ubuntu : The release version should be 3.14.79-107 (Feb 26, 2017) or higher.
- Android : It will be included in the next version.
The basic working flow is as following.
[Set-up Flow]
- Connect a tab button to the pin port you want to use. (Please refer to the available key table in the end part of this wiki page.)
- Setting GPIO number using boot.ini
- Run reboot
[Basic Working Scenario]
- After booting, based on the GPIO number that is described in boot.ini, gpio_keypad driver will generate KEY_POWER event when you push tab button, and it will make the system power off.
- After power off is done, bl301 will check the GPIO status periodically based on the GPIO number that is reported from kernel, and when you push the button, board will wake up.
- For the key wake up, the key chattering time is 300ms.
---->>> Power Key Event root@odroid64:~# [ 84.515844] reboot: Power down ..... ERprocess cCEC cfg:0x2f WAKEUP GPIO cfg:0x000000d6 set vddee to 0x0352mv 06f1932000000000 (Holding here...) --->>> Power Key Event exit_reason:0x09 set vddee to 0x042emv BL1:08GXBB:BL1:08dafd:0a8993;FEAT:EDFC318C;POC:3;RCY:0;EMMC:800;NAND:81;SD:0;READ:0;CHK:0; TE: 321463 BL2 Built : 11:44:26, Nov 25 2015. ..... ..... secure task start! high task start! low task start! ..... U-Boot 2015.01-00187-g3eb97d4-dirty (Feb 22 2017 - 14:25:18)
Hardware Example
For example, we will use Pin#35 of 40pin expansion connector.
The pin is assigned to GPIOY.BIT3 and its GPIO number is #214.
Its default pin pulled status is UP (High) and switch active will be Low,
so you should connect another port of tab switch to Ground (GND), Pin#39.
Setting boot.ini
You can assign GPIO number with env gpiopower in boot.ini.
# gpio power key : J2 (2x20) Pin#35 , GPIOY.BIT3 setenv gpiopower "214" ... ... setenv bootargs ${bootargs} gpiopower=${gpiopower}
Setting Power Button Action for Power Off
Ubuntu
When you turn the board off using power button, you need to change power key action pattern.
- Open Power Management Preferences : [System] → [Preferences] → [Hardware] → [Power Management]
- and then Select [General] tab
Android
In case of Android, one short power key event is used for sleep and with long key event, you can handle options of power off/reboot.
With Android Marshmallow v2.4 or higher version, it's available to enter power off sequence using long-pressing (5 sec).
Available Key Numbers
1. J2 - 2×20 pins
Pin Number | Net Name | GPIO Number | Active Level | Pin Number | Net Name | GPIO Number | Active Level |
---|---|---|---|---|---|---|---|
1 | 3.3V Power | 2 | 5.0V Power | ||||
3 | I2CA_SDA | N/A | 4 | 5.0V Power | |||
5 | I2CA_SCL | N/A | 6 | Ground | |||
7 | GPIOX.BIT21 | GPIO#249 | High → Low | 8 | TXD1 | N/A | |
9 | Ground | 10 | RXD1 | N/A | |||
11 | GPIOX.BIT19 | GPIO#247 | High → Low | 12 | GPIOX.BIT10 | GPIO#238 | High → Low |
13 | GPIOX.BIT11 | GPIO#239 | High → Low | 14 | Ground | ||
15 | GPIOX.BIT9 | GPIO#237 | High → Low | 16 | GPIOX.BIT8 | GPIO#236 | High → Low |
17 | 3.3V Power | 18 | GPIOX.BIT5 | GPIO#233 | High → Low | ||
19 | GPIOX.BIT7 | GPIO#235 | High → Low | 20 | Ground | ||
21 | GPIOX.BIT4 | GPIO#232 | High → Low | 22 | GPIOX.BIT3 | GPIO#231 | High → Low |
23 | GPIOX.BIT2 | GPIO#230 | High → Low | 24 | GPIOX.BIT1 | GPIO#229 | High → Low |
25 | Ground | 26 | GPIOY.BIT14 | GPIO#225 | Low → High | ||
27 | I2CB_SDA | N/A | 28 | I2CB_SCL | N/A | ||
29 | GPIOX.BIT0 | GPIO#228 | High → Low | 30 | Ground | ||
31 | GPIOY.BIT8 | GPIO#219 | High → Low | 32 | GPIOY.BIT13 | GPIO#224 | High → Low |
33 | GPIOX.BIT6 | GPIO#234 | Low → High | 34 | Ground | ||
35 | GPIOY.BIT3 | GPIO#214 | High → Low | 36 | GPIOY.BIT7 | GPIO#218 | High → Low |
37 | ADC.AIN1 | N/A | 38 | 1.8V Power | N/A | ||
39 | Ground | 40 | ADC.AIN0 | N/A |
2. J7 - 1×7 pins
Pin Number | Net Name | GPIO Number | Active Level |
---|---|---|---|
1 | Ground | ||
2 | GPIOAO.BIT6 | GPIO#128 | High → Low |
3 | P5V0 | 5.0V Power | |
4 | GPIOAO.BIT8 | GPIO#130 | High → Low |
5 | GPIOAO.BIT10 | GPIO#132 | High → Low |
6 | GPIOAO.BIT9 | GPIO#131 | High → Low |
7 | GPIOAO.BIT11 | GPIO#133 | High → Low |
3. SW1
Pin Number | Net Name | GPIO Number | Active Level |
---|---|---|---|
1 | NC | N/A | |
2 | GPIOY.BIT5 | GPIO#216 | High → Low |
3 | GND | Ground |