dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Having issues with your DietPi installation, or, found a bug? Post it here.
gerrond
Posts: 3
Joined: Mon Jun 17, 2019 11:59 pm

dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by gerrond » Tue Jun 18, 2019 12:06 am

Hi

Adding this line to Dietpi/config.txt does not produce the desired shut-down. The same pi3B+ using Raspbian works.

Entering dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up on the CLI produces no errors. lsmod says gpio-keys is loaded (but not used).

How to proceed?

User avatar
MichaIng
Legend
Posts: 1620
Joined: Sat Nov 18, 2017 5:21 pm

Re: dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by MichaIng » Thu Jun 20, 2019 8:22 pm

@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:

Code: Select all

2019-06-20 21:15:59 [email protected]:/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:
Please try:

Code: Select all

systemctl unmask systemd-logind
systemctl start systemd-logind

gerrond
Posts: 3
Joined: Mon Jun 17, 2019 11:59 pm

Re: dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by gerrond » Mon Jun 24, 2019 12:44 pm

─────────────────────────────────────────────────────
DietPi v6.24.1 : 12:39 - Mon 24/06/19
─────────────────────────────────────────────────────
- Device model : RPi 3 Model B+ (armv7l)
- 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
─────────────────────────────────────────────────────

DietPi Team : MichaIng (lead), Daniel Knight (founder)
Image : DietPi Core Team (pre-image: Raspbian Lite)
Web : https://DietPi.com | https://twitter.com/dietpi_
Patreon Legends : PINE64 community
Donate : https://DietPi.com/#donate
DietPi Hosting : Powered by https://MyVirtualServer.com

[email protected]:~# 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
[email protected]:~# dtoverlay=gpio-shutdown gpio_pin=3,active_low=1,gpio_pull=up
[email protected]:~# dtoverlay -l
No overlays loaded
[email protected]:~# systemctl --version
systemd 232
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN
[email protected]:~# systemctl unmask systemd-logind
[email protected]:~# systemctl start systemd-logind
Failed to start systemd-logind.service: Unit dbus.socket not found.
[email protected]:~#

gerrond
Posts: 3
Joined: Mon Jun 17, 2019 11:59 pm

Re: dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by gerrond » Mon Jun 24, 2019 1:15 pm

I have just noticed that "shutdown now" -

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.

User avatar
MichaIng
Legend
Posts: 1620
Joined: Sat Nov 18, 2017 5:21 pm

Re: dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by MichaIng » Sun Jun 30, 2019 2:09 pm

Code: Select all

[email protected]:~# 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
[email protected]:~# dtoverlay=gpio-shutdown gpio_pin=3,active_low=1,gpio_pull=up
[email protected]:~# 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):

Code: Select all

dtoverlay gpio-shutdown gpio_pin=3 active_low=1 gpio_pull=up
dtoverlay -l
The usage info is indeed misleading.
dtoverlay -h gpio-shutdown shows dtoverlay=gpio-shutdown,<param>=<val>, but this is only the syntax for config.txt, not the command line. This is shown by the general dtoverlay usage info:
dtoverlay <overlay> [<param>=<val>...]
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.

johncolman
Posts: 8
Joined: Sat Aug 17, 2019 8:05 pm

Re: dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by johncolman » Sat Aug 17, 2019 8:11 pm

I have the same problem with a Pi Zero W running v6.25.3. I have the shutdown button working on a Pi3+ running Debian.

User avatar
MichaIng
Legend
Posts: 1620
Joined: Sat Nov 18, 2017 5:21 pm

Re: dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by MichaIng » Sat Aug 17, 2019 8:46 pm

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
Posts: 8
Joined: Sat Aug 17, 2019 8:05 pm

Re: dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by johncolman » Sat Aug 17, 2019 9:03 pm

I ran those two commands didn't change anything.

Running ls -Al /dev returned this line amongst others

lrwxrwxrwx 1 root root 7 Aug 17 19:51 serial1 -> ttyAMA0

User avatar
MichaIng
Legend
Posts: 1620
Joined: Sat Nov 18, 2017 5:21 pm

Re: dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by MichaIng » Sat Aug 17, 2019 10:02 pm

@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?

johncolman
Posts: 8
Joined: Sat Aug 17, 2019 8:05 pm

Re: dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up

Post by johncolman » Sat Aug 17, 2019 10:22 pm

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

Post Reply