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

Cross Compiling macchina.io for Raspberry Pi Zero W #97

Open
vardanin opened this issue Jan 30, 2020 · 5 comments
Open

Cross Compiling macchina.io for Raspberry Pi Zero W #97

vardanin opened this issue Jan 30, 2020 · 5 comments

Comments

@vardanin
Copy link

Raspberry Pi Zero W has a modest 512 MB of RAM, I guess cross compiling is a better solution than direct compiling on the platform, because of that I want to cross compile macchina.io on my Ubuntu 16.04 host and run it on Raspberry Pi Zero W. I follow steps for cross compiling in this article:

https://github.com/macchina-io/macchina.io/wiki/Cross-Compiling-for-Raspberry-Pi-(Raspbian)-and-BeagleBone-Black-(Debian-Stretch)

#1 Can not install libssl-dev:armhf
Command:
$ sudo apt-get install libssl-dev:armhf

Can not locate the package:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libssl-dev:armhf

#2 Editing configuration file
Which build configuration file is the best choise: ARM-Linux, X-Debian-Stretch-RPi or some other? What we need to redefine in this configuration file for armv6l Raspberry Pi Zero W architecture?

@obiltschnig
Copy link
Member

You should do the cross compiling on host using the same Debian release that you are also running on the Raspberry Pi. Everything else is a recipe for disaster. For the current Raspbian Buster, that would be Debian Buster. The X-Debian-Stretch-RPi build config should work for Buster as well.

@vardanin
Copy link
Author

vardanin commented Mar 3, 2020

I installed Debian Buster 10.3 (x86-64) on my VMware virtual macchine.

Also I downloaded Raspberry Pi Zero GCC cross-compiler:
https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Raspberry%20Pi%20GCC%20Cross-Compiler%20Toolchains/Buster/GCC%209.2.0/Raspberry%20Pi%201%2C%20Zero/

Following commands are executed:

$ cd ~

$ sudo apt-get install g++ make libssl-dev python

$ git clone https://github.com/macchina-io/macchina.io.git

$ cd macchina.io

$ git checkout master

$ make -s -j2 hosttools

Exporting path to bin folder of cross-compiler
$ export PATH=~/cross-pi-gcc-9.2.0-0/bin/:$PATH

$ POCO_CONFIG=X-Debian-Stretch-RPi LINKMODE=SHARED make -s -j2 DEFAULT_TARGET=shared_release

During compiling, get this error messages for openssl:

** Compiling src/Cipher.cpp (release, shared)
In file included from include/Poco/Crypto/Cipher.h:21,
from src/Cipher.cpp:15:
include/Poco/Crypto/Crypto.h:28:10: fatal error: openssl/opensslv.h: No such file or directory
28 | #include <openssl/opensslv.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [/home/marko/macchina.io/platform/build/rules/compile:61: /home/marko/macchina.io/platform/Crypto/obj/Linux/armv7l/release_shared/Cipher.o] Error 1
make[1]: *** [Makefile:160: Crypto-libexec] Error 2
make[1]: *** Waiting for unfinished jobs....
.
.
.
(END of compiling)
(v8::Isolate*, v8::GCType, v8::GCCallbackFlags)’} [-Wcast-function-type]
10326 | reinterpret_castIsolate::GCCallback(callback));
| ^
SOLINK(target) /home/marko/macchina.io/platform/JS/V8/out/Release/obj.target/v8/src/libv8.so
COPY /home/marko/macchina.io/platform/JS/V8/out/Release/lib.target/libv8.so
make: *** [Makefile:76: clean] Error 2

I used original X-Debian-Stretch-RPi configuration file with no change, but time optimization flags on cross-compiler site and X-Debian-Stretch-RPi configuration file are different.

Cross-compiler site:
-march=armv6 -mfloat-abi=hard -mfpu=vfp

X-Debian-Stretch-RPi configuration file:
-march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4

Also Raspberry Pi Zero have armv6l instead of armv7l architecture. I tried to compile helloWorld on host and a.out file work on Zero.

@obiltschnig
Copy link
Member

You need to have the OpenSSL libraries available for your target (cross-compiled with the same toolchain) as well.

@vardanin
Copy link
Author

vardanin commented Mar 6, 2020

I tried to compile macchina direct on Raspberry Pi Zero W. For example, Tinkerforge RED Brick and Zero W have similar hardware capabilities, 1GHz CPU and 512 MB RAM. But Tinkerforge RED Brick and all models of Raspberry Pi have ARM v7 architecture, except Raspberry Pi Zero/Zero W which have ARM v6 architecture.

Compiling on my Raspberry Pi Zero W with latest Rasbian Buser terminated during V8 build with unsupported architecture error:

...

** Building shared library (release) /home/pi/macchina.io/platform/lib/Linux/armv6l/libPocoWebTunnel.so.1
gyp: name 'arm_version' is not defined while evaluating condition 'arm_version==7 or arm_version=="default"' in v8/src/v8.gyp
make[2]: *** [Makefile:96: out/Makefile] Error 1
make[1]: *** [Makefile:281: JS/V8-libexec] Error 2
make: *** [Makefile:76: clean] Error 2

Is it possible to run the macchina on Raspberry Pi Zero/Zero W?

@obiltschnig
Copy link
Member

obiltschnig commented Mar 6, 2020

It may be that the old ARMv6 architecture is no longer supported by the V8 version we're using. Haven't actually checked. You could try adding the following check to platform/JS/V8/Makefile:

ifeq ($(findstring armv6,$(OSARCH)),armv6)
GYPFLAGS += -Darm_version=6
endif

(right after or before the corresponding check for armv7)

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

2 participants