gerrond
AFAIK the syntax to load the overlay from console should be:
dtoverlay gpio-shutdown gpio_pin=3,active_low=1,gpio_pull=up
dtoverlay -l then has βgpio-shutdownβ in the list?
Ah:
2019-06-20 21:15:59 root@micha:/tmp# dtoverlay -h gpio-shutdown
Name: gpio-shutdown
Info: Initiates a shutdown when GPIO pin changes. The given GPIO pin
is configured as an input key that generates KEY_POWER events.
This event is handled by systemd-logind by initiating a
shutdown. Systemd versions older than 225 need an udev rule
enable listening to the input device:
CPU temp : 53βC : 127βF (Running warm, but safe)
FQDN/hostname : alarmPi2
LAN IP : 192.168.1.73 (eth0)
MOTD : You can select the content of this banner by running: dietpi-banner
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
stops the green LED and leaves the red LED on as expected but the USB current goes up from 0A68 to 0A82 - this is not what I expected! Raspbian April 2019 current goes down to 0A21. I donβt know whether it is inherrent in my dietPi or is due to the result of the dtoverlay thing.
Downloaded , uncompressed and uploaded todayβs 7z to card.
Accepted minimal image.
After updates, entered βshutdown nowβ, current now falls to 0A19.
root@alarmPi2:~# dtoverlay gpio-shutdown gpio_pin=3,active_low=1,gpio_pull=up
DTOVERLAY[error]: invalid override value '3,active_low=1,gpio_pull=up' - ignored
* Failed to set gpio_pin=3,active_low=1,gpio_pull=up
root@alarmPi2:~# dtoverlay=gpio-shutdown gpio_pin=3,active_low=1,gpio_pull=up
root@alarmPi2:~# dtoverlay -l
No overlays loaded
dtoverlay=gpio-shutdownβ¦ from command line btw cannot work. Itβs shell syntax to create a variable but not run any command.
Just to check: echo $dtoverlay
It looks like all parameters need to be separated by spaces (separate arguments):
The usage info is indeed misleading.
dtoverlay -h gpio-shutdown shows dtoverlay=gpio-shutdown,=, but this is only the syntax for config.txt, not the command line. This is shown by the general dtoverlay usage info:
dtoverlay [=β¦]
But there again one cannot derive how to add multiple parameters. However space separated makes sense as these are then added as individual arguments to the command.
systemd-logind is unmasked? systemctl unmask systemd-logind && systemctl start systemd-logind
And nothing else blocks/uses the GPIO pins, e.g. I2C, SPI or UART (serial device/console)?
ls -Al /dev gives an overview of enabled devices, ttyS0, ttyAMA0, i2c*, and spi* are examples that use GPIO pins.
johncolman
Try to disable this serial device, as long as you donβt use any serial/UART login terminal:
/DietPi/dietpi/func/dietpi-set_hardware serialconsole disable
Although I am not 100% sure if this disables /dev/ttyAMA0. It disables any boot messages and login console attached to this device, but via usual methods one can only disable /dev/ttyS0 completely on RPi models with WiFi+Bluetooth. /dev/ttyAMA0 shows up when Bluetooth is disabled, since otherwise Bluetooth uses/block this. /dev/ttyAMA0 uses GPIO 14 & 15 (so pins 8 & 10) AFAIK, so these cannot not be used for the shutdown button.
Aside the hardware side, you assured the user that executes the script has sufficient permissions (e.g. part of βgpioβ group)? dtoverlay declaration in /DietPi/config.txt (and /boot/config.txt on Raspbian) is exactly the same?
lsmod lists gpio_keys?
I ran
/DietPi/dietpi/func/dietpi-set_hardware serialconsole disable
No change.
I donβt have a script running , just the dtoverlay line added to the DietPi.txt, so havenβt changed any permissions.
I have checked both txt files are the same.
lsmod lists gpio_keys just returns Usage: lsmod
johncolman
lsmod is the command you should use and the output should contain gpio_keys.
dtoverlay -l only shows the overlays loaded at runtime, thus not the ones added to config.txt.
Note as mentioned above that the syntax for loading overlays at runtime is slightly different, e.g.:
dtoverlay gpio-shutdown gpio_pin=3 active_low=1 gpio_pull=up
Not sure currently if this fails, when loaded via config.txt already, but AFAIK it works. Then you can check via dtoverlay -l if it has been successfully loaded, respectively otherwise the first will throw an error message already.
If overlay and module is loaded and systemd-logind running (systemctl status systemd-logind) and the shutdown button does still not work, then we have to check if the pins are responding as expected. I donβt have the commands here, but it is possible to send input to the keys from command lines as well, as well as checking the current state of the physical pins.
Ok typed the wrong thing for lsmod, this is the reply from lsmod
gpio_keys 9575 0
When I run the overlay from the command line with spaces I get
Failed to apply overlay β0_gpio-shutdownβ (kernel)
This is what I get when I run systemctl
root@DietPi:~# systemctl unmask systemd-logind
root@DietPi:~# systemctl status systemd-logind
β systemd-logind.service - Login Service
Loaded: loaded (/lib/systemd/system/systemd-logind.service; static; vendor preset: enabled)
Active: inactive (dead)
Condition: start condition failed at Sat 2019-08-17 22:06:53 BST; 1 day 19h ago
Docs: man:systemd-logind.service(8)
man:logind.conf(5) http://www.freedesktop.org/wiki/Software/systemd/logind http://www.freedesktop.org/wiki/Software/systemd/multiseat
It shuts down and a second click of the button it restarts. Tried it a few times and works ok. I will try adding the super capacitor UPS on pin 18 next.
johncolman
Great, probably some info we should add somewhere, at least to dietpi.txt where you can set systemd-logind to be enabled prior to first boot.
Was dbus sufficient or libpam-systemd required as well?
Okay, could be tested, but actually the docs state that libpam-systemd is required for logind functionality in general: https://packages.debian.org/stretch/libpam-systemd
The only other thing that systemd-logind does, AFAIK, is automatically spawning gettys on demand, but not tracking/handling any session tasks.