みずりゅの自由帳

主に参加したイベントやソフトウェア技術/開発について記録しています

Nerves1.6.1対応のためにfwupをアップグレードする

ElixirのIoTフレームワークであるNervesですが、日本時間の2020年3月20日バージョン1.6.1がリリースされています。 バージョンの1.6.0から1.6.1からの差分として、以下の2点があります。

  1. 「nerves_bootstrap」のバージョン1.8に対応。*1
  2. 「fwup」の要求バージョンが1.5以上。

自分はNerves v.1.5.0からNervesを利用していたので、インストールしていたfwupのバージョンが1.3.1でした。 Nervesの1.6.1を利用したかったので、fwupのバージョンをアップデートすることにします。

自分の環境は「macOS Mojave*2」です。

そのため、今回のバージョンアップについては、macOSでの操作となります。

fwup1.5未対応時のエラー出力

fwupのバージョンが1.5未満の状態で、Nerves1.6.1でmix firmwareを実行すると以下のようにエラーメッセージが出てきました。

$mix firmware
==> nerves_system_br
Generated nerves_system_br app
==> nerves_toolchain_ctng

〜(中略)〜

Generated nerves_pack app
==> hello_nerves
** (Mix) fwup ~> 1.5 is required for Nerves.

You are running 1.3.1
.
Please see https://hexdocs.pm/nerves/installation.html#fwup
for installation instructions
fwupのアップグレード

要求にしたがい、fwupのバージョンを上げます。

自分はHomebrewを利用しているので、brewコマンドでアップグレードします。

$ brew update
$ brew upgrade fwup

brew upgrade fwupを実行すると、以下のようなメッセージが出ました。しばらくすると特に問題なくアップグレードは終了しました。

メッセージを見ると、fwupのバージョンは1.6.0になっているようです。

==> Upgrading 1 outdated package:
fwup 1.3.1 -> 1.6.0
==> Upgrading fwup 1.3.1 -> 1.6.0
==> Installing dependencies for fwup: libb2, lz4, xz, zstd and libarchive
==> Installing fwup dependency: libb2
==> Downloading https://homebrew.bintray.com/bottles/libb2-0.98.1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libb2-0.98.1.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/libb2/0.98.1: 8 files, 238.5KB
==> Installing fwup dependency: lz4
==> Downloading https://homebrew.bintray.com/bottles/lz4-1.9.2.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/67/67ca428e60e2c2f6e524dd3de42629c1a616d28b2c743b66bf4cbdcc3b28ea46?__gda__=e
######################################################################## 100.0%
==> Pouring lz4-1.9.2.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/lz4/1.9.2: 22 files, 581KB
==> Installing fwup dependency: xz
==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.5.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/44/44483961b5d2b535b0ece1936c9d40b4bc7d9c7281646cca0fb476291ab9d4dc?__gda__=e
######################################################################## 100.0%
==> Pouring xz-5.2.5.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/xz/5.2.5: 92 files, 1.1MB
==> Installing fwup dependency: zstd
==> Downloading https://homebrew.bintray.com/bottles/zstd-1.4.4.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/85/8533ca2bb803f88c0bddb7131de1fff6fe8f0c6278982ef7cb0332631010291c?__gda__=e
######################################################################## 100.0%
==> Pouring zstd-1.4.4.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/zstd/1.4.4: 27 files, 3MB
==> Installing fwup dependency: libarchive
==> Downloading https://homebrew.bintray.com/bottles/libarchive-3.4.2_1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ba/ba1e2a44af82b21ad9ddcc906bb9b6f0073797b79a1a2d41758d253609c95628?__gda__=e
######################################################################## 100.0%
==> Pouring libarchive-3.4.2_1.mojave.bottle.tar.gz
==> Caveats
libarchive is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have libarchive first in your PATH run:
  echo 'export PATH="/usr/local/opt/libarchive/bin:$PATH"' >> ~/.bash_profile

For compilers to find libarchive you may need to set:
  export LDFLAGS="-L/usr/local/opt/libarchive/lib"
  export CPPFLAGS="-I/usr/local/opt/libarchive/include"

For pkg-config to find libarchive you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libarchive/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/libarchive/3.4.2_1: 62 files, 3.5MB
==> Installing fwup
==> Downloading https://homebrew.bintray.com/bottles/fwup-1.6.0.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring fwup-1.6.0.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/fwup/1.6.0: 8 files, 337.2KB
Removing: /usr/local/Cellar/fwup/1.3.1... (8 files, 256.3KB)
==> Checking for dependents of upgraded formulae...
==> No dependents found!
==> Caveats
==> libarchive
libarchive is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have libarchive first in your PATH run:
  echo 'export PATH="/usr/local/opt/libarchive/bin:$PATH"' >> ~/.bash_profile

For compilers to find libarchive you may need to set:
  export LDFLAGS="-L/usr/local/opt/libarchive/lib"
  export CPPFLAGS="-I/usr/local/opt/libarchive/include"

For pkg-config to find libarchive you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libarchive/lib/pkgconfig"
$
fwup対応後のmix firmware

fwupのバージョンが1.5以上になったので、ふたたびmix firmwareを実行。

今度はエラーが発生せずに処理が終了しました。

$mix firmware

Nerves environment
  MIX_TARGET:   rpi3
  MIX_ENV:      dev

Compiling 2 files (.ex)
Generated hello_nerves app
|nerves_bootstrap| Building OTP Release...

〜(中略)〜

Number of directories 221
Number of ids (unique uids + gids) 4
Number of uids 3
    root (0)
    _appstore (33)
    kawamuraryuuta (501)
Number of gids 3
    wheel (0)
    _appstore (33)
    staff (20)
Building /Users/<ユーザ名>/work/elixir/ex_1.10.2-otp-22/nerves1.6.1/hello_nerves/_build/rpi3_dev/nerves/images/hello_nerves.fw...
$

無事、mix firmwareの実行が成功しました。

これで、2020/4/29時点での最新バージョンで「NervesはElixirのIoTでナウでヤングなクールなすごいやつ」を体験できます。

*1:更新内容は「--nerves-pack」オプションのデフォルト適用と「--init-gadget」オプションの削除。詳細はこちら: https://github.com/nerves-project/nerves_bootstrap/releases/tag/v1.8.0

*2:マシンはMacbook Air 2018年モデルを利用しています。