It’s very easy with rust to compile for arm. There is even arm musl so make it more cross platform.
Install rust curl https://sh.rustup.rs -sSf | sh
install arm toolchain rustup target add arm-unknown-linux-musleabi
Build your lib (i.e. safe-api) by cloning the repo and cd into it and type cargo build --target=arm-unknown-linux-musleabi
Any chance SAFE team can provide a musl build for download. I only visit Linux command line a few times a year, enough for me to forget alot between each time.
It would be nice to try and get the Raspberry pi 3b+ going during the weekend.
Just saw that the test Network will continue at a later time, so that gives some time to prepare.
I suggest trying first to get help from the community than divert Maidsafe. I’ll probably have a go myself so might be able to help, but I’m sure others could also do so.
I have been building the cli and authenticator for the raspberry pi4 at some point, maybe 3 or 4 monthes ago. That had worked nicely. I am trying to dig the posts where I mentioned it back then
I did that yesterday but the network crashed before I could provide it to the community. I will send the link to my deliveries when the network restarts because I may need to rebuild it if Maidsafe changes the code in the meantime.
I generated 4 targets:
x86_64-unknown-linux-musl
x86_64-pc-windows-gnu
x86_64-apple-darwin
armv7-unknown-linux-musleabihf
The one you want is the last one but I don’t have the hardware to test it. But apparently many people here seem ready to test it.
Note that in my fork I removed auto update stuff, or more exactly put it behind a cargo feature that is not activated by default. I did this for 2 reasons:
this is needed to link with musl library (otherwise we get an error about openssl-sys)
I don’t like auto update
As an added bonus this reduces greatly the size of the executable (from 22MB to 19MB).
No, it isn’t because of the openssl dependency. And the problem is there for both safe-vault and safe-api.
I’m stuck missing the cross compiler on Ubuntu: arm-linux-musleabi-gcc is not found when I cargo build.
I found https://musl.cc/ which probably has something I could build from source, or maybe already built but it’s an 88M tarball and I can feel myself falling down a rabbit hole.
So I’m going to pause, see about getting an Odroid-U3+ running and may try building native. It takes a while but did work before, although there was a final killer in the Odroid Linux kernel not being modern enough so I’m probably on a wild goose chase anyway!
I do have a Rasp Pi to fall back on. Gotta find my old SD cards now :grimmacing: They must be here…
I’m using Ubuntu 19 and after cargo build fails the last line says:
error occurred: Failed to find tool. Is arm-linux-musleabi-gcc installed?
So I went looking how to install that. Mean time I can get the Odroid running it is on Ubuntu 16.04 so I may to upgrade that first for a more up to date kernel? Anyway, when I get my Odroid going again I’ll try building on there.
This is how I installed it. Easiest way is to build it on the device itself IMO.
//setup ssh client session to your pi(whatever) device by using putty or other ssh client
(ssh you@192.168.xxx.xxx)
//update repo
sudo apt update
//git for downloading the sources
sudo apt install git
cd ~
mkdir git
cd git
git clone https://github.com/maidsafe/safe-api.git
git clone https://github.com/maidsafe/safe-vault.git
//install rust
sudo apt install curl
curl https://sh.rustup.rs -sSf | sh
//check
rustc --version
//building preparation
sudo apt install libssl-dev
sudo apt install build-essential
sudo apt install pkg-config
//building safe-api
cd ~/git/safe-api
cargo build --release
cd ~/git/safe-api/target/release
safe vault install (will install a vault binary that won't work for ARM, but maybe this command is needed for some settings?? I don't know)
//building safe-vault and replace the current installed safe-vault
cd ~/git/safe-vault
cargo build --release
cp ~/git/safe-vault/target/release/safe_vault ~/.safe/vault/
//create safe alias to make life easier (maybe other way to do this?)
//use some editor (sudo apt install nano)
nano ~/.bashrc
//add this line somewhere
alias safe='~/git/safe-api/target/release/safe'
source ~/.bashrc
Note: build the release versions as debug will be way too slow, and may not build at all.
Status:
safe-api:cargo build --release - BUILT
safe-vault:cargo build --release - BUILT
safe network switch shared-section DONE
safe authd start DONE
safe vault join DONE
NOTE: I don’t know if Ubuntu 16 or Odroid-U3+ are adequate for a SAFE Vault yet. That’s what I’m testing.
Build steps
UPDATE: the following scripts may work but I have updated and published a set of improved scripts which can be used on Ubuntu, and as a template for building on other distros here: SAFE Network Farming.
# Housekeeping:
sudo apt-get update
# Get Rust and git:
sudo apt-get install curl git
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env # If not rebooted since installing Rustc
# Build SAFE CLI on Odroid-U3+, Ubuntu 16.04 LTS
mkdir -p ~/src/maidsafe
cd ~/src/maidsafe
git clone https://github.com/maidsafe/safe-api
cd safe-api
source $HOME/.cargo/env # If not rebooted since installing Rustc
time cargo update
time cargo build --release # Took 74 mins
echo alias safe='~/src/maidsafe/safe-api/target/release/safe' >> ~/.bashrc
source ~/.bashrc
# Copy safe-authd into place
cp ~/src/maidsafe/safe-api/target/release/safe-authd ~/.safe/authd
# Setup Vault Config:
# Is 'safe vault install' needed?
safe vault install # Downloads an unsuitable vault, but will setup the config which we need
# Select the network (e.g. shared-section)
safe networks check
# If the above complains, add a network config and select it:
safe networks add shared-section https://safe-vault-config.s3.eu-west-2.amazonaws.com/shared-section/vault_connection_info.config
safe networks switch shared-section
safe networks check
# Should be ok now!
# Build SAFE Vault: on Odroid-U3+, Ubuntu 16.04 LTS# Build SAFE Vault on Odroid-U3+, Ubuntu 16.04 LTS
mkdir -p ~/src/maidsafe
cd ~/src/maidsafe
sudo apt-get install libssl-dev # Ubuntu
# Didn't need (already installed/latest versions): sudo apt-get install build-essential pkg-config
git clone https://github.com/maidsafe/safe-vault
cd safe-vault
source $HOME/.cargo/env # If not rebooted since installing Rustc
time cargo update # <10 mins
time cargo build # 56mins
# Copy safe_vault into place
cp ~/src/maidsafe/safe-vault/target/release/safe-authd ~/.safe/vault/
# Test Vault: Use SAFE CLI to test Vault on (12/06/20) Baby Fleming shared single section (Odroid-U3+, Ubuntu 16.04 LTS)
# If this gives errors, see 'Setup Vault Config' above.
safe networks check
safe networks switch shared-section
safe vault join
# TODO Test Client: Use SAFE CLI to test as client on (12/06/20) Baby Fleming shared single section (Odroid-U3+, Ubuntu 16.04 LTS)
safe networks check
safe networks switch shared-section
safe auth start
safe auth create-acc --test-coins # Trying with sharedfleminghomevaults
Ah good point, Debug mode will be incredibly slow. You will need to build --release. It’s mostly the crypto parts that run 10-100 times slower in debug.
Thank you for the push in right direction. It was indeed a memory issue, the board has only 1 GB RAM and there was not enough space to swap. Now it compiles succesfully, thats enough for today
I anybody is trying the same, before the memory problem I had problem with OpenSSL: error: failed to run custom build command for openssl-sys v0.9.41``
This helped:
Then I hit the memory problem: = note: collect2: fatal error: ld terminated with signal 9 [Killed]
This helped:
nano /usr/bin/init-zram-swapping
line
mem=(((totalmem / 2 / {NRDEVICES}) * 1024 ))
chaged 1024 to 4096, than reboot and start the compilation.