Greg Mefford (@ferggo)
Cincinnati Elixir Meetup
2016-02-02
$40
$60
$10
<3
See also Garth's upcoming Nerves talk at ElixirDaze in March
Erlinit
fwup
Buildroot
Cell
Erlinit
fwup
Buildroot
Elixir
Native Code
Mix
Minimal Linux
Erlang Release
Make
Linux Source
Nerves Configuration
Cross-Compiled Binaries
Firmware Image
Requires
Linux
Erlinit
Bake (fwup)
Elixir
Native Code
Minimal Linux
Erlang Release
Bake
Cross-Compiled Binaries
Firmware Image
System
Toolchain
You!
# Just run this script. It'll be fiiiiiiiine... ;)
ruby -e "$(curl -fsSL https://bakeware.herokuapp.com/bake/install)"
# libconfuse 2.8 is required but not available in apt
curl -L https://github.com/martinh/libconfuse/releases/download/v2.8/confuse-2.8.tar.gz | tar -xz -C /tmp
pushd /tmp/confuse-2.8
./configure && make && sudo make install
popd
rm -rf /tmp/confuse-2.8
# Install libarchive and libsodium (deps for fwup)
sudo apt-get install libarchive-dev libsodium-dev
# Install fwup
git clone https://github.com/fhunleth/fwup.git
cd fwup
./autogen.sh
./configure && make && sudo make install
# Install bake
ruby -e "$(curl -fsSL https://bakeware.herokuapp.com/bake/install)"
mix new gibson
defmodule Gibson.Mixfile do
use Mix.Project
def project do
[...]
end
def application do
[
applications: [:nerves, :nerves_io_neopixel],
mod: {Gibson, []}
]
end
defp deps do
[
{:nerves_io_neopixel, "~> 0.2.0"},
{:nerves, github: "nerves-project/nerves"}
]
end
end
use Bake.Config
platform :nerves
default_target :rpi
target :rpi,
recipe: {"nerves/rpi", "~> 0.1"}
bake system get
bake toolchain get
bake firmware
$ sudo fwup -a -i _images/gibson-rpi.fw -t complete
Use 1.89 GiB memory card found at /dev/sdb? [y/N] y
100%
## Name of the node
-sname gibson
## Cookie for distributed erlang
-setcookie god
## Start the Elixir shell
-noshell
-user Elixir.IEx.CLI
-extra --no-halt
nerves_demo/rel/vm.args
$ iex --sname joey --cookie god
iex> pid = Node.spawn_link :"gibson@Nerves", fn ->
...> receive do
...> {:install, client} -> CookieMonster.install(client, self)
...> end
...> end
#PID<9014.59.0>
iex> send pid, {:install, self}
{:ok, #PID<0.73.0>}
iex> flush
{:installed, #PID<9014.59.0>}
:ok