Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtoverlay=gpio-shutdown not working #389

Open
amolotkov opened this issue Mar 4, 2024 · 14 comments
Open

dtoverlay=gpio-shutdown not working #389

amolotkov opened this issue Mar 4, 2024 · 14 comments
Labels
support support

Comments

@amolotkov
Copy link

Following configuration is not working on the build from March 2nd.
dtoverlay=gpio-shutdown,gpio_pin=20,active_low=1,gpio_pull=down

Same config works on vanilla bookworm

@mgrouch
Copy link

mgrouch commented Mar 4, 2024

is gpio-keys module loaded.

You might be missing some additional configuration

Might be this thread could help you troubleshoot
https://forums.raspberrypi.com/viewtopic.php?t=261452

@mgrouch mgrouch added the support support label Mar 4, 2024
@amolotkov
Copy link
Author

Everything seems to be as expected, Also I've noticed that OS ignores the RPI on board power off button as well

adedd dtoverlay=gpio-keys to config

/sbin/lsmod
Module Size Used by
...
gpio_keys 20480 0
...

sudo gpioinfo
...
line 20: "PIN38" "shutdown" input active-low [used]
...
line 26: "PIN37" "power_ctrl" output active-low [used]

user@lysmarine:~ $ grep gpio /proc/interrupts
171: 0 0 0 0 107d508500.gpio 20 Edge pwr_button

There are events when I drive the Pin to Low

user@lysmarine:~ $ sudo hexdump /dev/input/event0
0000000 19c6 65e6 0000 0000 9bb9 0006 0000 0000
0000010 0001 0074 0001 0000 19c6 65e6 0000 0000
0000020 9bb9 0006 0000 0000 0000 0000 0000 0000

and

sudo journalctl | grep -i power
Mar 04 19:07:53 lysmarine systemd-logind[747]: Power key pressed short.
Mar 04 19:07:54 lysmarine systemd-logind[747]: Power key pressed short.
Mar 04 19:07:55 lysmarine systemd-logind[747]: Power key pressed short.
Mar 04 19:08:28 lysmarine systemd-logind[747]: Power key pressed short.

Here is the content of the /etc/systemd/logind.conf

#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the logind.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/logind.conf' to display the full config.
#
# See logind.conf(5) for details.

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff
#HandlePowerKeyLongPress=poweroff
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#RebootKeyIgnoreInhibited=no
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RuntimeDirectoryInodesMax=
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#StopIdleSessionSec=infinity

@mgrouch
Copy link

mgrouch commented Mar 4, 2024

What’s the output of

systemd-analyze cat-config systemd/logind.conf

@amolotkov
Copy link
Author

amolotkov commented Mar 4, 2024

user@lysmarine:~ $ systemd-analyze cat-config systemd/logind.conf
# /etc/systemd/logind.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the logind.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/logind.conf' to display the full config.
#
# See logind.conf(5) for details.

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff
#HandlePowerKeyLongPress=poweroff
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#RebootKeyIgnoreInhibited=no
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RuntimeDirectoryInodesMax=
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#StopIdleSessionSec=infinity

@mgrouch
Copy link

mgrouch commented Mar 4, 2024

Things to check:

is systemd-logind service enabled?

sudo systemctl status systemd-logind

what happens when you initiate shutdown via gpio?

does logind receive that event?

Commands to run

dmesg

journalctl

do you have power off button on your keyboard?
Does it work?

check power management settings

@amolotkov
Copy link
Author

user@lysmarine:~ $ sudo systemctl  status systemd-logind
[sudo] password for user: 
● systemd-logind.service - User Login Management
     Loaded: loaded (/lib/systemd/system/systemd-logind.service; static)
     Active: active (running) since Mon 2024-03-04 15:08:11 PST; 1min 31s ago
       Docs: man:sd-login(3)
             man:systemd-logind.service(8)
             man:logind.conf(5)
             man:org.freedesktop.login1(5)
   Main PID: 768 (systemd-logind)
     Status: "Processing requests..."
      Tasks: 1 (limit: 9250)
        CPU: 148ms
     CGroup: /system.slice/systemd-logind.service
             └─768 /lib/systemd/systemd-logind

