paulv
Posts: 558
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

RPi 4 : Lost GPIO-3 restart (and fix)

Sun Jun 30, 2019 11:57 am

On the previous RPi's, including the RPi 3+, you had the ability to restart the RPi if is was halted and still powered.
This worked by momentarily shortening GPIO-3 (P1-5) to ground.
This is no longer working on the RPi 4.

[UPDATE] There is a fix available, read on to later postings.

dmesg reports this:
3.846681] input: soc:shutdown_button as /devices/platform/soc/soc:shutdown_button/input/input0

The only difference with a working RPi 3+ (running Stretch) is that at the very end of this line it has input8.

Interestingly, the RUN pin no longer restarts the RPi 4 either, it only puts it into a halted state, but does no longer wake-it up.

Is there something else that needs to be done/can be done to get it working on the model 4?
I'm using this ability to, among other things, control the RPi from a hardware watchdog, so rely on this feature.

Adding the following to /boot/config.txt works for both models (specifically using the same pin)to shut it down:
dtoverlay=gpio-shutdown,gpio_pin=3

I can put it to sleep, I now need the right prince with the right kiss. Anybody? :lol:

Many thanks,

paulv
Last edited by paulv on Sun Jul 14, 2019 6:39 am, edited 3 times in total.

muelli
Posts: 60
Joined: Sat Jul 21, 2012 12:16 pm

Re: RPi 4 : Lost GPIO-3 restart

Sun Jun 30, 2019 2:31 pm

Oh I just asked this question in another thread.
I was wondering about this as well, because I need this function too.

Would be quite horrific for my application here with several Pi's, if this cannot be done anymore :/

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: RPi 4 : Lost GPIO-3 restart

Sun Jun 30, 2019 2:50 pm

As far as the GPIO 3 method, that is in the OS (I think it is done with an interrupt handler that remains resident even after the OS halts), so should be able to be put back with little trouble. Learned this as the result of writing much Bare Metal code.

I thought the run pad was wired to the reset pin of the SoC, so one would expect that there is nothing that software or firmware could do to override its function, I have no idea why that would not work.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

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

Re: RPi 4 : Lost GPIO-3 restart

Sun Jun 30, 2019 3:04 pm

DavidS wrote:
Sun Jun 30, 2019 2:50 pm
As far as the GPIO 3 method, that is in the OS (I think it is done with an interrupt handler that remains resident even after the OS halts), so should be able to be put back with little trouble. Learned this as the result of writing much Bare Metal code.
The start part of GPIO3 is in the bootcode/firmware, not the OS. IIRC, the Pi does a partial restart and is then held in a state where the OS hasn't been loaded until that GPIO is grounded. This may have changed on the Pi 4. The shutdown function is handled differently. I believe it emulates a power button signal to the OS.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: RPi 4 : Lost GPIO-3 restart

Sun Jun 30, 2019 3:07 pm

rpdom wrote:
Sun Jun 30, 2019 3:04 pm
DavidS wrote:
Sun Jun 30, 2019 2:50 pm
As far as the GPIO 3 method, that is in the OS (I think it is done with an interrupt handler that remains resident even after the OS halts), so should be able to be put back with little trouble. Learned this as the result of writing much Bare Metal code.
The start part of GPIO3 is in the bootcode/firmware, not the OS. IIRC, the Pi does a partial restart and is then held in a state where the OS hasn't been loaded until that GPIO is grounded. This may have changed on the Pi 4. The shutdown function is handled differently. I believe it emulates a power button signal to the OS.
Then why does it not work in a bare metal environment? It will work in Raspbian, RISC OS, and most others, though in bare metal it only works if you detect it and use the watchdog to do a reset.

Now the Run pad works no matter what.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

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

Re: RPi 4 : Lost GPIO-3 restart

Sun Jun 30, 2019 3:18 pm

