First Dose of Embedded Elixir with Nerves
Greg Mefford (@ferggo)
Cincinnati Elixir Meetup
2016-02-02
Thanks to Gaslight
Why Embedded?
$40
$60
$10
Internet of Things
BeagleBone Black
- Open Hardware
- Lots of Great Peripherals (e.g. CAN)
- Industrial Temperature Option
Elixir Embedded
<3
- Fault-Tolerance
- Fast Garbage Collection
- Concurrency
- Constrained Hardware
- Binary Protocols
- ...
Nerves
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
It's a small team, but community interest is growing. Get involved today!
You!
- Better getting-started documentation
- Better integration between Nerves and Bakeware, and between Nerves and Mix
- WiFi support
- Get Cell working with Nerves
- Update relsync to work with Elixir and Nerves (live-reload)
- Support for BakeWare on Windows
Coming Up:
Quick Demo/Walkthrough
Hack the Gibson!!!1
# Just run this script. It'll be fiiiiiiiine... ;)
ruby -e "$(curl -fsSL https://bakeware.herokuapp.com/bake/install)"
Install Bake
Mac OSX:
(www.bakeware.io)
# 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)"
Ubuntu 14.04:
mix new gibson
Setup a Project
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"}
Create a Bakefile
Bake It!
bake system get
bake toolchain get
bake firmware
Burn the SD Card
$ sudo fwup -a -i _images/gibson-rpi.fw -t complete
Use 1.89 GiB memory card found at /dev/sdb? [y/N] y
100%
Erlang Distribution
Configure the VM
## 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
Connect to the Node
$ 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
First Dose of Embedded Elixir with Nerves
By Greg Mefford
First Dose of Embedded Elixir with Nerves
- 2,406