[Solved] Octoprint-Filament-Reloaded-OrangePi


I'm having an issue with this plugin: Octoprint-Filament-Reloaded-OrangePi

The board is an orange pi zero plus (H5) Armbian:

pi@octo:~$ uname -a
Linux octo 4.14.65-sunxi64 #6 SMP Mon Aug 20 20:01:45 CEST 2018 aarch64 GNU/Linux

The following error appears in the log:

"IOError: [Errno 13] Permission denied: '/sys/class/gpio/gpio14/direction'"

The plugin appears to set up the pin correctly via:

pi@octo:~$ cat /sys/class/gpio/gpio14/direction

ls -al  /sys/class/gpio/
-rwxrwx---  1 root gpio 4096 Aug 27 20:07 export
lrwxrwxrwx  1 root root    0 Aug 27 20:16 gpio14 -> ../../devices/platform/soc/1c20800.pinctrl/gpiochip1/gpio/gpio14
lrwxrwxrwx  1 root root    0 Dec 31  1969 gpiochip0 -> ../../devices/platform/soc/1c20800.pinctrl/gpio/gpiochip0
lrwxrwxrwx  1 root root    0 Dec 31  1969 gpiochip352 -> ../../devices/platform/soc/1f02c00.pinctrl/gpio/gpiochip352
-rwxrwx---  1 root gpio 4096 Aug 27 19:55 unexport

The gpio permissions seem to be proper; I can do the following as pi user (without sudo):

pi@octo:~$ echo out | tee /sys/class/gpio/gpio14/direction
pi@octo:~$ echo in | tee /sys/class/gpio/gpio14/direction

As pi user, I can:

pi@octo:~$ echo out | tee /sys/class/gpio/gpio14/direction
pi@octo:~$ echo 0 > /sys/class/gpio/gpio14/value
pi@octo:~$ cat /sys/class/gpio/gpio14/value
pi@octo:~$ echo 1 > /sys/class/gpio/gpio14/value
pi@octo:~$ cat /sys/class/gpio/gpio14/value

Seems to be an issue with the plugin.

Thanks for your feedback.


Well, we see that the rights/ownership of /sys/class/gpio/gpio14 is currently (promiscuous) at 777 and root:root. I don't recall, but I'd imagine that Guy included the pi user in the gpio group. But then again, you haven't mentioned whether or not you used the OctoPi image for this.

It probably wouldn't hurt to see an ls -l /sys/class/gpio/gpio14 to see what the rights/ownership are for that direction file.


Thanks for the reply.

I was able to solve this, although not "elegant", by editing /home/pi/OctoPrint/venv/lib/python2.7/site-packages/OPi/GPIO.py

  1. Added import time
  2. Added time.sleep(0.1)

This "fix" is referenced here. It has to do with udev rules synchronously changing permissions slowly.

I setup marlin M600 as described here by @rmeijsSdu

Here are the results of: ls -l /sys/class/gpio/gpio14

lrwxrwxrwx 1 root gpio 0 Aug 28 15:09 /sys/class/gpio/gpio14 -> ../../devices/platform/soc/1c20800.pinctrl/gpiochip1/gpio/gpio14

Octoprint runs great on this board.


how the h%$#@% did you find that plugin? I never put a link to it nowhere :smiley: :smiley: :smiley: nor I added it to the list of plugins on official repo of the octoprint?

the plugin works but barely :frowning: since the OPI gpio library is really bad ... the only way to make it work is to add the delay so to avoid the race condition with the file and udev systems .. I was hoping that either that library will fix itself or that armbian will somehow fix itself or whatever but didn't want to make fork of the lib myself as I'm really not a python dev so it makes zero sense.. I run this plugin on my computers with the same "delay" hack in the lib :frowning: ..


I almost mentioned that issue but I wasn't sure that the particular package was in use. I'm glad you persisted and had the cleverness to edit the code in place. You might need to babysit this each update since something else might "rev up" that particular package. Well done.