DavidS wrote:
Sun Jun 30, 2019 3:07 pm
Then why does it not work in a bare metal environment?
Possibly the bare metal environment does not initiate the correct "Power off" state? I beleive it doesn't work from a "Halt" state. I am probably wrong. My simple bare metal experiments didn't perform a shutdown at all, they just required removal of power.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23708
Joined: Sat Jul 30, 2011 7:41 pm

Re: RPi 4 : Lost GPIO-3 restart

Mon Jul 01, 2019 9:45 am

AIUI, powering down the Pi4 end up in a very low power state, from which it cannot be restarted. At present this is all that is available, but we are looking into mechanisms to prevent getting to that very low power state and therefore providing the ability to restart.

Sorry.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

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

Re: RPi 4 : Lost GPIO-3 restart

Mon Jul 01, 2019 9:59 am

Thanks jamesh for the info.

It seems ironic that a few people have been requesting a low power state for ages, and now we've got it we can't restart from it.

I'm not complaining. Most of my RPis are on 24/7. I'll see what the 4B is like when mine arrives (hopefully tomorrow) :)

paulv
Posts: 558
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: RPi 4 : Lost GPIO-3 restart

Mon Jul 01, 2019 2:43 pm

Thanks James,

If a fix will become available, how will this be communicated? Here?

Tks,

Paulv

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23708
Joined: Sat Jul 30, 2011 7:41 pm

Re: RPi 4 : Lost GPIO-3 restart

Mon Jul 01, 2019 2:57 pm

paulv wrote:
Mon Jul 01, 2019 2:43 pm
Thanks James,

If a fix will become available, how will this be communicated? Here?

Tks,

Paulv
Almost certainly, maybe a blog post to collate all the fixes we are likely to be implemented - a new release does tend to produce a bump in fixes...!!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

hippy
Posts: 5969
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: RPi 4 : Lost GPIO-3 restart

Mon Jul 01, 2019 4:11 pm

DavidS wrote:
Sun Jun 30, 2019 2:50 pm
I thought the run pad was wired to the reset pin of the SoC, so one would expect that there is nothing that software or firmware could do to override its function, I have no idea why that would not work.
Looking at the reduced schematics it could be that GLOBAL_RESET is asserted by the SoC after shutdown, which holds GLOBAL_EN to the PMIC in a low state, which shuts down power to the SoC, which means RESET/RUN won't have any effect on the unpowered SoC.

This seems to be a modified version of using GPIO to control PEN on the 3B+ to reduce current to almost nothing after shutdown.

If GLOBAL_RESET is permanently being asserted after shutdown, and it is that which is preventing RESET from working, then removing Q5 or R10 would prevent GLOBAL_RESET from having any effect on the PMIC GLOBAL_EN signal.

One might have to also remove R77 to stop the PMIC holding the SoC in reset. But I suspect not.

That might work, might not, will void your warranty, and would be done entirely at your own risk.

One would lose the 'very low power after shutdown' mode but that could potentially be replicated using GPIO as it was with a 3B+. But note GLOBAL_EN is pulled up to 5V so do not connect directly to a GPIO pin.

There are no full schematics so there is no public information as to what the full consequences would be and, with silkscreen component labelling removed from the PCB, you would have to figure out which components were Q5 or R10. It should be possible to find R10 through continuity checking from the GLOBAL_EN header.

I did think one might consider pulling GLOBAL_EN hard to 5V and that may cause a reboot, but R10 is only rated at 63mW.

It would be worth checking what the GPIO 3V3 power pin shows after shutdown. That could confirm the PMIC is powering down the SoC et al after shutdown.

muelli
Posts: 60
Joined: Sat Jul 21, 2012 12:16 pm

Re: RPi 4 : Lost GPIO-3 restart

Mon Jul 08, 2019 6:22 am

Thanks for the update on this topic! Very excited to hear there is work in progress to enable this feature not only on 1,2,3 but also on 4.
I have 18 Pi 3b+ working here and need to move to Pi 4 as soon as this is fixed :) I need more power for my project ^^

