5 Replies Latest reply on Mar 1, 2015 2:23 AM by Yodal

    How to control PWRBTN action

    glemarchand

      Hello,

       

      I'm currently working on a custom Edison board and I have a question about the PWRBTN. My use case is the following one:

       

      1. The board is on a charging doc => the edison is on a sleep mode or power off mode
      2. The board leave the dock =>  the edison reboot
      3. The board go back on the dock => the edison go back to sleep or power off

       

      How to get this kind of behavior using the PWRBTN ? Must I change something in a configuration file, or write an independant program ?

       

      Thanks for your help

        • 1. Re: How to control PWRBTN action
          Intel_Alvarado

          Hi glemarchand,

           

          The PWRBTN# pin is an active low input which can cause the Edison module to transition into and out of sleep, or cause a power off , depending on the configuration of the software. According to the Edison schematic the PWRBTN is connected to SW1UI2 of the Arduino expansion board. You can see more information of SW1UI2 in https://communities.intel.com/docs/DOC-23454 .

           

          RESET_OUT# can be used by external hardware to indicate system reset. This external hardware will be your custom board, in the document it states that “If the Intel® Edison is running, then a momentary press will cause the Intel® Edison to go into the low power sleep mode.”, this is what you are looking for right? Then, since you are not using the Arduino board use a switch or a button connected to the PWRBTN to get this behavior.

           

          Regards

          Sergio

          • 2. Re: How to control PWRBTN action
            glemarchand

            Hi Sergio,

             

            I'm not using the Arduino expansion board, it's a full custom board. In this board I have a switch connected to the PWRBTN pin. I made some test today and I get the following result

            • (initial state the edison is power on)
            • I pushed the PWRBTN during +/- 7s => edison go in sleep mode = good behavior
            • I release the PWRBTN => edison stay in sleep mode = bad behavior

             

            As you wrote, the documentation says "he PWRBTN# pin is an active low input which can cause the Edison module to transition into and out of sleep, or cause a power off , depending on the configuration of the software". How can I change this configuration ?

             

            Regards

            Guillaume

            • 3. Re: How to control PWRBTN action
              Yodal

              The power button functions, as far as I know, are handled by pwr-button-handler (big surprise I know). To change the functionality of the power button you have to change this program or replace it. You can see the code in the edison-src download under device-software/meta-edison-distro/recipes-support/pwr-button-handler/. I hope that helps.

              • 4. Re: How to control PWRBTN action
                glemarchand

                Thanks yodal, I think it's a good way !

                 

                However I seems to have still an issue. In the original pwr-button-handler.c, I comment the two lines "system(argv[X])" on line 154 and 106 then I compile and copy the program in /usr/bin and reboot my Edison for apply. After reboot, the action on the power button is still the same. Any idea ? I try systemctl reenable pwr_button_handler.service but i got the same problem.

                • 5. Re: How to control PWRBTN action
                  Yodal

                  Looking closer at it, it might be best to use the normal code and just change what is passed to the program by systemctl. Changing the service's parameter might sick instead of altering the program. If all else fails, try editing the program/service file before building the kernel and then flash a new kernel with your changes.