Skip to content

Instantly share code, notes, and snippets.

@zaxbux
Last active July 10, 2022 05:49
Show Gist options
  • Save zaxbux/73b77752a29fcce0e30052cf0a377034 to your computer and use it in GitHub Desktop.
Save zaxbux/73b77752a29fcce0e30052cf0a377034 to your computer and use it in GitHub Desktop.
Raspberry Pi 4B One Button Startup/Shutdown (OBSS) without disrupting I2C

I am working on a project that requires GPIO3 be used for I2C. Unfortunately, this is also the pin that can be used for one button startup/shutdown.

Goals

  • Wake Pi after shutdown, halt, or poweroff
  • Shutdown Pi safely to avoid corruption
  • Does not rely on GPIO3 (pin 5; I2C1 SCL)

Background

  • The J2 header provides three pins: GLOBAL_EN (5V), GND, and RUN (3V3)
  • The GLOBAL_EN pin will wake/boot the Pi after halt, poweroff, or shutdown states. (2)
  • Setting WAKE_ON_GPIO=0 and POWER_OFF_ON_HALT=1 allows the Pi to enter a low power mode when shutdown.
    • Once in this mode, all PMIC outputs are disabled (this also reduces current draw).
    • In order to bring up the system, GLOBAL_EN must be pulled low or the USB can be re-inserted. (1)
    • The 3V3 rail is not powered in this mode, however the 5v rail is still powered. (3)

Solution

Take advantage of the fact that the 3V3 rail is not powered when the Pi is in low-power mode as an indicator to an external microcontroller to pull GLOBAL_EN low when a request to power-on is received (reference schematic). If the 3V3 rail is powered, this will indicate that (a) an otherwise unsused GPIO pin should be pulled low; or (b) the I2C bus can be used to trigger a software-controlled shutdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment