SAFE Network App for ARM?

I was going to install the SAFE Network App, but I’m starting off with a roadblock because the machines I’m able to experiment with are all Raspberry Pis. They can run Ubuntu with desktop, but any binaries coming from outside the distribution need to be compiled for ARM. My experience with compiling anything for ARM has been … let’s just say maybe I’m an idiot. Are ARM builds coming?

7 Likes

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

12 Likes

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. :slightly_smiling_face:

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.

2 Likes

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.

3 Likes

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

5 Likes

Please do, I’m trying to build for ARM atm and have some problems. Will post if I get stuck but if you can post your stuff that might help.

4 Likes

this was here :

4 Likes

I tried to build this on Raspberry Pi4 with 4GB running kali.
I really am beginning to prefer kali over raspiablan.

Anyway… it all compiles well, but running gives this error.

bash: /home/kali/.safe/cli/safe: cannot execute binary file: Exec format error

So it is the released binaries that are the issue, thanks for the info.

Hope the community can put something together. :slight_smile:

For info, on first build I got the following error,

= note: collect2: fatal error: ld terminated with signal 9 [Killed]

Googling around I got the impression it means the poor pi was overloaded,
so I ran

cargo build

again…

kali@kali:~/safe-api$ cargo build
Compiling safe-cli v0.14.0 (/home/kali/safe-api/safe-cli)
Finished dev [unoptimized + debuginfo] target(s) in 5m 34s

no probs.

4 Likes

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.

7 Likes

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…

2 Likes

IF you are on a normal linux machine (or win/mac)

Should work. The binary will be arm and not run in 64 bit linux, So you copy that to your arm and it will / should work.

Seems @tfa Has this binary from the above comment, so folks should copy that if they don’t wish to compile

4 Likes

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.

I grabbed some commands from my history.

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

Do your other safe cli stuff…

6 Likes

Building on Odroid-U3+ with Ubuntu 16.04LTS

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
5 Likes

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.

6 Likes

@nevel note your safe install vault should be safe vault install

4 Likes

I am getting this error too, but running “cargo build” again doesnt help. Any suggestions?
HW is OrangePi PC with Armbian Bionic Linux 5.4.35-sunxi

Looks like a memory issue (googling). Are there any other processes running you might kill?
And how much mem do you have?

1 Like

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 :slight_smile:

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.

2 Likes

Do you know if Ubuntu 19 and ODROID-XU4 are adequate for running a SAFE Vault? And I guess I would have to build a vault for ARM right?