sridharrajagopal
Posts: 4
Joined: Tue Oct 30, 2018 1:41 am

Alternate pin for "Wake From Halt" instead of GPIO3 ?

Tue Oct 30, 2018 2:27 am

Hi,

I am interested in shutting down the RPi and then waking it up from halt as a means of power optimization. I see that GPIO3 (pin5 ) can be shorted to GND (pin6) to wake the RPi from halt.

However, GPIO3 is also the default pin for I2C. If you have any I2C devices connected to your RPi, there is a conflict. It would be nice if the pin was configurable, and if so, where can I change the config?

For instance, pins 7 and 9 can be used instead of pins 5 & 6. Pin 7 (GPIO4) is right next to pin 5, and is a general purpose GPIO pin and therefore has no conflict with any other functionality. It is also physically in proximity to the GND pin (pin 9), and so therefore the same shorting of the pin for Wake From Halt can still be achieved easily, right?

An external RTC like DS1337, DS1339 or DS3231 (which are usually I2C based) can be used in conjunction with a configurable "Wake From Halt" pin (GPIO4 or any other pin that doesn't conflict), to allow for scheduled shutdown, wake from halt that can be as long as the alarm time supported by the RTC (for example, wake up once a day and report some data) and allow for some power optimizations when running on battery/solar.

So my question is whether the Wake From Halt pin can be changed from GPIO3 to another? Also, if it makes sense, can GPIO4 be considered for Wake From Halt for future purposes to avoid conflict with I2C?

Thanks,
Sridhar

User avatar
rpdom
Posts: 14766
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Alternate pin for "Wake From Halt" instead of GPIO3 ?

Tue Oct 30, 2018 5:09 am

sridharrajagopal wrote:
Tue Oct 30, 2018 2:27 am
So my question is whether the Wake From Halt pin can be changed from GPIO3 to another? Also, if it makes sense, can GPIO4 be considered for Wake From Halt for future purposes to avoid conflict with I2C?
No, the pin is hard-coded into the Pi. It can't be changed.

One reason that pin was chosen is because it has an on-board pull-up resistor, so is pulled high whenever the Pi has power. Briefly connecting it to pin 6 pulls it low and triggers the restart. It shouldn't affect i2c devices as the i2c bus is not active at the time.

klricks
Posts: 6506
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Alternate pin for "Wake From Halt" instead of GPIO3 ?

Tue Oct 30, 2018 6:33 am

An alternate way to wake from halt is to use the RUN pin.

If the safe shutdown feature is enabled: dtoverlay=gpio-shutdown, then that also defaults to GPIO3 so that a single switch can be used to shutdown or wake.
However unlike the wake pin, the shutdown pin can be configured to any GPIO for those who are using i2c. Of course 2 switches would then be required.

This will configure safe shutdown on GPIO 26:

Code: Select all

dtoverlay=gpio-shutdown,gpio_pin=26
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

sridharrajagopal
Posts: 4
Joined: Tue Oct 30, 2018 1:41 am

Re: Alternate pin for "Wake From Halt" instead of GPIO3 ?

Tue Oct 30, 2018 7:52 pm

rpdom wrote:
Tue Oct 30, 2018 5:09 am
sridharrajagopal wrote:
Tue Oct 30, 2018 2:27 am
So my question is whether the Wake From Halt pin can be changed from GPIO3 to another? Also, if it makes sense, can GPIO4 be considered for Wake From Halt for future purposes to avoid conflict with I2C?
No, the pin is hard-coded into the Pi. It can't be changed.

One reason that pin was chosen is because it has an on-board pull-up resistor, so is pulled high whenever the Pi has power. Briefly connecting it to pin 6 pulls it low and triggers the restart. It shouldn't affect i2c devices as the i2c bus is not active at the time.
That is quite unfortunate! It will affect I2C devices in the following scenario, which is what I was considering - using an RTC to initiate wake from halt - the RTC communicates via I2C and therefore cannot use that as SCL pin and SQW/INT pin at the same time. It is quite frustrating as there is a perfect pin nearby for this purpose - GPIO4! Don't many GPIO pins have internal pullup/down resistors that can be set programmatically? (viewtopic.php?t=62191)

Thanks,
Sridhar

sridharrajagopal
Posts: 4
Joined: Tue Oct 30, 2018 1:41 am

Re: Alternate pin for "Wake From Halt" instead of GPIO3 ?

Tue Oct 30, 2018 7:55 pm

klricks wrote:
Tue Oct 30, 2018 6:33 am
An alternate way to wake from halt is to use the RUN pin.

If the safe shutdown feature is enabled: dtoverlay=gpio-shutdown, then that also defaults to GPIO3 so that a single switch can be used to shutdown or wake.
However unlike the wake pin, the shutdown pin can be configured to any GPIO for those who are using i2c. Of course 2 switches would then be required.

This will configure safe shutdown on GPIO 26:

Code: Select all

dtoverlay=gpio-shutdown,gpio_pin=26
Hi,

Yes, I am aware of this for the shutdown. If "Wake from Halt" was similarly configurable to any GPIO, it would have been perfect!

Thanks,
Sridhar

User avatar
rpdom
Posts: 14766
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Alternate pin for "Wake From Halt" instead of GPIO3 ?

Tue Oct 30, 2018 8:05 pm

sridharrajagopal wrote:
Tue Oct 30, 2018 7:52 pm
That is quite unfortunate! It will affect I2C devices in the following scenario, which is what I was considering - using an RTC to initiate wake from halt - the RTC communicates via I2C and therefore cannot use that as SCL pin and SQW/INT pin at the same time. It is quite frustrating as there is a perfect pin nearby for this purpose - GPIO4! Don't many GPIO pins have internal pullup/down resistors that can be set programmatically?
The I2C bus on the Pi is disabled while in halt state, so the RTC cannot use it to communicate. It is only after the system has (partially, at least) booted that I2C is active.

GPIO4 is frequently used for other things, however, like the other GPIOs, not at boot. But it is commonly used for the 1-wire bus, which requires an external 4K7 pull-up to be added.

The internal pull-up/down are in a fixed pre-determined state while halted, but 2 & 3 are the only ones with fixed pull-ups. The others could be pulled up or down by external hardware and cause the Pi to restart every time it is halted.

The reason the shutdown pin is configurable is that the firmware has been started and can read the config file. At halt time it has been reset and the config file has not been read (AFAIK).

Return to “General discussion”