raspberrypi / firmware

This repository contains pre-compiled binaries of the current Raspberry Pi kernel and modules, userspace libraries, and bootloader/GPU firmware.
5.17k stars 1.68k forks source link

gpio-poweroff for RPi 0W, bullseye, 32-bit #1906

Closed seamusdemora closed 3 months ago

seamusdemora commented 3 months ago

I've got a RPi 0W I'm trying to press into service for a "garden irrigation" project. As it's in the garden, it's also battery/solar powered. I have a "fixture" I've used for a couple of years that controls power application to the RPi. This "fixture" uses a Realtime clock (RTC), and a "latching relay" to control power to the RPi. I use the RTC's #INT output to CLOSE the latching relay contacts and supply Power, and gpio-poweroff to OPEN the latching relay contacts and remove Power. This fixture has always worked well, it's fairly simple, and I've checked and double-checked it for this project.

I have the following entries in boot/config.txt:

# ?????????????????? : 
# dtoverlay=dwc-otg

# seamus: set up RTC on i2c0
dtparam=i2c_vc=on
dtoverlay=i2c-rtc,ds3231,i2c0,wakeup-source
dtoverlay=gpio-poweroff 
# dtoverlay=gpio-poweroff,active_delay_ms=250,inactive_delay_ms=500,timeout_ms=8000
# dtoverlay=gpio-poweroff,gpiopin=17

The problem I seem to be having is that the gpio-poweroff overlay is not "firing" the GPIO pin! I've tried it on the default pin (GPIO 26), and on GPIO 17, but get nothing from either. I've got an Agilent oscilloscope, and have tried to capture the transition; I DO NOT SEE A TRANSITION on GPIO 26 (or on GPIO 17).

I researched the problem: The only relevant item I could find was this post in the forums. The OP appeared to have researched it well - he actually came up with the solution that worked for him. Unfortunately, it did not work for me. I tried powering in the PWR (first) and the OTG (second) connectors, with and without the dwc-otg overlay in both cases - without success.

And so I'm posting here as a last resort. Any ideas or solutions for this??

P.S.: I would have tried posting in the forums, but was "banned for life" several years ago for this.

pelwell commented 3 months ago

Which kernel version is this?

seamusdemora commented 3 months ago

6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023

pelwell commented 3 months ago

gpio-poweroff works just fine on 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023. What doesn't work is shutting down with the desktop enabled. If you switch to "boot to console" (in raspi-config) you'll find that all three gpio-poweroff configurations in your config.txt work as expected.

I suggest upgrading to a 6.6 kernel, or booting to console.

pelwell commented 3 months ago

If you wait long enough, something times out and the shutdown will complete, wiggling the poweroff GPIO as it exits.

seamusdemora commented 3 months ago

gpio-poweroff works just fine on 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023. What doesn't work is shutting down with the desktop enabled. If you switch to "boot to console" (in raspi-config) you'll find that all three gpio-poweroff configurations in your config.txt work as expected.

I suggest upgrading to a 6.6 kernel, or booting to console.

Desktop?? I'm using the "Lite" version of the OS. What am I missing?

I've only ever used the "Lite" version of the OS on virtually every hardware model made, and I've never had a problem with the gpio-poweroff overlay. This is the first time I've tried it on my (recently departed) Pi 0W, and I concluded that the issue I'm seeing must be related to this model.

Also - I connected my o'scope (first to GPIO 26, later to GPIO 17) on the Zero W, but it was never triggered - even once when I left the scope connected for maybe an hour after the gpio-poweroff. I know what it looks like... below is a screenshot I made some time ago on a 4B :
image

Anyway - I appreciate your suggestion, but remain confused & without a clear path ahead. I assume my use of the "Lite" version of the OS rules out your explanation of the "desktop" being the cause??

pelwell commented 3 months ago

It's working fine for me on a Zero W running the current Lite image downgraded to 6.1.21. You should try the same (sudo rpi-update 0b15297 to install that specific, nearly-15-month-old kernel).

If you want to debug your problem, add ignore_loglevel to cmdline.txt and see what appears on the display or UART. If you have neither display nor UART, you're going to find it difficult.

seamusdemora commented 3 months ago

My Zero W is scheduled for delivery on Monday, July 1. I was planning on using the SD card from the dead Zero W ('bullseye' w/ 6.1.21)... would that not be functionally equivalent to a fresh install of 'bookworm' & downgrading the kernel to 6.1.21? Be happy to do whatever you suggest - just trying to save steps where it makes sense.

wrt ignore_level: I can connect either a display & kbd -OR- wire up the UART to another RPi. It may be easier for me to connect the display & kbd, add video=HDMI-A-1:1920x1080M@60 to cmdline.txt ... if there's no other diffs of which I'm unaware.

pelwell commented 3 months ago

I got the option name wrong - it should be ignore_loglevel (corrected above).

seamusdemora commented 3 months ago

ignore_loglevel "documentation"

seamusdemora commented 3 months ago

My replacement RPi 0W arrived a day early! :0

I've re-installed the SD card (from the now-departed RPi 0W), and re-ran my test. The gpio-poweroff overlay works perfectly! I don't know what caused the malfunction on the first RPi 0W, and I won't be learning anything further as it's been consigned to the bin.

Thank you again for your help, and my sincere apologies for the false alarm.