GPIO Power Button

I know this was asked before but I didn’t found a good solution over the ones proposed. So could someone help me ?

I want a power button on the GPIO, I know that there is some pads on the hardware that I could solder some wires but I don’t want to use this as I will need to change several boards.

I want just a push button to power on (that is turn on or wake from sleep) and power off (that is a short press to sleep or long press to have the turnoff/reset menu). I will not need to use this GPIOs for reset, firmware upgrades, SD boot or any other use.

I thought about 3 possible aproaches:

1- redirect the pins used by Power Button to GPIO
2- use something like the WOL aproach, that is changing pwr_ctrl.c from bootloader (and adding gpio-gxbb.h) and recompile Android - which is the the way used by boards like Odroid C4
3- develop a program that monitors a specific GPIO port and then execute the turn off when the pin is connected to gnd - which is the way used by LineageOS for Raspberry.

I tried mostly the 2nd way, but it didn’t succeed to make it work yet.

Any ideas ?

@JohnGalt about wol ,you can refer to WOL Usage | Khadas Documentation

Hi @jasonl , thanks for your idea ! I looked for the WOL functions on the code and I tried to put some of my functions calls on the same places.
But it didn’t work yet. probably because of the GPIO side.