I think I’ve found a way to have a single pushbutton control both power up and power down for the RPi for systems that use I2C and thus cannot use GPIO3 for power down.
Here is how I have this configured on my system (HiFiBerry DAC+, 7" RPi Official display, no encoders) Currently using GPIO24 for activity LED, and GPIO25 as the power down switch.
|----------- [GPIO3/SCL]
|
|----------- [GPIO25]
|
|------------ [Pushbutton] -------[GND]
In /boot/config.txt
#Setup act light, and dedicated power button dtoverlay=pi3-act-led,activelow=off,gpio=24 dtoverlay=gpio-shutdown,gpio_pin=25,gpio_pull=off
The actual gpio_pin used by gpio-shutdown is not critical, just pick a free pin.
The real trick here, is to configure the shutdown pin as “gpio_pull=off” which disables the internal pull-up. Now, short GPIO25, and GPIO3 (Which has an external pull-up, and is shared with I2C SCL line)
When the system is running, GPIO25 is an input, and does not effect the I2C SCL. Pressing the Pushbutton shorts GPIO25 to GND and the system shuts down. At this point, GPIO3 is used as the “reset” and pressing the Pushbutton shorts GPIO3 to GND performing a system reset. Since GPIO3 and GPIO25 are shorted together, a single button connected to GND will provide all the switching needed.
I don’t know if this will work with every configuration, at this point I’ve tested it just a little bit, and it seems to work. I suspect that the code for gpio-shutdown is doing some debounce that is preventing the low cycles of SCL Clock from causing a shutdown.