2

I've been doing some research on power buttons for the Raspberry Pi, but I'm having quite a hard time finding information. Right now, I have button working on GPIO5, and when I connect it to the opposing GND pin, the Pi boots up. I added the line dtoverlay=gpio-shutdown to my /boot/config.txt, so that I can shutdown with this connection as well. However, I have a couple of questions that I'm having a hard time finding answers to.

  • Is the shutdown initiated with connecting the GPIO3 pin and the GND pin considered a safe shutdown? Will the system finish writing to memory, etc, just like with sudo shutdown?
  • I know that I can change the pin for shutdown, by changing dtoverlay=gpio-shutdown to dtoverlay=gpio-shutdown,gpio-pin=X, but is there a way to change the pin for boot up as well? Considering GPIO3 is normally used for I2C.
1

I don't know the complete answer to all of your questions, so this is a partial answer.

Q1:

Is the shutdown initiated with connecting the GPIO3 pin and the GND pin considered a safe shutdown?

I recall hearing of issues associated with using GPIO for shutdown, but some recent information suggests that this feature works as it should if the system is configured properly - i.e. if configured properly, the shutdown is "safe". Of course the hardware-free way to shutdown the RPi is from the screen or the CLI via sudo shutdown, sudo halt or sudo poweroff.

Q2:

I know that I can change the pin for shutdown, by changing dtoverlay=gpio-shutdown to dtoverlay=gpio-shutdown,gpio-pin=X, but is there a way to change the pin for boot up as well?

You don't need to take up a GPIO pin to re-start the RPi from a shutdown state. The documentation states:

WAKE_ON_GPIO

If 1 then 'sudo halt' will run in a lower power mode until either GPIO3 or GLOBAL_EN are shorted to ground.

Default: 1 (0 in original version of bootloader 2019-05-10) Version: All

POWER_OFF_ON_HALT

If 1 and WAKE_ON_GPIO=0 then switch off all PMIC outputs in halt. This is lowest possible power state for halt but may cause problems with some HATs because 5V will still be on. GLOBAL_EN must be shorted to ground to boot.

Default: 0 Version: 2019-07-15

My interpretation of the above documentation is this: Briefly shorting GLOBAL_EN to ground will re-start/re-boot the RPi irrespective of how WAKE_ON_GPIO and POWER_OFF_ON_HALT are set. The GLOBAL_EN node is shown in the photo below:

enter image description here

  • 2
    The GLOBAL-EN pin actually shuts down the PMIC. Grounding it is equivalent to turning power off. It removes power from EVERYTHING (except 5V pin). The Pi will restart when the Gnd is removed. On the original Pi, which put the PMIC into a low power state on halt this was the only way to reboot. See raspberrypi.stackexchange.com/a/114108/8697 – Milliways Sep 19 '20 at 6:57
  • What's the difference to the RUN pin then? – Goswin von Brederlow Sep 27 '20 at 15:53
  • @GoswinvonBrederlow: raspberrypi.stackexchange.com/a/33945/83790 – Seamus Sep 27 '20 at 16:06
  • So RUN is the small brother to GLOBAL-EN then as it will only reset the CPU and not power off the PMIC? – Goswin von Brederlow Sep 27 '20 at 16:11
  • @GoswinvonBrederlow: Not sure what you mean by small brother, but AFAIK: grounding GLOBAL_EN will re-boot a Pi that has been halted by shutdown or poweroff or halt. That is what the RPi "official docs" state (see my answer). As far as Milways comment above: I don't know if it's true or not as I have not tried it. – Seamus Sep 27 '20 at 16:34
0

The operation is explained in /boot/overlays/README

It is quite safe, I have it on all my Pi in case I need to shutdown a headless Pi (or one without keyboard attached), although my Pi are rarely shutdown, unless I am adding hardware.

I use dtoverlay=gpio-shutdown,gpio_pin=21 so I can shutdown by bridging pins 39/40

Name:   gpio-shutdown
Info:   Initiates a shutdown when GPIO pin changes. The given GPIO pin
        is configured as an input key that generates KEY_POWER events.

…

        This overlay only handles shutdown. After shutdown, the system
        can be powered up again by driving GPIO3 low. The default
        configuration uses GPIO3 with a pullup, so if you connect a
        button between GPIO3 and GND (pin 5 and 6 on the 40-pin header),
        you get a shutdown and power-up button. Please note that
        Raspberry Pi 1 Model B rev 1 uses GPIO1 instead of GPIO3.
Load:   dtoverlay=gpio-shutdown,<param>=<val>
Params: gpio_pin                GPIO pin to trigger on (default 3)
                                For Raspberry Pi 1 Model B rev 1 set this
                                explicitly to value 1, e.g.:

                                    dtoverlay=gpio-shutdown,gpio_pin=1

        active_low              When this is 1 (active low), a falling
                                edge generates a key down event and a
                                rising edge generates a key up event.
                                When this is 0 (active high), this is
                                reversed. The default is 1 (active low).

        gpio_pull               Desired pull-up/down state (off, down, up)
                                Default is "up".

                                Note that the default pin (GPIO3) has an
                                external pullup. Same applies for GPIO1
                                on Raspberry Pi 1 Model B rev 1.

        debounce                Specify the debounce interval in milliseconds
                                (default 100)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.