4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Coral Dev Board で Tensorflow Lite を動かすところまで mac で設定する

4
Last updated at Posted at 2019-12-26

基本、下記の記事の通りにやっただけです。

coraldevboard.png

少し違う環境でも試しているので、このページで情報が足りない場合は以下を参照のこと: https://qiita.com/mml/items/e04537dccbdb9028e226

物理的な準備

  • Coral Dev Board
  • Mac Book Pro
  • USB-C to C ケーブル (fastboot用)
  • USB-C の 5V 電源アダプタ (2.4A)
  • USB-B to C ケーブル (コンソール出力を mac に出すため)
  • オプション:HDMI ケーブル
  • オプション:Full HD 液晶ディスプレイ

mac の準備

fastboot の用意

あらかじめ fastboot を入れておく。Arduino Studio を入れてから、下記にパスを通せば使えるようになる。

/Users/<ユーザ名>/Library/Android/sdk/platform-tools/

Arduino Studio を入れたくない場合は、元記事のように brew でインストールするのがよさそう。

OS のイメージファイルの用意

下記のようにして取得しておく

$ curl -O https://dl.google.com/coral/mendel/enterprise/mendel-enterprise-chef-13.zip
$ unzip mendel-enterprise-chef-13.zip
$ cd mendel-enterprise-chef-13

Silicon Labs のシリアルドライバのインストール

下記から MacOS 用のドライバをダウンロードできる。

インストール途中で、セキュリティの警告が出て実行できないと言われたら、「設定」の「セキュリティ」の「一般」のタブの下の鍵をクリックして鍵をあけてから「ダウンロードしたアプリケーションの実行許可」の「App Store と確認済みの開発元からのアプリケーションを許可」のところに Silicon Labs と出るので、それを OK して鍵を閉じると、インストールが継続された。(セキュリティに関係する項目なので、この操作は自己責任にて)

これで、シリアルポートが認識されているかを確認する。

$ ls /dev/cu*
/dev/cu.Bluetooth-Incoming-Port	/dev/cu.SLAB_USBtoUART2
/dev/cu.SLAB_USBtoUART

SLAB_USBtoUART というのができていれば OK。

mac で console の出力を見る

ターミナルを開いて、screen を起動する。

$ screen /dev/cu.SLAB_USBtoUART 115200

基板の DIP が下記(公式ページより)のようになっていることを確認する。

DIP

DIP が問題なければ、mac と dev board を USB-C のケーブルと、USB-B のケーブルでそれぞれ繋いで、dev board に USB-C の電源アダプタをつなぐ。 USB-C ポートがふたつあるけど、data と power で用途が違っている。power 側に AC アダプタをつなぐ。ケーブルを実際に接続した状態は下記の通り(画像は公式ページのもの)。

USBcable

Dev Board 正常に起動して、ケーブルの接続、ドライバのインストール、screen コマンドの実行がすべて正常なら、下記のようなメッセージが表示される。

U-Boot 2017.03.1 (Mar 27 2019 - 22:21:16 +0000)

