Thank you for your donation!


dtoverlay changes?
#1
Hello,

Did something change in version 6.x with dtoverlay support? In version 5.x I used the following code placed in /boot/config.txt to affect an orderly shut down via a momentary push button connecting gpio 3 to ground.


Code:
dtoverlay=gpio-shutdown
 
I tried gpio-poweroff as well and various parameters like gpiopin=3 and active_low=1, but no combination works for me with 6.1.0. My button is connected between header pins 5 and 9, gpio3 and ground.

Thanks,

     John
Reply
#2
(09-04-2019, 01:41 PM)Listener Wrote: Hello,

Did something change in version 6.x with dtoverlay support? In version 5.x I used the following code placed in /boot/config.txt to affect an orderly shut down via a momentary push button connecting gpio 3 to ground.


Code:
dtoverlay=gpio-shutdown
 
I tried gpio-poweroff as well and various parameters like gpiopin=3 and active_low=1, but no combination works for me with 6.1.0. My button is connected between header pins 5 and 9, gpio3 and ground.

Thanks,

     John

What model RPi? 

Regards,
Kent
Reply
#3
Maybe the parameter names changed for that overlay. I don't really track that kind of stuff.

You could try the command below to see if there were any errors logged when the kernel tried to load the overlay.

Code:
sudo vcdbg log msg
Reply
#4
(09-04-2019, 03:33 PM)TheOldPresbyope Wrote: What model RPi? 

Regards,
Kent

It is a 3b+.

     John
Reply
#5
@Listener

Ah. I was thinking it might be an RPi4B, which is so different internally that the firmware- and Raspbian-developers are still working out kinks.

I have never tried this shutdown overlay so don't have personal experience. The current firmware documentation says (I pasted this snippet as code rather than quote so the text formatting doesn't break up):

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

               ACTION!="REMOVE", SUBSYSTEM=="input", KERNEL=="event*", \
                       SUBSYSTEMS=="platform", DRIVERS=="gpio-keys", \
                       ATTRS{keys}=="116", TAG+="power-switch"

       This overlay only handles shutdown. After shutdown, the system
       can be powered up again by driving GPIO3 low. The default
       configuration uses GPIO3 with a pullup, so if you connect a
       button between GPIO3 and GND (pin 5 and 6 on the 40-pin header),
       you get a shutdown and power-up button.
Load:   dtoverlay=gpio-shutdown,<param>=<val>
Params: gpio_pin                GPIO pin to trigger on (default 3)

       active_low              When this is 1 (active low), a falling
                               edge generates a key down event and a
                               rising edge generates a key up event.
                               When this is 0 (active high), this is
                               reversed. The default is 1 (active low).

       gpio_pull               Desired pull-up/down state (off, down, up)
                               Default is "up".

                               Note that the default pin (GPIO3) has an
                               external pullup.

So, no, the parameter names don't appear to have changed.

(We're up to systemd version 241 in moOde 6.1.0, so the udev rule is unnecessary.)

I know this says the default pin is 3 but I suggest you try the full invocation anyway:

Code:
dtoverlay=gpio-shutdown,gpio_pin=3

Note the underscore in "gpio_pin".

If I get a chance tomorrow I'll try this for myself.

Regards,
Kent

Post-edit notes:

[1] Tim's suggestion will turn up bad parameter names
[2] It turns out I didn't need to go to the github repo. I could have printed out the same information at the command line entering a command I didn't know about until 1 minute ago:

Code:
dtoverlay -h gpio-shutdown
Reply
#6
@Listener
@Tim Curtis

Ok, my post last night was correct but not helpful. This morning I found the problem.

Hardware: moOde 6.1.0 on RPi3B+ (I don't think the model matters). Onboard audio device.

From the cli, add the gpio-shutdown overlay

Code:
pi@moode:~ $ sudo dtoverlay gpio-shutdown


In a second terminal window I see the following syslog output

Code:
pi@moode:~ $ tail -f /var/log/syslog
...
Sep  5 08:14:12 moode0w kernel: [   89.417778] pinctrl-bcm2835 3f200000.gpio: pin gpio3 already requested by 3f804000.i2c; cannot claim for soc:shutdown_button
Sep  5 08:14:12 moode0w kernel: [   89.417791] pinctrl-bcm2835 3f200000.gpio: pin-3 (soc:shutdown_button) status -22
Sep  5 08:14:12 moode0w kernel: [   89.417797] pinctrl-bcm2835 3f200000.gpio: could not request pin 3 (gpio3) from group gpio3  on device pinctrl-bcm2835
Sep  5 08:14:12 moode0w kernel: [   89.417802] gpio-keys soc:shutdown_button: Error applying setting, reverse things back
Sep  5 08:14:12 moode0w kernel: [   89.417826] gpio-keys: probe of soc:shutdown_button failed with error -22

Hmmm. Pin assignment conflict with i2c. Doh. My chart shows gpio pin 3 is assigned to i2c SCL. Naturally setting explicitly gpio_pin=3 similarly fails.

Choosing pin 4 as the shutdown pin, Raspbian seems happy:

Code:
pi@moode:~ $ sudo dtoverlay -r gpio-shutdown
pi@moode:~ $ sudo dtoverlay gpio-shutdown gpio_pin=4

-----

pi@moode:~ $ tail -f /var/log/syslog
...
Sep  5 08:21:28 moode0w kernel: [  525.269002] input: soc:shutdown_button as /devices/platform/soc/soc:shutdown_button/input/input0

However, shorting this pin to ground doesn't shutdown the Pi. I don't have time this morning to do any homework on the correct choice of pin and level but this should get you started in the right direction.

Regards,
Kent
Reply
#7
OK Kent,

That is a good trailhead. I'll be off grid for four days in the Sierra, so I won't be able to pursue it until next week.

Thanks,

    John
Reply


Forum Jump: