PiSupply / PiJuice

Resources for PiJuice HAT for Raspberry Pi - use your Pi Anywhere
https://uk.pi-supply.com/collections/pijuice/products/pijuice-portable-power-raspberry-pi
GNU General Public License v3.0
435 stars 103 forks source link

Software Halt Power Off does not seem to be working #868

Open funkyfourier opened 2 years ago

funkyfourier commented 2 years ago

The option "Software Halt Power Off" does not seem to do anything on my setup. When powering off via the main menu "Logout"->"Shutdown", or running sudo halt / sudo poweroff, the red light on the RPi stays on several minutes after. In this mode the only way to power on again is to hold SW1 for 20 sec until it cuts the power to the RPi completely and then press it again.

"Software Halt Power Off" is set to 30 seconds and "System task enabled" is checked. It is a RPi 4B running Raspbian GNU/Linux 11 (bullseye) and PiJuice firmware V1.6_2021_09_10.

rpi-eeprom-config tells me:

BOOT_UART=0 WAKE_ON_GPIO=1 POWER_OFF_ON_HALT=0

Should not the power to the RPi be cut off after 30 seconds regardless of shut down method?

Edit: I notice that when USB power is connected to the PiJuice the red light on the RPi shuts off after the specified seconds (i.e the behaviour I'd expect), but not when USB power disconnected. This is opposite of what would be ideal for my use case as I am building a portable device.

tvoverbeek commented 2 years ago

Just to be sure, "Software Halt Power Off" only works when running on battery only. It does not work when you are powering via the Pi4 USB-C.

funkyfourier commented 2 years ago

Just to be sure, "Software Halt Power Off" only works when running on battery only. It does not work when you are powering via the Pi4 USB-C.

Ok. There is no USB-C connector going into the Pi4.

Nadahar commented 2 years ago

Just to be sure, "Software Halt Power Off" only works when running on battery only. It does not work when you are powering via the Pi4 USB-C.

It works for me when powered via the micro-USB on the PiJuice as well (not just on battery). It obviously can't work if the RPi is "powered directly" (GPIO or USB-C).

tvoverbeek commented 2 years ago

@Nadahar Correct."Software Halt Power Off" also works when external power is connected to the PiJuice micro-USB.

funkyfourier commented 2 years ago

OK, so I got a new PiJuice Zero and I am still having similar issues, although not quite identical. The PiJuice Zero is hooked up to a RPi4B with a stacking header. It is running FW 1.4 as it was out of the box, and the RPi4B is running bullseye with the latest updates installed. The PiJuice Zero has the official 5000mAh battery connected.

"Software Halt Power Off" is set to 20 and "System task enabled" is enabled. No other options have been changed.

What I am getting now is this:

These symptoms are consistent with or without the micro USB plugged into the PiJuize Zero.

Note: In none of these cases has the USB-C plug on the RPi4B been connected to anything.

Any feedback would be appreciated. I am building a single-app portable device with a touch screen, so the ability to proper power off via the button would be a highly useful feature.

Will also test with the newest firmware and update below.

Edit: Exact same behaviour on firmware 1.6.

tvoverbeek commented 2 years ago

The "Software Halt Power Off" setting only applies to shutdown/halt initiated by user software (your first 2 bullets). The SW1 long press effect is determined by the function you have assigned to SW1 LONG_PRESS_1 SYS_FUNC_HALT wil shut down the system but keep the 5V on (probably the case for your 3rd bullet). Change it to SYS_FUNC_HALT_POW_OFF. The power off will occur after ca 60 sec. This value is har-coded. See lines 66-69 in pijuice_sys.py (https://github.com/PiSupply/PiJuice/blob/master/Software/Source/src/pijuice_sys.py) This is all documented in the SOftware README on github.