Power Off and Wake Up using GPIO Key Button

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.

  1. Connect a tab button to the pin port you want to use
  2. Set GPIO number using boot.ini

Here is an example.

We use following items.

A reference of circuit connections with the button is as following.

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 GPIO Number
Button GPIO #11 (GPIO) 479
Button Active #9 (GND) -
LED Positive #1 (3.3V) -
LED Negative #6 (GND) -

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.

(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).
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}

Just add the three lines in the above example in to your boot.ini file.
The latest boot.ini file

To wake-up after power off, long-pressing over 2 seconds is needed.

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 GPIO Number
Button GPIO #11 479
Button Active #9 -
LED Positive #8 -
LED Negative #6 -