WS281x-LED-Status Plugin: SPI Intializing von RPi4b fails

Hello,

I have trouble activating the WS281x-LED-Status Plugin on a Raspberry 4B. I only get the error message "code -13 (Unable to initialize SPI)')" in the debug log for the plugin.

The hardware is fine (it worked before a fresh Octoprint install). It also worked before as i mentioned.

What i checked:

  • Plugin OS Test is fine
  • SPI is activated (and the Octoprint User has the right permissions)

Wanted to try GPIO 20 but the plugin did not recognize this pin.

Thanks for any help!

Did you add the option dtoverlay=spi1-3cs to the file /boot/config.txt like it says in the plugin's doc?

Hello Walter,

yes, also had the spi1.* Devices visible in /dev/

But GPIO input got marked red an the logfile showed an output "code -11 (Selected GPIO not possible)')"

Maybe i am missing something very basic in the Raspberry Config, but i don't know what.

Is there a specific reason preventing you from using the default GPIO 10? That is what I am using on both of my Pi4s and it works.

Yes, this error when using PIN 10:

[quote="flankendiskriminator, post:1, topic:60799"]
"code -13 (Unable to initialize SPI)')"[/quote]

This is my working /boot/config.txt. You can compare if you have the same options enabled:

arm_64bit=0
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Disable compensation for displays with overscan
disable_overscan=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

[all]
# enable raspicam
start_x=1
gpu_mem=128
core_freq_min=500

Hey Walter, still the same error (code -13)

Don't know what has changed after reinstalling octoprint, before destroying my old image the torch worked fine.

One more thing that is not in /boot/config.txt is the SPI buffer size. Did you do this?:

  • Adding spidev.bufsize=32768 to the end of /boot/cmdline.txt

Btw. here is my Octopi/OctoPrint version:

  • OctoPrint 1.10.2
  • Python 3.9.2
  • OctoPi* 1.0.0cam (build 2024.06.18.101629)

Yes, bufsize is set.

OctoPrint version : 1.10.2
OctoPi version : 1.0.0
Python: 3.9.2

Do you have a touchscreen connected to your Pi4 that also uses SPI?

Touchscreen yes, but i guess not SPI, as it is the original RPIO-7LCD.

Well, you can take it off to test and see what happens. :slight_smile:

Same error (-13, Initalizing failed)

OK, found the issue (loaded strandtest.py from the repo of ws281x): My pi user has no permission to access /dev/mem.

Nothing giving access to the user worked, so now Octoprint is running as Root. Not perfect, but at least it works.

++ @Charlie_Powell

I am having the same issue, however, I do not want to run Octoprint as Root. From what I understand, even with a touchscreen on SPI GPIO10, it should be able to also communicate with the LED. BTW, during all this, I don't physically have my touchscreen connected. However I get: RuntimeError('ws2811_init failed with code -13 (Unable to initialize SPI)'.
Utilities show everything should be good to go.

image

When I SSH into the Pi using the 'pi' username, I cannot access the /dev/mem folder without prompt. strandtest.py works fine on GPIO18, however must run with SUDO. The octo software is under the home/pi folder, so, maybe I need to assign 'pi' access to the dev/mem folder? If this is impossible with a touchscreen, I may have to resort to having octoprint run as root. Any other ideas?

Oh shit, i wanted to followup.... After testing with strandtest, i came up with that the permissions on the GPIO device are still incorrect. After getting strandtest working as 'pi' the plugin worked flawlessy.

Try this two commands:

sudo chown root.gpio /dev/gpiomem
sudo chmod g+rw /dev/gpiomem

(You should also put these commands - without sudo - in the /etc/rc.local, so they are executed at every startup)

This should give 'pi' the correct permissions to access the gpio device (the device on my installation did not had user rights to access, there "User in gpio group" is insufficent).