[FEDORA - AARCH64 - error compiling ws281x]

Hello guys,

I am trying to make a unicornhat work with fedora28 using aarch64.

pip is not working with a compilation error, so I tried from a git clone.
So the issue is from pri-ws281x that is not compiling well :

Compiling ws281x library…
b’lib/ws2811.c: In function \xe2\x80\x98setup_pwm\xe2\x80\x99:\nlib/ws2811.c:395:23: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]\n dma_cb->dest_ad = (uint32_t)&((pwm_t *)PWM_PERIPH_PHYS)->fif1;\n ^\nlib/ws2811.c: In function \xe2\x80\x98setup_pcm\xe2\x80\x99:\nlib/ws2811.c:460:23: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]\n dma_cb->dest_ad = (uint32_t)&((pcm_t *)PCM_PERIPH_PHYS)->fifo;\n ^\nduring RTL pass: loop2_invariant\nlib/ws2811.c: In function \xe2\x80\x98ws2811_render\xe2\x80\x99:\nlib/ws2811.c:1253:1: internal compiler error: Segmentation fault\n }\n ^\nPlease submit a full bug report,\nwith preprocessed source if appropriate.\nSee http://bugzilla.redhat.com/bugzilla for instructions.\nPreprocessed source stored into /tmp/ccCu7B3N.out file, please attach this to your bugreport.\nmake: *** [Makefile:17: lib-built/ws2811.o] Error 1\n’
/usr/bin/ld: cannot find -lws2811

any hints to solve this issue ?

Thanks a lot

I think it’s a non-starter with the version of GCC on arch64, I think this is the same or a closely related issue- https://github.com/jgarff/rpi_ws281x/issues/289

pip shouldn’t need to compile, but I’m guessing either your Python version or architecture mismatch the available wheel packages (listed here: https://github.com/rpi-ws281x/rpi-ws281x-python/releases). Do you know if armv7l will run on Arch64? What version of Python are you using?

I’m afraid I’ve got basically zero experience with Arch and am not the sharpest C programmer, your best bet is to weigh in on the issue linked above and hope someone with the right expertise fixes the syntax for these newer versions of GCC.

TLDR: Even if you manage to get it to compile, it wont work. AArch64 simply isn’t supported and requires some hero to come along and make the required fixes, and for those fixes to be approved and merged into rpi_ws281x.

Okay looks like AArch64 is on Python 3.6.5 and Raspbian only has 2.7, 3.4 and 3.5. That means there’s no .whl distribution you can use.

However the following patch should get it building on AArch64:

diff --git a/library/Makefile b/library/Makefile
index b8da8f5..df3df72 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -14,7 +14,7 @@ $(BUILD)/version.h:
        cp version.h $(BUILD)/version.h

 $(OBJECTS): $(BUILD)/%.o : $(SRC)/%.c
-       gcc $< -o $@ -c -g -O2 -Wall -Werror -fPIC
+       gcc $< -o $@ -c -g -O2 -Wall -Werror -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -fPIC

 $(BUILD)/$(LIB): $(OBJECTS)
        ar rc $@ $^

The crucial additions being just -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast to the build command in the Makefile.

You’ll need the source from the Python port:

git clone https://github.com/rpi-ws281x/rpi-ws281x-python
cd rpi-ws281x-python
git submodule update init
cd library
( apply patch from above )
python setup.py install
pip install unicornhat

But this wont get us far, because:

[root@alarm examples]# python hat/matrix.py
Traceback (most recent call last):
  File "hat/matrix.py", line 6, in <module>
    import unicornhat as unicorn
  File "/usr/lib/python3.6/site-packages/unicornhat.py", line 35, in <module>
    ws2812.begin()
  File "/usr/lib/python3.6/site-packages/rpi_ws281x-3.1.0-py3.6-linux-aarch64.egg/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)

I got past this only to hit another roadblock- I’ve posted my full journey here: https://github.com/jgarff/rpi_ws281x/issues/289.

I’d suggest:

  • Use Raspbian

or

  • Use a Unicorn HAT HD

There are issues with AArch64 beyond my understanding or control which means rpi_ws281x support is unlikely, and definitely not going to happen soon if it happens at all.