Mar 04 15:08:11 lysmarine systemd-logind[768]: Watching system buttons on /dev/input/event4 (Logitech K400)
Mar 04 15:08:11 lysmarine systemd-logind[768]: Watching system buttons on /dev/input/event1 (pwr_button)
Mar 04 15:08:11 lysmarine systemd-logind[768]: Watching system buttons on /dev/input/event2 (vc4-hdmi-0)
Mar 04 15:08:11 lysmarine systemd-logind[768]: Watching system buttons on /dev/input/event3 (vc4-hdmi-1)
Mar 04 15:08:11 lysmarine systemd-logind[768]: Watching system buttons on /dev/input/event0 (soc:shutdown_button@14)
Mar 04 15:08:11 lysmarine systemd[1]: Started systemd-logind.service - User Login Management.
Mar 04 15:08:18 lysmarine systemd-logind[768]: New session 1 of user user.
Mar 04 15:08:19 lysmarine systemd-logind[768]: New session c1 of user lightdm.
Mar 04 15:08:20 lysmarine systemd-logind[768]: Removed session c1.
Mar 04 15:08:20 lysmarine systemd-logind[768]: New session 4 of user user.
user@lysmarine:~ $ 


what happens when you initiate shutdown via gpio?

Nothing

does logind receive that event?

Mar 04 15:36:41 lysmarine systemd-logind[768]: Power key pressed short.
Mar 04 15:36:46 lysmarine sudo[3996]: user : TTY=pts/0 ; PWD=/home/user ; USER=root ; COMMAND=/usr/bin/journalctl -e
Mar 04 15:36:46 lysmarine sudo[3996]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)

do you have power off button on your keyboard?
Does it work?

I don't have power button on keyboard, but power button on Raspberry Pi5 board doesn't work as well

check power management settings

What can I check there. It's only 2 options Balanced/Power saver - Changing them have no effect

@mgrouch
Copy link

mgrouch commented Mar 4, 2024

How long do you hold power button on pi5 board?
It’s working for me

@amolotkov
Copy link
Author

How long do you hold power button on pi5 board? It’s working for me

Pressing and releasing, Long press doesn't make any difference as well. I have a fresh install , really strange

@mgrouch
Copy link

mgrouch commented Mar 5, 2024

Anything powered connected via USB and leaking power into pi5?

@amolotkov
Copy link
Author

Nope, nothing external connected to PI except 5 v power. This exact rig and exact config works as expected with vanilla raspberry OS, and Open Plotter

@mgrouch mgrouch changed the title dtoverlay=gpio-shutdown not wporking dtoverlay=gpio-shutdown not working Mar 5, 2024
@mgrouch
Copy link

mgrouch commented Mar 6, 2024

Another thing to try:

sudo systemctl disable upower
sudo systemctl stop upower
systemd-inhibit --list

@mgrouch
Copy link

mgrouch commented Mar 6, 2024

There is also this discussion

systemd/systemd#28902

so another thing to try:


sudo systemctl disable ctrl-alt-del.target
sudo systemctl enable poweroff.target

@mgrouch
Copy link

mgrouch commented Mar 6, 2024

Some more details on how things work:

https://medium.com/@buzondefede/shutdown-from-power-button-explained-in-ubuntu-22-04-3fbe671b5765

looks like some app installed inhibitor on logind (systemd) power off events

@amolotkov
Copy link
Author

Some more details on how things work:

https://medium.com/@buzondefede/shutdown-from-power-button-explained-in-ubuntu-22-04-3fbe671b5765

looks like some app installed inhibitor on logind (systemd) power off events

Yah, that what I thought. Thank's for help, I'll play around with your solutions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support support
Projects
None yet
Development

No branches or pull requests

2 participants