Button shutdown not detecting a press

G2 operating system and special app's (e.g. p2app) discussion only--post Thetis and piHPSDR questions in their own sub-forums
Post Reply
W0KHZ
Posts: 2
Joined: Wed Dec 03, 2025 11:19 pm

Button shutdown not detecting a press

Post by W0KHZ »

I have tried my best to find an answer to this problem, but can't find it. I recently acquired a used G2 and upon arrival the microSD in the G2 appeared to be corrupted. Luckily inside of the unit was a backup microSD which does work but shutdown via the power button does not work. I ran the script manually that waits for the button state to change, but it has no effect. The previous owner had upgraded the pi to 5 and it's running the bookworm OS.

Also, the power button originally stayed white. I ran the script that fixes that, and that works. Now when the pi is running, it turns red and turns white when the pi has shutdown. Since the button is not shutting down the pi, I have been shutting it down using the shutdown command.

Any clues as to why the power button shutdown script doesn't work? It is running and waiting for a button state change that it never detects.
Svante
Posts: 33
Joined: Thu Jul 18, 2024 7:56 am

Re: Button shutdown not detecting a press

Post by Svante »

Had my Anan G"2,17 months now. Never change colour on first push Have to make 2 short push then it changes colour and I wait about 15 sek. then a longer push This is very irritating way to shut off a tranceiver. Have my Anan under a noise isolated table do to the noisy fan. So looking for a better shut off solution.
Remote howe do this people do ?
Svante sm6usu
ct1iqi
Posts: 51
Joined: Thu Jul 06, 2023 4:01 pm

Re: Button shutdown not detecting a press

Post by ct1iqi »

Had a look at the fix-LED-power-button.sh script and it seems to only address indeed the LED action, not the shutdown.
The original front-less G2 has defined in config.txt:
>>
dtoverlay=gpio-shutdown,gpio_pin=26
gpio=15=op,dh
<<
The script replaces the effect of the second line by a systemd service that makes this pin an output and high, such the the red LED is lit when the OS is active.
It also removes the second line from config.txt when found.
It doesn't cover shutdown, so the question is whether this shutdown detection got activated.

The gpio definitions in the device tree have the option to make the gpio state change trigger a kernel action, in this case shutdown.
The overlay is added to the basic device tree during the initial phases of a boot.
You can check whether the overlay is actually there in the OS image (boot/overlays) and getting activated properly.
The settings the kernel sees for gpio appear by
sudo cat /sys/kernel/debug/gpio
and there should be something there that is an input and causing an interrupt.
What could be in config.txt is something like
dtoverlay=gpio-shutdown,gpio_pin=26,active_low=1,gpio_pull=up

The source code of the actual device tree overlay you can see here:
https://github.com/raspberrypi/linux/bl ... verlay.dts
Where it says rpi-6.12.y, choose the kernel version that your OS has (uname -r).

Like the setting of the LED was brought to user space, one can also do this with the shutdown interrupt.
In case needed I can send you some example code. It's what I did in my G2 after an upgrade with a Radxa CM5.
W0KHZ
Posts: 2
Joined: Wed Dec 03, 2025 11:19 pm

Re: Button shutdown not detecting a press

Post by W0KHZ »

Thank you for your help on this. Just so you know, you are dealing with a novice here using Linux. I know enough to be dangerous and that's about it. This is way over my head.

Here are a few lines in /sys/kernel/debug/gpio that might be of interest...

gpio-553 (PWR_GPIO |pwr_button ) in hi ACTIVE LOW
gpio-562 (BT_ON |shutdown ) out hi

The kernel version of my OS is: 6.12.34+rpt-rpi-2712

The script I found that doesn't work has this:

sleep 20
gpioget --bias=pull-up gpiochip0 26
pinvalue=1
sleep 2
echo "waiting for shutdown to be triggered..."
while [ $pinvalue -eq 1 ]
do
# poll input every second, and wait for logic zero
pinvalue=$(gpioget --bias=pull-up gpiochip0 26)
sleep 1
done
echo "shutdown request detected"
shutdown 0

Thanks again for any assistance you can provide.
Post Reply

Return to “G2 Operating System & Applications”