Skip to content

Instantly share code, notes, and snippets.

@riusricardo
Last active September 30, 2019 08:41
Show Gist options
  • Save riusricardo/4256cf1fe532c55f9ad212b861dd83d0 to your computer and use it in GitHub Desktop.
Save riusricardo/4256cf1fe532c55f9ad212b861dd83d0 to your computer and use it in GitHub Desktop.
Steps to compile Substrate on a RPi device.
  1. Compile the code in your Desktop (better if it's Linux or Mac). A full compilation cargo build --release. We are only going to use this to get the WASM blobs.
  2. On the RPi you should install the required dependencies:
sudo apt install -y cmake pkg-config libssl-dev git gcc build-essential git curl clang libclang-dev protobuf-compiler
curl https://sh.rustup.rs -sSf | sh
  1. We now need to use a environment vaiable on the RPi to indicate that we don't want to build the WASM code. export SKIP_WASM_BUILD='true'
  2. Start building on the RPi to generate the target directory structure.
git clone https://github.com/paritytech/substrate
cd substrate
./scripts/init.sh
cargo build --release -vv -j=2
  1. On your desktop computer you should find a directory: target/release/wbuild. We need to copy this folder that contains the WASM blobs into the RPi. Copy (scp is good for this case) it to the equivalent target folder in the RPi where your code is being compiled. So you should have a wbuild folder on the RPi. Just remember that every time you do a cargo clean, this folder will be erased and you will need to copy it again.

  2. We need to copy another file from the Desktop pc into the RPi. It is a file that will be created on the build folder inside the target directory. target/release/build In this directory you need to find a folder that is called node-runtime-###... in case of substrate. In case of a custome node it could change to your projects name but it is important to find the directory that has an out folder inside. Example: target/release/build/node-runtime-a0ff0c68b336f06f/out On this path you will find a file called wasm_binary.rs which includes the full paths to our WASM blobs. Copy this file to the equivalent location in your RPi and fix the paths inside to point to the wsbuild folder that we copied from the desktop pc to the RPi. E.g. - Change to your RPi path

pub const WASM_BINARY: &[u8] = include_bytes!("/home/pi/substrate/target/release/wbuild/node-runtime/node_runtime.compact.wasm");
pub const WASM_BINARY_BLOATY: &[u8] = include_bytes!("/home/pi/substrate/target/release/wbuild/target/wasm32-unknown-unknown/release/node_runtime.wasm");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment