-
-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Plugin Version
PhysicalButton: Version 0.6.2
Octoprint: Version 1.10.3
OctoPi: Version 1.1.0, running on Raspberry Pi 4 Model B Rev 1.2
Sorry for the long post, but I wanted to be detailed in my diagnosis
Describe the bug
PhysicalButton is overriding the pullup state of configured inputs to the factory-default pullup/pulldown/no-pullup state. It's even overriding the overrides in configure.txt firmware which can set state very early in boot process. Doing this renders buttons inoperable because they are floating with no internal pullup/pulldown. My buttons stop working.
Example
I have a button on GPIO17 to control my relay on GPIO26. GPIO17 input state defaults to no-pullup but I want to use the built-in pullup so I can just ground the pin with my button to activate.
I have an override in my pi's config.txt to force the GPIOs I need for buttons to enable the internal pull-up.
/boot/firmware/config.txt
gpio=17=ip,pu
See the Raspi docs on pinctrl output to decode, but briefly:
ip=input and op=output
pu=pullup pd=pulldown and pn=pullup_none
If I completely disable octoprint daemon, and reboot the pi, my GPIO17 pin is in the desired state overridden by my config.txt values, as expected. GPIO26 will get converted to output by PhysicalButton when it executes later, so it's fine as-is for now..
root@octopi:/home/pi# pinctrl get 17,25
17: ip pu | hi // GPIO17 = input
26: ip pd | lo // GPIO26 = input
However, when PhysicalButton plugin starts or saves the state, it is reverting the GPIO17 pin back to no-pullup state. I've confirmed this by writing a watcher shell script that checks the states every 1 second and can see it happen after direct interaction with PhysicalButton (startup/saves/edits/etc).
I've also confirmed this is linked to PhysicalButton plugin, because pin states are not altered when the plugin is disabled in Octoprint plugin manager.
To Reproduce
Reboot the Pi with octoprint disabled
root@octopi:/home/pi# systemctl disable octoprint
Removed "/etc/systemd/system/multi-user.target.wants/octoprint.service".
root@octopi:/home/pi# reboot
The system will reboot now!
root@octopi:/home/pi#
After reboot:
root@octopi:/home/pi# pinctrl get 17,25
17: ip pu | hi // GPIO17 = input
26: ip pd | lo // GPIO26 = input
#start Octoprint:
root@octopi:/home/pi# systemctl enable octoprint
Created symlink /etc/systemd/system/multi-user.target.wants/octoprint.service → /etc/systemd/system/octoprint.service.
root@octopi:/home/pi# systemctl start octoprint
#
#wait a little bit for octopriint to start
#
root@octopi:/home/pi# pinctrl get 17,26
17: ip pn | lo // GPIO17 = input
26: op -- pn | lo // GPIO26 = output
GPIO17 (my button) has reverted to no-pullup (FAIL)
GPIO26 (my relau) has gone to output mode (PASS)
The same thing happens if you
- Set the GPIO17 states to use pullup in SSH session
pinctrl set 17 ip pu- Go into Octoprint > Plugin PhysicalButton > edit button
- save settings in browser
- re-check pin configs via SSH
pinctrl get 17,26and see GPIO17 pullup is none again.
Expected behavior
PhysicalButton should not be reverting input GPIO pins to no-pullup.
It looks like there's code to default to pullup-true on button setup, but I can't figure out why it's choosing no-pullup (other than that's the pin default on GPIO17 from what I can tell.
Additional context
FYI - I had this GPIO setup (button & relay on pins 17 & 26) working OK in my previous setup. Same exact PI board, with same pins but older version of octoprint (using python 2.x), So I don't think it's a hardware issue since that suff is same, and I've checked with multi meter that electronics seem to be OK. I'd have to dig through that SD card image to figure out exactly what versions I had that worked.