'ODROID-N2' on this page refers to the ODROID-N2 series (N2, N2+, N2L).
Power Off and Wake Up using GPIO Key Button
- This section is based on the ORDOID-N2.
- But It also works on the ODROID-C4.
This section describes how to set up GPIO key button for power off and wake up purpose.
The brief set-up flow is as following.
- Connect a tab button to the pin port you want to use
- Set GPIO number using boot.ini
1. Hardware Set-Up
Here is an example.
We use following items.
A reference of circuit connections with the button is as following.
- Please consider suitable series resistance values with your LEDs.
- For example, 100 ohm for a standard red led (1.2V/20mA).
For this example, we will use Pin#11 of 40pin expansion connector.
The pin is assigned to GPIOX.BIT3 and its GPIO number is #479.
Connect the red line to Pin#11.
Its default pin pulled status is high and switch active will be Low, so you should connect the gray line of tab switch to Ground (ex:Pin#9).
Function | N2 Pin Assign | C4 Pin Assign | GPIO Number |
---|---|---|---|
Button GPIO | #11 (GPIO) | #11 (GPIO) | 479 |
Button Active | #9 (GND) | #9 (GND) | - |
LED Positive | #1 (3.3V) | #1 (3.3V) | - |
LED Negative | #6 (GND) | #6 (GND) | - |
2. Available Keys
Here are the available key examples using 40-pin connector and 7-pin connector.
You can find the pin assign examples for Red Line and Gray Line.
ODROID-N2
(1) J2 - 2×20 pins
Active Level (Gray Line) | GPIO Number | Pin Number (Red Line) | Pin Number (Red Line) | GPIO Number | Active Level (Gray Line) |
---|---|---|---|---|---|
- | 3.3V Power | 1 | 2 | 5.0V Power | - |
Active High | GPIO#493 | 3 | 4 | 5.0V Power | - |
Active Low | GPIO#494 | 5 | 6 | Ground | - |
Active High | GPIO#473 | 7 | 8 | GPIO#488 | Active Low |
- | Ground | 9 | 10 | GPIO#489 | Active Low |
Active Low | GPIO#479 | 11 | 12 | GPIO#492 | Active Low |
Active Low | GPIO#480 | 13 | 14 | Ground | - |
Active Low | GPIO#483 | 15 | 16 | GPIO#476 | Active Low |
- | 3.3V Power | 17 | 18 | GPIO#477 | Active Low |
Active Low | GPIO#484 | 19 | 20 | Ground | - |
Active Low | GPIO#485 | 21 | 22 | GPIO#478 | Active Low |
Active Low | GPIO#487 | 23 | 24 | GPIO#486 | Active Low |
- | Ground | 25 | 26 | GPIO#464 | Active High |
- | GPIO#474 | 27 | 28 | GPIO#475 | Active Low |
Active Low | GPIO#490 | 29 | 30 | Ground | - |
Active Low | GPIO#491 | 31 | 32 | GPIO#472 | Active High |
Active Low | GPIO#481 | 33 | 34 | Ground | |
Active High | GPIO#482 | 35 | 36 | GPIO#495 | High-Z |
- | - | 37 | 38 | - | - |
- | Ground | 39 | 40 | - | - |
(2) J7 - 1×7 pins
Pin Number (Red Line) | GPIO Number | Active Level (Gray Line) |
---|---|---|
1 | Ground | - |
2 | GPIO#471 | Active High |
3 | 5.0V Power | - |
4 | GPIO#460 | Active High |
5 | GPIO#462 | Active High |
6 | GPIO#461 | Active High |
7 | GPIO#463 | Active High |
[ Known Issue ]
- Some ports those default level is pull-down are not available with the latest release version.
- Pin#5 and Pin#28 don't work normally for wake-up after poweroff because of the default level (1.1V).
3. SW Set-up using boot.ini
ODROID-N2
setenv bootargs "root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait rw ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 elevator=noop hdmimode=${hdmimode} cvbsmode=576cvbs max_freq_a53=${max_freq_a53} max_freq_a73=${max_freq_a73} maxcpus=${maxcpus} voutmode=${voutmode} ${cmode} disablehpd=${disablehpd} cvbscable=${cvbscable} overscan=${overscan} ${hid_quirks} monitor_onoff=${monitor_onoff} logo=osd0,loaded ${cec_enable}" ### in case of GPIOX.3 (Pin 11) of 2x20 pins connector setenv gpiopower "479" setenv bootargs ${bootargs} gpiopower=${gpiopower}
ODROID-C4
setenv bootargs "root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait rw ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 elevator=noop hdmimode=${hdmimode} cvbsmode=576cvbs max_freq_a53=${max_freq_a53} maxcpus=${maxcpus} voutmode=${voutmode} ${cmode} disablehpd=${disablehpd} cvbscable=${cvbscable} overscan=${overscan} ${hid_quirks} monitor_onoff=${monitor_onoff} logo=osd0,loaded ${cec_enable}" ### in case of GPIOX.3 (Pin 11) of 2x20 pins connector setenv gpiopower "479" setenv bootargs ${bootargs} gpiopower=${gpiopower}
Just add the three lines in the above example in to your boot.ini file.
The latest boot.ini file
4. Wake up Action
To wake-up after power off, long-pressing over 2 seconds is needed.
5. Heartbeat LED Action on the Power Button LED
For LED heartbeat action, you need to modify this dtsi file, build dtb image again and replace meson64_odroidn2.dtb in /media/boot.
ex) GPIOX.BIT12, Pin#8
leds { compatible = "gpio-leds"; blueled { label = "blue:heartbeat"; gpios = <&gpio GPIOX_12 GPIO_ACTIVE_HIGH>; linux,default-trigger = "heartbeat"; }; };
Function | N2 Pin Assign | C4 Pin Assign | GPIO Number |
---|---|---|---|
Button GPIO | #11 | #11 | 479 |
Button Active | #9 | #9 | - |
LED Positive | #8 | #8 | 488 |
LED Negative | #6 | #6 | - |
6. How to modify dtb using fdtget and fdtput
Install device-tree-compiler first.
- target
root@odroid:~$ sudo apt-get install device-tree-compiler
Backup your original dtb file.
- target
root@odroid:~$ sudo cp /media/boot/meson64_odroidn2.dtb /media/boot/meson64_odroidn2.dtb.backup
Check the current leds node.
The original led gpio is GPIOAO_11 and it's used as heartbeat blue led.
- target
root@odroid:~$ fdtget /media/boot/meson64_odroidn2.dtb /leds/blueled gpios 24 11 0
Now, change the node.
For this example, new led gpio is GPIOX_12.
- target
root@odroid:~$ fdtput /media/boot/meson64_odroidn2.dtb /leds/blueled gpios 26 78 0
- target
root@odroid:~$ fdtget /media/boot/meson64_odroidn2.dtb /leds/blueled gpios 26 78 0
Then, do system reboot.
- target
$ sudo reboot
Additional Description of 'gpios' array
There are 3 arguments in 'gpios'.
gpios = <&gpio_ao GPIOAO_11 GPIO_ACTIVE_HIGH>;
1st argument
It can be one of &gpio or &gpio_ao.
&gpio | 26 |
&gpio_ao | 24 |
2nd argument
The values are defined in the following header file.
https://github.com/hardkernel/linux/blob/odroidn2-4.9.y/include/dt-bindings/gpio/meson-g12a-gpio.h
3rd argument
It can be one of GPIO_ACTIVE_HIGH or GPIO_ACTIVE_LOW.
https://github.com/hardkernel/linux/blob/odroidn2-4.9.y/include/dt-bindings/gpio/gpio.h#L13
GPIO_ACTIVE_HIGH | 0 |
GPIO_ACTIVE_LOW | 1 |