6
5

More than 5 years have passed since last update.

[Elixir] Nervesを試してみる

Last updated at Posted at 2016-11-23

「Elixirで組み込み向けの強靭なソフトウェアを作ろう」を謳うNervesを試してみた。

実機はRaspberry Pi2、デスクトップ環境はDebianを使用し、手順はGetting Startedにあるとおり進めてみた。

インストール

インストール周りはここに記載されているとおり。

必要パッケージのインストール

$ sudo aptitude install ssh-askpass
$ sudo aptitude install squashfs-tools

あとfwupも必要だがdebianにはパッケージが用意されていないので、ここからdebianパッケージを拾ってきてインストールする。

$ sudo dpkg -i fwup_0.11.0_amd64.deb

Nervesのインストール

以下のコマンドを実行してNervesをインストールする。

$ mix archive.install https://github.com/nerves-project/archives/raw/master/nerves_bootstrap.ez

プロジェクト作成から起動まで

mix nerves.newでプロジェクトを作成する。Raspberry Pi2なのでターゲットにはrpi2を指定

$ mix nerves.new hello_nerves --target rpi2
$ cd hello_nerves
$ mix deps.get
$ mix compile

あとはマイクロSDカードに焼くだけ

$ mix firmware
$ mix firmware.burn
Use 7.4 GiB memory card found at /dev/sdf? [Yn] Y
100%
Elapsed time: 9.452s

HDMIケーブルをディスプレイに繋いで電源を入れれば、iexが立ち上がってくる

なお、_images/rpi2/hello_nerves.fwにあるイメージは20MB弱とかなり小さい。

シリアルポート接続

HDMI接続だとなにかと不便なのでシリアルポート接続にしてみる。手順はここ

hello_nervesの直下にrootfs-additions/etcディレクトリを掘り、deps/rpi2/nerves_system_rpi2/rootfs-additions/etc/erlinit.configをコピーしコンソール設定部分を以下のように変更する

rootfs-additions/etc/erlinit.config
#-c tty1
-c ttyAMA0

(2016/11/26: ttyS0からttyAMA0に修正)
そして上記ファイルを使用するよう設定ファイルに追記する

config/config.exs
config :nerves, :firmware,
  rootfs_additions: "rootfs-additions"

ビルドしてSDカードに焼く

$ mix compile
$ mix firmware
$ mix firmware.burn

TTL to USBケーブルでホストに接続し、以下のコマンドで接続できる

$ screen /dev/ttyUSB0 115200
6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5