Simplifying IoT Development Using Rebuild

Yaniv Nissenboim
jumperiot
Published in
4 min readJul 27, 2017

This is a post by Yan Vugenfirer (CEO at Daynix and Rbld.io). After taking Rebuild for a test spin on nRF52 we must say, it’s a must tool in your IoT development tool kit.

Introduction to Rebuild

Building modern software in a predictable and repeatable way isn’t easy. The overwhelming number of software dependencies and the need to isolate conflicting components presents numerous challenges to the task of managing build environments: the need to use specific distribution, different compilers, different compilers’ versions, conflicting libraries, etc.

Therefore we decided to create Rebuild. It is perfect for establishing build infrastructures for source code. Rebuild allows the user to create and share fast, isolated and immutable build environments. This way consistent environment will be used by the different team members and for different use cases (development, build server, continuous integration, etc). The distinctive feature of Rebuild environments is a seamless user experience. When you work with Rebuild, you feel like you’re running “make” on a local machine.

To illustrate the benefits of Rebuild I am going to show how Rebuild can simplify the usage nRF52 SDK.

Client Installation

The Rebuild client requires Docker engine 1.9.1 or newer and Ruby 2.0.0 or newer. If you don’t have those dependencies installed, use our WiKi to guide your through installation steps.

Rebuild is available at rubygems.org:

gem install rbld

Testing installation

Run: rbld help

You should see the output of help command.

Quick start

Search for existing environments

Let’s see how we can simplify the usage of embedded toolchains with Rebuild. By default Rebuild is configured to work with DockerHub as an environment repository and we already have ready-made environments there.

The workflow for Rebuild is as follows:

  1. Search for the needed environment in Environment Repository.
  2. Deploy the environment locally (needs to be done only once for the specific environment version).
  3. Run Rebuild.

If needed you can modify, commit and publish modified environments to Registry while simultaneously keeping track of different environment versions.

First, we search for environments by executing this command:

$ rbld search

You should see the following output:

Searching in rbld/environments…

bb-x15:16-05
nrf5:13
rpi-raspbian:v001

Next, we deploy the environment to our local machine. To do this, enter the following command:

$ rebuild$ rbld deploy nrf5:13

You should see the following output:

Deploying from rbld/environments…[==============================================>] 278.5 MB/278.5 MB
Successfully deployed nrf5:13

We just deployed the ready made environment with nRF SDK. We already have directory with samples. And now it is time to use Rebuild to compile your code. Enter the directory with your code. Point the Makefile to SDK location (in this environment it is pointed by NRF5_SDK_ROOT environment variable):

SDK_ROOT := $(NRF5_SDK_ROOT)

Run following command to compile your code:

$ rbld run nrf5:13 — — make

In the screenshot you see compilation of simple_timer sample from examples/peripheral/simple_timer/pca10040/blank/armgcc.

Of course, you can also use any other command that you use to build your code.

You can also use your environment in interactive mode. Just run the following:

$ rbld run nrf5:13

Then, simply execute the necessary commands from within the environment. Rebuild will take care of the file permission and ownership for the build result that will be located on your local file system.

Environment creation

In the sample above I used ready-made nRF52 environment, now let’s check how it was created.

First download the SDK:

wget https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v13.x.x/nRF5_SDK_13.1.0_7ca7556.zip

Then create initial Rebuild environment using base image:

rbld create — base ubuntu:16.04 nrf5

Let’s modify the environment by running:

rbld modify nrf5:initial

We are now modifying the environment in interactive mode.

Run:

sudo apt-get update
sudo apt-get install -y make unzip gcc-arm-none-eabi vim
sudo unzip nRF5_SDK_13.1.0_7ca7556.zip -d /nRF5_SDK_13.1.0_7ca7556

We need to point the sdk to the right location of the gcc-arm-none-eabi:

sudo vim /nRF5_SDK_13.1.0_7ca7556/components/toolchain/gcc/Makefile.posix

It should look like this:

GNU_INSTALL_ROOT := /usr
GNU_VERSION := 4.9.3
GNU_PREFIX := arm-none-eabi

And we want to keep the environment variable with the path to the sdk for using it in the makefile:

echo -e ‘export NRF5_SDK_ROOT=/nRF5_SDK_13.1.0_7ca7556’ | sudo tee -a /rebuild/rebuild.rc

We are done with the environment setup, exit the interactive shell by pressing CTRL-D.

Let’s commit the changes and delete the initial environment:

rbld commit nrf5:initial — tag 13
rbld rm nrf5:initial

Run:

rbld list

You should see your environment and it is ready to use:

nrf5:13

Explore Rebuild

To learn more about Rebuild, run rbld help or read our GitHub documentation.

Rebuild commands can be grouped by functionality

Creation and modification of the environments:

  • rbld create — Create a new environment using the base environment or from an archive with a file system
  • rbld modify — Modify the environment
  • rbld commit — Commit modifications to the environment
  • rbld status — Check the status of existing environments
  • rbld checkout — Revert changes made to the environment

Managing local environments:

  • rbld list — List local environments
  • rbld rm — Delete local environment
  • rbld save — Save local environment to file
  • rbld load — Load environment from file

Working with environment registries:

  • rbld search — Search registry for environments
  • rbld deploy — Deploy environment from registry
  • rbld publish — Publish local environment to registry

Running an environment either with a set of commands or in interactive mode:

  • rbld run — <command to execute> — Run command(s) in the environment
  • rbld run — Use environment in interactive mode

Additional information

Share your thoughts

Feel free to share your thoughts comments, and contact the Rebuild guys at — rbld@rbld.com.

--

--