Closed t3chguy closed 8 years ago
Could you supply some pertinent details on your OS?
cat /etc/*-release
ld -v
gcc -v
uname -a
I will do shortly, currently trying another image to see whether its directly related to that. It was the Ubuntu Mate image available on the Raspberry Pi Downloads Page, I will get back here after testing Raspbian, and go back to Mate to get you the details you need.
Thanks
We currently don't test on, or support, anything but Raspbian and I've got a suspicion that Unicorn HAT will be particularly tricky to get working with Ubuntu Mate due to the somewhat arcane way in which it works.
I'll never say never, though. I'm downloading Ubuntu Mate right now to see if I can get it working myself. I'm currently supposed to be busy with something else, though, so I might be a while getting back to you!
Thanks for testing it yourself regardless! Raspbian is almost installed on a secondary card so I can test if it works for me there.
As expected, works blindingly on Raspbian
Trying to install rpi-ws281x on its own also fails:
t3chguy@Admin-RPi ~> sudo pip install rpi-ws281x
Downloading/unpacking rpi-ws281x
Downloading rpi_ws281x-1.1.3.tar.gz (102kB): 102kB downloaded
Running setup.py (path:/tmp/pip-build-Ao72KX/rpi-ws281x/setup.py) egg_info for package rpi-ws281x
Installing collected packages: rpi-ws281x
Running setup.py install for rpi-ws281x
Compiling ws281x library...
building '_rpi_ws281x' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Ilib/ -I/usr/include/python2.7 -c rpi_ws281x_wrap.c -o build/temp.linux-armv7l-2.7/rpi_ws281x_wrap.o
rpi_ws281x_wrap.c: In function ‘init_rpi_ws281x’:
rpi_ws281x_wrap.c:4638:21: warning: variable ‘md’ set but not used [-Wunused-but-set-variable]
PyObject *m, *d, *md;
^
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/rpi_ws281x_wrap.o -Llib/ -lws2811 -o build/lib.linux-armv7l-2.7/_rpi_ws281x.so
/usr/bin/ld: lib//libws2811.a(ws2811.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
lib//libws2811.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-Ao72KX/rpi-ws281x/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-OHyTLA-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
Compiling ws281x library...
creating build
creating build/lib.linux-armv7l-2.7
copying neopixel.py -> build/lib.linux-armv7l-2.7
running build_ext
building '_rpi_ws281x' extension
creating build/temp.linux-armv7l-2.7
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Ilib/ -I/usr/include/python2.7 -c rpi_ws281x_wrap.c -o build/temp.linux-armv7l-2.7/rpi_ws281x_wrap.o
rpi_ws281x_wrap.c: In function ‘init_rpi_ws281x’:
rpi_ws281x_wrap.c:4638:21: warning: variable ‘md’ set but not used [-Wunused-but-set-variable]
PyObject *m, *d, *md;
^
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/rpi_ws281x_wrap.o -Llib/ -lws2811 -o build/lib.linux-armv7l-2.7/_rpi_ws281x.so
/usr/bin/ld: lib//libws2811.a(ws2811.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
lib//libws2811.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-Ao72KX/rpi-ws281x/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-OHyTLA-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-Ao72KX/rpi-ws281x
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 248, in main
return command.main(cmd_args)
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 35: ordinal not in range(128)
And my system info is:
t3chguy@Admin-RPi ~> cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=15.04
DISTRIB_CODENAME=vivid
DISTRIB_DESCRIPTION="Ubuntu 15.04"
NAME="Ubuntu"
VERSION="15.04 (Vivid Vervet)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 15.04"
VERSION_ID="15.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
t3chguy@Admin-RPi ~> ld -v
GNU ld (GNU Binutils for Ubuntu) 2.25
t3chguy@Admin-RPi ~> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.9/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.9.2-10ubuntu13' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.9.2 (Ubuntu/Linaro 4.9.2-10ubuntu13)
t3chguy@Admin-RPi ~> uname -a
Linux Admin-RPi 3.18.0-25-rpi2 #26-Ubuntu SMP PREEMPT Sun Jul 5 06:46:34 UTC 2015 armv7l armv7l armv7l GNU/Linux
Managed to get it to compile by just adding -fPIC
into the library Makefile. I can't push this as a fix until I've tested it on Raspbian, but I've got a working Unicorn HAT on Ubuntu Mate- much to my surprise!
You should replace your python/rpi-ws281x/lib/Makefile
with:
all: lib test
lib:
gcc -o ws2811.o -c -g -O2 -Wall -Werror ws2811.c -fPIC
gcc -o pwm.o -c -g -O2 -Wall -Werror pwm.c -fPIC
gcc -o dma.o -c -g -O2 -Wall -Werror dma.c -fPIC
gcc -o board_info.o -c -g -O2 -Wall -Werror board_info.c -fPIC
gcc -o mailbox.o -c -g -O2 -Wall -Werror mailbox.c -fPIC
ar rc libws2811.a ws2811.o pwm.o dma.o board_info.o mailbox.o
ranlib libws2811.a
test:
gcc -o main.o -c -g -O2 -Wall -Werror main.c
gcc -o test main.o libws2811.a
clean:
-rm ws2811.o pwm.o dma.o board_info.o mailbox.o
-rm libws2811.a
-rm test
@Gadgetoid I tried your rendition of the Makefile, and it looks fully functional in Ubuntu :D
I really appreciate you getting it to work, hopefully it'll also work on Raspbian so this change can be pushed into the repo.
Thanks
Edit, I will clone and modify it just as I have done again, but on Raspbian to run a test to see whether it breaks it there, I'll be using the Raspbian installed via NOOBS
@Gadgetoid I can confirm that on Raspbian even with the -fPIC
arguments it both compiles correctly and functions identically to the PyPi package. Hope this fix gets pushed into the repo as then it'll add compatibility for Ubuntu Mate for other users.
Thanks again for getting this working!
I've now tested this on Raspbian and pushed the -fPIC
fix into the Makefile: https://github.com/pimoroni/unicorn-hat/commit/52010b2eac166c78cd02906302bdc16a48e6403d
See log below:
Exactly the same happens using
pip install unicornhat