CPU:   Freescale i.MX8MQ rev2.1 1500 MHz (running at 1000 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 28C
Reset cause: POR
Model: Freescale i.MX8MQ Phanbell
DRAM:  1 GiB
Board id: 2
Baseboard id: 1
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial

BuildInfo:
- ATF
- U-Boot 2017.03.1

flash target is MMC:0
Net:
Warning: ethernet@30be0000 using MAC address from ROM
eth0: ethernet@30be0000
Fastboot: Normal
Hit any key to stop autoboot:  0

**********************************************************************
Welcome to your new Coral EdgeTPU Development Board!
**********************************************************************

To get started, you need to download and flash the latest firmware.
Please follow the instructions at g.co/coral/setup.


Configured USB Switch for UFP

ちなみに HDMI ケーブルを先につないでいると、power にケーブルを差しても電源が入らないようだ。

ここからは、Dev Board のバージョンによって操作が違うらしい。公式によれば、ファンの壁面に書かれているバージョンを見て、バージョンが 9410 以上であれば、これで fastboot モードになっていて、インストールを開始できるぽい。手持ちのボードは 9522 だったので、インストールに進んで良いらしい。

BoardVersion

Dev Board への OS のインストール

mac と dev board を USB-C ケーブルで接続する。この type-C ケーブルが曲者で、安物のケーブルだとうまく接続できないことがあるぽい。いろいろ試して、Tunderbolt3 対応ケーブルを使ってみたら、問題なく通信できた。

fastboot でデバイスの確認

$ fastboot devices
190851b6f32ea629	fastboot

こんな感じで、何がしかの数字が出たら OK。出なければ、ケーブルが悪いかデバイスが fastboot モードになっていない(多分)。

インストール

デバイスの確認ができたら、mendel-enterprise-chef-13.zip を展開したディレクトリ内で、flash.sh を実行する。

$ bash flash.sh
Sending 'bootloader0' (1006 KB)                    OKAY [  0.054s]
Writing 'bootloader0'                              OKAY [  0.233s]
Finished. Total time: 0.308s
Rebooting into bootloader                          OKAY [  0.025s]
Finished. Total time: 0.025s
< waiting for any device >
Sending 'gpt' (33 KB)                              OKAY [  0.018s]
Writing 'gpt'                                      OKAY [  0.363s]
Finished. Total time: 0.401s
Rebooting into bootloader                          OKAY [  0.023s]
Finished. Total time: 0.023s
< waiting for any device >
Erasing 'misc'                                     OKAY [  0.071s]
Finished. Total time: 0.081s
Sending 'boot' (131072 KB)                         OKAY [  4.938s]
Writing 'boot'                                     OKAY [  4.141s]
Finished. Total time: 9.100s
Sending sparse 'rootfs' 1/3 (397265 KB)            OKAY [ 21.027s]
Writing 'rootfs'                                   OKAY [ 29.390s]
Sending sparse 'rootfs' 2/3 (408325 KB)            OKAY [ 22.311s]
Writing 'rootfs'                                   OKAY [ 57.614s]
Sending sparse 'rootfs' 3/3 (352960 KB)            OKAY [ 13.947s]
Writing 'rootfs'                                   OKAY [103.771s]
Finished. Total time: 248.216s
Rebooting                                          OKAY [  0.005s]
Finished. Total time: 0.005s

これでインストールは終了。

ログインと設定

screen でコンソール経由でログインする。ユーザ名とパスワードは、いずれも mendel。

Mendel GNU/Linux (chef) orange-shrimp ttymxc0

orange-shrimp login: mendel
Password: 
Last login: Fri Apr 19 22:59:13 UTC 2019 on tty7
Linux orange-shrimp 4.9.51-imx #1 SMP PREEMPT Fri Apr 5 00:17:46 UTC 2019 aarch64

The programs included with the Mendel GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Mendel GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
mendel@orange-shrimp:~$ 

screen を起動しても何もメッセージが出ない場合は、次のようにしてみる。

  1. すべてのケーブルを抜く
  2. USB-B だけ差す (mac とつなぐ)
  3. screen を起動する (この段階では何も表示されない)
  4. USB-C (電源アダプタ) を power につなぐ

無線LAN の設定

$ nmcli dev wifi connect <NETWORK_NAME> password <PASSWORD> ifname wlan0

正常につながれば、下記のようなメッセージが出る。失敗すると Error と表示される。

Device 'wlan0' successfully activated with 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx'.

設定はリブートするとリセットされるので、恒久的な設定にしたければ /etc/network/interfaces などに設定する。

アップデート

ネットワークにつながったら、アップデートする。

$ sudo apt -y update
$ sudo apt -y upgrade

Tensorflow Lite のインストール

$ wget https://dl.google.com/coral/python/tflite_runtime-1.14.0-cp37-cp37m-linux_aarch64.whl
$ pip3 install tflite_runtime-1.14.0-cp37-cp37m-linux_aarch64.whl

flite_runtime-1.14.0-cp37-cp37m-linux_aarch64.whl is not a supported wheel on this platform. とか出るかもしれないど、気にしない。とりあえずテストしておく。テストの前に HDMI ケーブルでディスプレイにつないでおくと、デモの様子をディスプレイで直接見ることができる。

$ edgetpu_demo --device

ディスプレイがないときは --stream オプションで起動して、いろいろやる必要あり (詳しくは公式ページをみてね)。

高速道路を車が走る画像から、車を検出するデモが動くようだ。ワーニングで「パワー不足のデバイス」とか言われてるけど、15fps くらいは出てた。このデモを実行してもファンが回らないのに、ヒートシンクは結構な温度になる。USB ケーブルを抜こうとして、うっかり火傷しそうになるくらいには熱かった。

普通の Linux の設定

あとは、普通の Linux マシンの設定をいくつかしておけば OK (多分)。 ssh でログインできるように設定できれば、USB-C の power ケーブル以外はなくてもよくなる。IP は固定にしておいたほうが良さそう。

4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?