3

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 see two separate questions re use and configuration of "power buttons" to halt and boot an RPi 4:

Question 1:

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

Answer:

Yes - it is a safe shutdown. For details & confirmation, see REF 1 and REF 2.

Question 2:

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.

Answer:

Before going any further, I'd like to make sure we're clear on two points:

  • You can startup and shutdown your RPi with a single push-button switch connected between GPIO 3 and GND. You didn't specifically say that you wanted this 1-button arrangement, but it's far more convenient than using separate buttons for shutdown and startup. The only good reason I can think of to do it any other way is to reduce energy consumption while leaving power connected to the RPi.

  • Shutting down your RPi - whether done with a button press, or from the command line - does not remove power. Your RPi will continue to consume some power in shutdown unless and until you "pull the plug".

That said, let's review the options:

Option 1. Move I2C from GPIO 3 and GPIO 4

The latest version of the firmware provides numerous overlay options for "relocating" I2C1, and/or "adding" I2C buses in /boot/config.txt. Review the latest version of the README for details.

This is the easiest option, and you need not read any further unless you need to minimize power consumption while in shutdown.

Option 2.

The RPi 4 introduced a new bootloader that's stored in EEPROM (instead of a bootcode.bin file). It also provided new configuration properties - two of which are relevant to reducing power consumption while the RPi 4 is shutdown or halted; i.e. the system is not running, but is powered up:

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

This informs us that the GLOBAL_EN input node may be used in lieu of GPIO 3 to restart the RPi 4 in all possible configurations of these parameters. Three things should be noted re GLOBAL_EN:

  • It is not a GPIO
  • It is pulled up to 5V
  • The actual restart is not* triggered when GLOBAL_EN is pulled LOW by pressing the pushbutton, but when it is "released" and allowed to return to its "pulled-up" (logic HIGH) state.

The GLOBAL_EN node is shown in the photo below:

GLOBAL_EN node location on RPi 4

Summary for Option 2:

This is more difficult than Option 1, but offers the advantage of reduced power consumption in halt/shutdown. The most straightforward hardware implementation is to use two pushbuttons - one for startup, one for shutdown. If you want to take some additional effort, a single button startup & shutdown solution is illustrated here.

6
  • 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? 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? Sep 27 '20 at 16:11
  • 1
    So far I only used RUN because older PIs only had RUN. Sep 27 '20 at 20:50
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)
8

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.