Thanks again!

timg236
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 198
Joined: Thu Jun 21, 2018 4:30 pm

Re: RPi 4 : Lost GPIO-3 restart

Mon Jul 08, 2019 11:51 am

Wake on GPIO3 is still possible but will consume significantly more power than on Pi3. So, for Pi4 "halt" was implemented to power off the outputs from the PMIC with GLOBAL_EN used to wake up.

For backwards compatibility with HATS you can can edit the bootloader's builtin mini config.txt file

Download bootloader from here
https://www.raspberrypi.org/downloads/

sed -i -e "s/WAKE_ON_GPIO=0/WAKE_ON_GPIO=1/" pieeprom.bin

Use EEPROM recovery as documented in the README.txt

A similar method but probably wrapped in a script will be used to enable PXE / USB MSD modes once they are implemented.

andylh
Posts: 6
Joined: Thu Apr 26, 2012 5:32 pm

Re: RPi 4 : Lost GPIO-3 restart

Wed Jul 10, 2019 1:35 pm

I am equally annoyed and disappointed that the "restart" behaviour with gpio-shutdown no longer works on a Pi4. This not working as previously almost makes the entire option superfluous, as I now have to turn off the power to get a restart.

Please revert to previous shutdown behaviour as soon as possible. I don't mind about not being in the lowest power level if I cannot restart.

At a minimum, the README file should have been corrected to document the problem on the Pi4, and not left the user to find out.

chipace
Posts: 69
Joined: Sat Jun 29, 2019 2:56 am
Location: brown paper bag in a septic tank

Re: RPi 4 : Lost GPIO-3 restart

Wed Jul 10, 2019 9:27 pm

I added a push button between GLOBAL_EN and GND on the board, and it WAKEs the RPi4 from low power shutdown just fine. I leave my RPi4 plugged into power all the time. It only pulls 20mA (just like RPi3B+). No dtoverlay needed. I thought this was an improvement over the RPi3B+. The button also acts as a RESET when the RPi4 is running.

trejan
Posts: 583
Joined: Tue Jul 02, 2019 2:28 pm

Re: RPi 4 : Lost GPIO-3 restart

Wed Jul 10, 2019 9:44 pm

andylh wrote:
Wed Jul 10, 2019 1:35 pm
Please revert to previous shutdown behaviour as soon as possible. I don't mind about not being in the lowest power level if I cannot restart.
timg236 already said how to revert it yourself in the post above yours?

paulv
Posts: 558
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: RPi 4 : Lost GPIO-3 restart

Sat Jul 13, 2019 7:58 pm

Thank you timg236 !

Just for the mere mortals among us, myself included, I wrote a step-by-step set of instructions on how to install the new bootloader with the fix. That is if you need to do this on a Windows PC/Mac.

First of all, download the fix from the website https://www.raspberrypi.org/downloads/ to your PC/Mac
Unzip the archive and rename the pieeprom.bin file to something like pieeprom.bin.orig
Create a text file with a name like bootfix.txt, and copy the magic command string :

Code: Select all

sed -i -e "s/WAKE_ON_GPIO=0/WAKE_ON_GPIO=1/" pieeprom.bin
into this file. Save the file.

Now we need to apply the fix to the pieeprom.bin file. You need to do that on your Rpi. This can be any RPi model. Take the SD card with your working Buster OS on it out of your RPi4 slot and put it into the PC/Mac.
Use the File Manager to copy the following three files to the /boot (DOS) section of the SD card:

Code: Select all

pieeprom.bin
recovery.bin
bootfix.txt
Eject the SD card and put it back into your RPi, then boot it up. After it booted, do the following:

Code: Select all

