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

ws2811_init fails with error code -3 on RPi 3B+ with ArchLinuxARM aarch64 #350

Closed
nils-van-zuijlen opened this issue Feb 3, 2019 · 4 comments

Comments

@nils-van-zuijlen
Copy link

I am using the python library at rpi-ws281x/rpi-ws281x-python and I recently switched from raspbian to ArchLinuxARM aarch64 on my RPi.

After the upgrade, when I tried to run my code, I got

Traceback (most recent call last):
  File "LedPanel.py", line 129, in <module>
    panel = LEDPanel(0,1)
  File "LedPanel.py", line 22, in __init__
    self._strip.begin()
  File "/usr/lib/python3.7/site-packages/rpi_ws281x/rpi_ws281x.py", line 124, in begin
    raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, str_resp))
RuntimeError: ws2811_init failed with code -3 (Hardware revision is not supported)

As I wanted to know what happened, I traced the calls back to the C library in which ws2811_init was the function called and the error code was thrown at line 886.

Apparently, the return value of rpi_hw_detect was wrong. I later found that it was trying to read /proc/device-tree/system/linux,revision from my system (code at line 343 of rpihw.c) and that that file does not exist on my Pi.

How may I get it to work ?

@nils-van-zuijlen
Copy link
Author

PS: I think #183 may fix the problem I have (and somebody else may have at some time)

@jamesshawver1
Copy link

I think I found the issue with this.
Patch needed in rpihw.c - the detection for ARM64 isn't working due to the size of detection code. fread returns the number of elements, not the number of bytes read, when the guarding statement is comparing against the number of bytes read. See - https://www.tutorialspoint.com/c_standard_library/c_function_fread.htm

see line number 419/420 -

419 size_t read = fread(&rev, sizeof(uint32_t), 1, f);
420 if (read != sizeof(uint32_t))

should be

419 size_t read = fread(&rev, sizeof(uint32_t), 1, f);
420 if (read != 1)

@fooker
Copy link

fooker commented Jun 16, 2021

I have the same problem even with #395 applied (which does exactly what was mentioned in #350 (comment)). The problem is still that the file /proc/device-tree/system/linux,revision is not there on my system. In fact, the whole /proc/device-tree/system/ is missing.

I'm running on linux-5.4.106 with broadcom/bcm2837-rpi-3-b.dtb loaded.

Some maybe helpful thing i found:

# uname -a
Linux photonic 5.4.106 #1-NixOS SMP Wed Mar 17 16:03:58 UTC 2021 aarch64 GNU/Linux
# cat /proc/device-tree/model 
Raspberry Pi 3 Model B
# cat /proc/device-tree/serial-number 
00000000b43e053c
# cat /proc/device-tree/compatible 
raspberrypi,3-model-bbrcm,bcm2837

@Gadgetoid
Copy link
Collaborator

I believe the issues discussed here are likely to be invalidated by #183 as both Raspberry Pi OS/debian derivatives and aarch64 will converge on detecting ranges from /proc/device-tree/soc/ranges with... some method of checking the running system is a Raspberry Pi.

Since these issues are related, I'm closing this one in favour of focusing discussion on the PR. It would be useful for have an aarch64 user weigh in on #183

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

No branches or pull requests

4 participants