HowTo (Mac) - Build

Note: This page assumes that you have successfully completed the Install step.

Image Build

The notes below are based on the hello_nerves example from the Nerves Project's Getting Started page. In this variation, we'll do the build on spot (a MacBook Air), using a Raspberry Pi 2B as the target. Our goal, in this step, is to build a system image for the target, including copies of Linux, Erlang, Elixir, Nerves, and the application code.

We start by asking Mix to create a new Nerves project:

$ mix hello_nerves_spot --target rpi2
* creating hello_nerves_spot/config/config.exs

After entering the directory, we ask Mix to ensure that we have local copies of our dependencies. Note that these will include some that are specific to the target.

$ cd hello_nerves_spot

$ mix local.hex
* creating /Users/rdm/.mix/archives/hex-0.12.1

$ mix deps.get

Now, we bring in a copy of Rebar3, "an Erlang tool that makes it easy to create, develop, and release Erlang libraries, applications, and systems in a repeatable manner".

$ mix local.rebar

Finally (whew!), we can try to compile the project. When doing this, I encountered several warnings. The one about cloudi_service_db_riak isn't a Nerves issue, so I filed it with the appropriate folks. The other bugs (I am told) will disappear Real Soon Now:

$ mix compile
==> hello_nerves_spot
Compiling 1 file (.ex)
Generated hello_nerves_spot app

As a sanity check, let's examine the results of the build:

$ NERVES_DEBUG=1 mix compile
Nerves Env loaded
Nerves Environment
target:     rpi2
toolchain:  _build/rpi2/dev/nerves/toolchain
system:     _build/rpi2/dev/nerves/system
app:        /Users/rdm/Dropbox/elixir/hello_nerves_spot

Looks good; let's create a system image for the target's firmware:

$ mix firmware
Building release with MIX_ENV=dev.
Building _images/rpi2/hello_nerves_spot.fw...

We now have an system image; our next step is to Upload it.

This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r8 - 19 Jul 2016, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email