cd /boot
cat bootfix.txt
# copy the contends of the file and paste it to the command line prompt to execute it, then turn off the RPi.
sudo poweroff
Take the SD card out of the RPi and put it back into your PC/Mac. Using the Filemanager, save the reprogrammed pieeprom.bin file from the SD card to your PC in the downloaded folder.
Take the SD card with your Buster OS out of your PC/Mac and put it in a safe place for a moment.
Put a new or formatted SD card into your PC/Mac, and copy the following two files to it:

Code: Select all

pieeprom.bin
recovery.bin
Eject the SD card from your PC/Mac and put it into your RPi4 and apply power. Have a look at the LED's. After a second or so the green one will start to flash rapidly. If that is so, the EEPROM bootloader on the RPi has been reprogrammed. Take the power away from the RPi, and insert your normal SD card with the Buster OS on it back into the RPi slot and boot the RPi.

Test the fix by putting the RPi to sleep with

Code: Select all

sudo halt
or

Code: Select all

sudo poweroff
from the command line, or use Shutdown from the GUI. Wait for the green LED to flash 10 times. Now short GPIO3 (pin 5) momentarily to Ground (pin 6) of the GPIO connector. If everything went well, the RPi4 will boot again.

Put the RPi back to sleep again, and now connect the RUN pin of J2 momentarily to Ground, and see if it will bootup the RPi.
Put the RPi back to sleep again, and now connect the GLOBAL pin of J2 momentarily to Ground, and see if it will bootup the RPi.

My RPi Model 4 passed all these tests, so I'm happy that I can reset or wake-up the RPi externally again.

Enjoy!
Last edited by paulv on Sun Jul 14, 2019 6:43 am, edited 2 times in total.

RonR
Posts: 520
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: RPi 4 : Lost GPIO-3 restart

Sun Jul 14, 2019 1:01 am

timg236 wrote:
Mon Jul 08, 2019 11:51 am
For backwards compatibility with HATS you can can edit the bootloader's builtin mini config.txt file

Download bootloader from here
https://www.raspberrypi.org/downloads/

sed -i -e "s/WAKE_ON_GPIO=0/WAKE_ON_GPIO=1/" pieeprom.bin

Use EEPROM recovery as documented in the README.txt
Confirmed working.

Thanks! I've grown accustomed to my shutdown/restart button.

muelli
Posts: 60
Joined: Sat Jul 21, 2012 12:16 pm

Re: RPi 4 : Lost GPIO-3 restart (and fix)

Mon Jul 15, 2019 6:38 am

Fantastic to read about this fix and the confirmation it works :)
It was mentioned the shut down Pi 4 will consume more power than the Pi 3 after applying this fix, has anyone checked how much it actually is?

Thanks folks, that is why I think the Raspberry is the device to buy. Great support from the manufacturer and the community.

emma1997
Posts: 240
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not the old one)

Re: RPi 4 : Lost GPIO-3 restart (and fix)

Mon Jul 15, 2019 10:21 pm

I was also disappointed to find the RUN button no longer makes it run (Linux/Arm gang huge practical jokers :) ). Fortunately by accident discovered GLOBAL_EN pin does work like RUN used to. Also glad to see the dtoverlay trick still functions for safe shutdown.

So a couple minutes to wire up two tact buttons got everything going for now. Same spot near POE pins (see pic) as RUN button on my Pi3s. As a bonus the idle current is still only a few milliamps as if using software shutdown. Depending on which method used it can idle in super low power mode or normal couple hundred milliamps. No fancy schmancy software fixes needed so far.

I'm hoping the video playback bugs are worked out as well. Unlike previous versions, Kodi under Buster shares desktop with the browser which is very important progress IMO. Browse and binge w/o tedious rebooting. This is the first time a Pi comes even close to being a usable personal computer for me.
Attachments
Pi4 on-off buttons.JPG
Pi4 on-off buttons.JPG (93.67 KiB) Viewed 3533 times

timg236
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 198
Joined: Thu Jun 21, 2018 4:30 pm

Re: RPi 4 : Lost GPIO-3 restart (and fix)

