Moode Forum
dtoverlay changes? - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: dtoverlay changes? (/showthread.php?tid=1686)



dtoverlay changes? - Listener - 09-04-2019

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


RE: dtoverlay changes? - TheOldPresbyope - 09-04-2019

(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


RE: dtoverlay changes? - Tim Curtis - 09-04-2019

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



RE: dtoverlay changes? - Listener - 09-05-2019

(09-04-2019, 03:33 PM)TheOldPresbyope Wrote: What model RPi? 

Regards,
Kent

It is a 3b+.

     John


RE: dtoverlay changes? - TheOldPresbyope - 09-05-2019

@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



RE: dtoverlay changes? - TheOldPresbyope - 09-05-2019

@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


RE: dtoverlay changes? - Listener - 09-05-2019

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


RE: dtoverlay changes? - lopchu - 03-05-2020

Hello,

does


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

work with current release (using a RPi3 B if that matters)?

I wanted to add a power button according to this guide

https://bitreporter.de/raspberrypi/richtiger-an-ausschalter-fur-den-raspberry-pi

It is in German but basically says:

Connect button to GPIO3 and GND, add line above to /boot/config.txt.

Will that work with moode audio?


RE: dtoverlay changes? - lopchu - 03-24-2020

I can answer my own question: it works.

I ordered a simple cable with a button (this one). In /boot/config.txt, I added:

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

(These are the default settings, so not necessary). And then had to comment out these entries:

Code:
#dtparam=i2c_arm-on
#dtparam=i2s=on

(I am not sure if both are necessary but they were commented out in the link I was following, see previous post).

P.S. Raspberry PI 3B, Moode 6.4.2 2020-02-12


RE: dtoverlay changes? - DRONE7 - 03-24-2020

Quote:(I am not sure if both are necessary but they were commented out in the link I was following, see previous post).

If you are using a USB audio device or the Pi's onboard audio that will be ok.
If you are or ever use a HAT dac or i2s connected dac or devices needing i2c connection (Oled displays etc) then you will need to uncomment those lines.