Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What to do if you see: ws2811_init failed with code -1 #70

Closed
Gadgetoid opened this issue Jul 12, 2016 · 10 comments
Closed

What to do if you see: ws2811_init failed with code -1 #70

Gadgetoid opened this issue Jul 12, 2016 · 10 comments

Comments

@Gadgetoid
Copy link
Member

Gadgetoid commented Jul 12, 2016

Update

The rpi_ws281x part of the library has been moved out of this GitHub repository to its own home at: https://github.com/pimoroni/rpi_ws281x-python which will eventually build against the upstream version of the C source.

This newer version includes more detailed error messages and exit codes, you can look them up here: https://github.com/jgarff/rpi_ws281x/blob/f56929f79e75e253ca5bd230efb728c39f413e2b/ws2811.h#L93-L108

#define WS2811_RETURN_STATES(X)                                                             \
            X(0, WS2811_SUCCESS, "Success"),                                                \
            X(-1, WS2811_ERROR_GENERIC, "Generic failure"),                                 \
            X(-2, WS2811_ERROR_OUT_OF_MEMORY, "Out of memory"),                             \
            X(-3, WS2811_ERROR_HW_NOT_SUPPORTED, "Hardware revision is not supported"),     \
            X(-4, WS2811_ERROR_MEM_LOCK, "Memory lock failed"),                             \
            X(-5, WS2811_ERROR_MMAP, "mmap() failed"),                                      \
            X(-6, WS2811_ERROR_MAP_REGISTERS, "Unable to map registers into userspace"),    \
            X(-7, WS2811_ERROR_GPIO_INIT, "Unable to initialize GPIO"),                     \
            X(-8, WS2811_ERROR_PWM_SETUP, "Unable to initialize PWM"),                      \
            X(-9, WS2811_ERROR_MAILBOX_DEVICE, "Failed to create mailbox device"),          \
            X(-10, WS2811_ERROR_DMA, "DMA error"),                                          \
            X(-11, WS2811_ERROR_ILLEGAL_GPIO, "Selected GPIO not possible"),                \
            X(-12, WS2811_ERROR_PCM_SETUP, "Unable to initialize PCM"),                     \
            X(-13, WS2811_ERROR_SPI_SETUP, "Unable to initialize SPI"),                     \
            X(-14, WS2811_ERROR_SPI_TRANSFER, "SPI transfer error")                         \

The correct error code for an unsupported hardware revision is now -3, if you see this code please follow the instructions below.

Original post for posterity:

If you see the ws2811_init failed with code -1 message, a number of things could be going wrong since the error -1 is returned for all exceptions when initializing the ws2811 library.

The most common cause thus far, however, is a new, or unknown revision of Raspberry Pi which is not logged in the rpihw.c file. To determine your revision number run:

cat /proc/cpuinfo | grep Revision

Compare this against the numbers in: https://github.com/pimoroni/unicorn-hat/blob/master/library/rpi-ws281x/lib/rpihw.c

If you don't see your revision number there, let us know. You should also submit an issue against https://github.com/jgarff/rpi_ws281x, with details of your Pi.

@macom2000
Copy link

macom2000 commented Dec 21, 2016

cat /proc/cpuinfo | grep Revision

gives

Revision : 0000
What can I do? Hardware is Banana Pi

@tolgraven
Copy link

Zero v1.3

CPU revision	: 7
Revision	: 1900093

Building and running rpi_ws281x lib straight actually works, but unicorn fails with -1.

@martinsmac
Copy link

I am having this problem on a Picture Zero W.
9000c1
You have defined this board in the header. Any ideas?

@JustinGT
Copy link

JustinGT commented Mar 5, 2017

Same issue here on Pi Zero W (with latest apt-get update etc).
Revision : 9000c1
Which is defined in the header: https://github.com/pimoroni/unicorn-hat/blob/master/library/rpi-ws281x/lib/rpihw.c#L205
Has everything been recompiled or is this something else?

Addition: When placing the same SD card into a Pi 3 it all works.

@martinsmac
Copy link

I rebuilt the rpi_ws2811 library on my pi w and it works fine now.

@RogueM
Copy link
Contributor

RogueM commented Mar 5, 2017

interesting... recompiled from the repo you mean, right? hum, yes, we have been thinking it's the pypi distributed source that somehow is dodgy in some way, though at a quick glance it wasn't obvious. Certainly the source in this repo is what we tested against the zero W.

@martinsmac
Copy link

I cloned this repo and recompiled the C library locally. I then ran setup.py. My intention was simply to add better error messages, rather than -1 for all cases. Once recompiled it started working and I never saw the errors codes I had added.

@djungowski
Copy link

I was having the exact same issue until I realized that I simply forgot to run my python scripts as root.

@juanCGVE
Copy link

juanCGVE commented Aug 3, 2021

cat /proc/cpuinfo | grep Revision
shows:
Revision : 0000
My hardware is a NanoPi neo Core
Can you tell me how to solve it?

@Gadgetoid
Copy link
Member Author

The NanoPi neo Core is not a Raspberry Pi board and will not work with rpi_ws281x. You'd need to figure out how to exploit its hardware features to generate a WS281X-compatible signal, or get Googling and see if someone else has done so. While rpi_ws281x is extremely specific to the Pi hardware, the techniques it uses are likely portable by someone with the right documentation, expertise and inclination.

Looks like there's been interest in ws2812 on the NanoPi since at least 2016 with nobody rising to the challenge, so YMMV - http://www.friendlyarm.net/forum/topic/6839

The easy solution? Buy a Raspberry Pi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants