BeagleBone Black Soft Power-Off

BeagleBone Black

The BeagleBone Black is an ARM-based device and doesn’t have ACPI support like most x86 systems. ACPI generally handles triggering shutdown and other power management events on x86 systems, so this functionality is missing on the BeagleBone. We can easily work around this problem with acpid, which provides an event handling script that is triggered when the power button is pressed. This is a simple way to add power button triggered shutdown without actually having ACPI support in the hardware.

First, install acpid from your distribution’s package manager. For Arch Linux ARM:

sudo pacman -S acpid

Next, open /etc/acpi/handler.sh in a text editor. Look for the snippet containing “PowerButton pressed” near the beginning of the script. After this line, add a new line with “poweroff” on it. You may also add any other commands you wish to run when the power button is pressed.

        case "$2" in
            PBTN|PWRF)
                logger 'PowerButton pressed'
                poweroff
                ;;
            *)
                logger "ACPI action undefined: $2"
                ;;
        esac
        ;;

Now enable and start the acpid daemon. On systemd-based distros, use the method below.

systemctl enable acpid.service
systemctl start acpid.service

Now that acpid is running, power button events will be handled by the events script. Note that the acpid service will generate errors in its log because it is unable to communicate with the kernel, but the poweroff will execute as expected.

Finally, press the power button on your BeagleBone and it should begin shutting down. If you encounter any issues, check the logs of the acpid service to make sure it launched properly. Also double-check your syntax in the event handler script.

Ethan is a computer engineer and open source hardware/software developer from Michigan. He enjoys AVR and linux development, photography, mountain biking, and drinking significant amounts of home-roasted coffee. Find out more at ethanzonca.com.

Tagged with: , , ,
Posted in Linux
2 comments on “BeagleBone Black Soft Power-Off
  1. Josias says:

    Hi, THnx for this.

    I’ve got a c program that always runs (control app). I would like to receive a notification that the power button has been pressed to exit my app as I may have files open. How do I go about it?

    A simple example will be appreciated.

    • Bill Bob says:

      I’m sure Ethan would be happy to sit down and craft a solution for you. I won’t do that, but I’ll give you the steps to go about it:
      1. Learn bash programming.
      2. Learn signal handling
      3. Implement a signal handler in your c program
      4. In the above handler script, send a signal to your c program

Leave a Reply

Your email address will not be published. Required fields are marked *

*