Closed elie-g closed 4 years ago
Cross-compiling your project with rpi-ws281x-go is a bit more complex than just setting the environment variables. The rpi-ws281x-go is a wrapper around a C library this library must be compiled using CGO. Additionally, the C code must also be cross-compiled and linked as a library. At the time I published this module, the easiest way was to use a Docker image that provided an ARM emulation for compiling the project.
The README file should explain how to use this module (with Docker) for your project.
Let me know if this is not clear or if you know a simpler way. See also issue #1 for more details about why I use Docker.
Note: Now Docker offers the "buildx" command and this could be another way of cross-compiling code. However, buildx is still experimental, so I am not sure that this is a better solution now.
Thanks for your help! I appreciate it
I tried with docker but it doesnt work. I can't even run the container. I can build the container but I can't run it even if I copy/paste the dockerfile in the readme. I always get the following error:
standard_init_linux.go:211: exec user process caused "exec format error"
I have a Raspberry Pi 4 model B so I first tried with these base images but I got the exact same result:
Here are the commands I use to build & run the container:
# Build the container
docker build -t rpi-builder .
# Run the containr
docker run --rm -it \
rpi-builder /usr/bin/qemu-arm-static \
/bin/bash -il
LSB Version: core-11.0.1ubuntu1-noarch:security-11.0.1ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 19.10
Release: 19.10
Codename: eoan
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 39 bits physical, 48 bits virtual
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 142
Model name: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Stepping: 10
CPU MHz: 2629.568
CPU max MHz: 4000.0000
CPU min MHz: 400.0000
BogoMIPS: 3999.93
Virtualization: VT-x
L1d cache: 128 KiB
L1i cache: 128 KiB
L2 cache: 1 MiB
L3 cache: 8 MiB
NUMA node0 CPU(s): 0-7
Vulnerability Itlb multihit: KVM: Mitigation: Split huge pages
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Full generic retpoline, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling
Vulnerability Tsx async abort: Not affected
I just tried on a VM with Ubuntu 18.04 and it was OK:
$ docker run --rm -it rpi-builder /usr/bin/qemu-arm-static /bin/bash -il
root@ac447b37e037:/go#
I will try with a version 19.10 of Ubuntu (like yours). Can you please copy the output of docker version
? (On my Ubuntu 18.04 VM I am using Docker Engine - Community Version 19.03.5)
Docker version 19.03.2, build 6a30dfca03
I was able to reproduce the behavior with Ubuntu eoan and Docker 19.03.2. I am working on another way to build the binary.
While trying other options, I found this page: https://community.arm.com/developer/tools-software/tools/b/tools-software-ides-blog/posts/getting-started-with-docker-for-arm-on-linux and I was able to run the builder after having typed this command:
sudo docker run --rm --privileged docker/binfmt:820fdd95a9972a5308930a2bdfb8573dd4447ad3
Can you please do this additional step and check if this solves your issue?
It seems to work so far. I haven't tested my app yet but at least I can build my project now. Though, for it to work, I had to edit the dockerfile and move the line RUN apt-get update -y ...
before cross-build-start
or otherwise I get a GPG signature error.
Merci énormément! J'aurais sans doute jamais trouvé la solution par moi-même. :wink:
Merci pour votre réponse.
I am working on another solution for building the binaries (using Docker buildx) and I will update the README accordingly. Is it OK for you if I close this issue?
Why am I getting an
undefined
error when I try to build my project?Command Line:
Error: