interesting - looking into the source code in build/tmp/work/core2-32-poky-linux/pwr-button-handler/0.1-r0/package/usr/src/debug/pwr-button-handler/0.1-r0/pwr-button-handler.c (see snippet below)
I only can see that after 2 secs pressing the pwr button "/usr/bin/configure_edison --enableOneTimeSetup" is called.
So I guess some other handler would ungracefully shutdown?
/* We use 2 seconds for now */
#define EDISON_OOBE_PRESS_TIMEOUT 2
#define CALLED_COMMAND_ON_TIMEOUT "/usr/bin/configure_edison --enableOneTimeSetup"
As you can see in Intel® Edison kit for Arduino – Buttons and Switch this is the normal function of the power button and it is configured by software.
"The power button is used to change the power mode of the Intel® Edison. It is configured by software. Pressing and holding the power button will cause the Intel® Edison to power down leaving the IO configuration in its current state. Pressing the button momentarily when the Intel® Edison is powered down will cause the Intel® Edison to reboot. If the Intel® Edison is running, then a momentary press will cause the Intel® Edison to go into the low power sleep mode. Pressing the button momentarily when the Intel® Edison is asleep, will bring the Intel® Edison into full power mode. Pressing and holding the power button for more than 2 seconds but less than 7 seconds will turn the Intel® Edison AP mode on."
As you can see this is the expected behavior, if you press and hold the power button for less than 7 seconds, it will put the Edison in AP mode. It doesn't matter that this document is made for the Arduino Expansion Board because the power button is connected directly to a pin in the Edison.
Hi mhan, thank you for the info, sounds like a shutdown handler is missing. The source you are showing here where can I download it?
it's part of "Edison Yocto complete image" on Edison - Software Downloads. If you Yocto build you'd find it in the subfolder given in my other reply. Otherwise you'd find it in device-software/meta-edison-distro/recipes-support/pwr-button-handler subfolder
Good news, I fixed the problem myself by adding a 3 x button click (within hour seconds) which will shutdown the system gracefully. I hope somebody has the power to include this into future Edison Linux releases.
The reworked pwr-button-handler.c is available here:
Please note, the compiled binary must be spelled with underlines and not hyphens.
I skimmed your code and saw quickly two things which will not work on ublinux.
1. /dev/input/input1 is not available
2. /bin/systemctl is not available
What I found is an empty file which should provide the possibility to add an event but I do not know how.
Maybe someone could help me out?
A "shutdown now" command will do the same job.
/dev/input/input1 needs to be configured when you build a kernel. I believe ublinux will include the Intel drivers for providing this feature. You will find in /usr/include/linux/input.h defines for the events for every Linux kernel. I have not looked into the Intel Edison kernel source, I even don't know in which package the source is.
Anyways it is now your turn the figure out how to get the input1 device driver configured.