Thu Jul 18, 2019 3:07 pm

Unless we find any serious problems in the next few days the next version of the bootloader will default to WAKE_ON_GPIO=1.

The main reason is that it's not possible to turn of 5V because the the board can be powered via the 5V pin and some HATS don't like having 5V but no 3V3. The halt power off can be re-enabled manually with a tweak to bootloader config. See release notes

https://www.raspberrypi.org/forums/view ... 7&t=246027

RonR
Posts: 520
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: RPi 4 : Lost GPIO-3 restart (and fix)

Thu Jul 18, 2019 5:34 pm

timg236 wrote:
Thu Jul 18, 2019 3:07 pm
Unless we find any serious problems in the next few days the next version of the bootloader will default to WAKE_ON_GPIO=1.

The main reason is that it's not possible to turn of 5V because the the board can be powered via the 5V pin and some HATS don't like having 5V but no 3V3. The halt power off can be re-enabled manually with a tweak to bootloader config. See release notes

https://www.raspberrypi.org/forums/view ... 7&t=246027
I like this decision.

Thank you.

slipstream42
Posts: 7
Joined: Sat Jun 02, 2018 1:55 pm

Re: RPi 4 : Lost GPIO-3 restart (and fix)

Tue Aug 13, 2019 5:51 pm

rpi 4B - put two momentary push buttons (pb) on a prototype hat (one for shutdown and one for boot)

- remember you always want to do a shutdown before a restart or your sdcard my get corrupted

----- one pb is for boot -----
this pb shorts Global_En to ground which brings the pi out of halt mode
(this pb will do a reset but really need to do a shutdown first then a boot up)

----- one pb is for shutdown -----
the pb is connected to gpio #17
the pb shorts this input to ground
a python script is started on boot that looks for a fall edging on this input
download scripts from: https://github.com/Howchoo/pi-power-button
article on shutdown btn: https://howchoo.com/g/mwnlytk3zmm/how-t ... spberry-pi

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

Re: RPi 4 : Lost GPIO-3 restart (and fix)

Tue Aug 13, 2019 6:22 pm

slipstream42 wrote:
Tue Aug 13, 2019 5:51 pm
rpi 4B - put two momentary push buttons (pb) on a prototype hat (one for shutdown and one for boot)

- remember you always want to do a shutdown before a restart or your sdcard my get corrupted

----- one pb is for boot -----
this pb shorts Global_En to ground which brings the pi out of halt mode
(this pb will do a reset but really need to do a shutdown first then a boot up)

----- one pb is for shutdown -----
the pb is connected to gpio #17
the pb shorts this input to ground
a python script is started on boot that looks for a fall edging on this input
download scripts from: https://github.com/Howchoo/pi-power-button
article on shutdown btn: https://howchoo.com/g/mwnlytk3zmm/how-t ... spberry-pi
You are missing the whole point.
Adding the special dtoverlay to config.txt will allow a safe shutdown without the need for any additional code running.
Now that GPIO 3 restart is fixed, the user can shutdown and restart the RPi4 with a single push-button connected to GPIO 3 as it does for RPi 3.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

emma1997
Posts: 240
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not the old one)

Re: RPi 4 : Lost GPIO-3 restart (and fix)

Tue Aug 13, 2019 7:18 pm

Nice to see slipstream42 found my above trick useful. However I agree dtoverlay is much better than that old script or python way.

From what I can tell changing from the current default of low power halt to allow single button boot is planned but not implemented yet. As mentioned previously it's necessary to reflash the boot firmware and I'm not sure bin is even available yet.

Another issue is single button on/off does not allow low power halt. My two button method does. This is probably only important for those like myself who are involved with battery and solar. IMO changing to high power halt default is a good decision though. Compatibility with previous models is more important than energy efficiency for most users. Hopefully the planned user friendly utility to switch between the two options will be available soon also. It's a bit nasty right now.

Return to “General discussion”