R-Car/Boards/Yocto-Gen3/Azure IoT Edge/v5.5.0
< R-Car | Boards/Yocto-Gen3 | Azure IoT Edge
Contents
はじめに
このページは、 R-Car にて Azure IoT Hub を使用するための、Yocto環境の構築および実行手順を記載している。
環境
ビルドPC
OS | Ubuntu 20.04 LTS (64bit) |
メモリ | 8 GB 以上 |
ストレージ | 空き 100 GB 以上 |
確認済みボード
Board | SoC | Confirmed |
---|---|---|
R-Car Starter Kit Premier | H3 v2.0 | OK |
CCPF + R-Car Starter Kit Premier | H3 v2.0 | OK |
R-Car Starter Kit Pro | M3 v1.0 | OK |
R-Car Starter Kit Pro | M3 v3.0 | OK |
CCPF + R-Car Starter Kit Pro | M3 v1.0 | OK |
CCPF + R-Car Starter Kit Pro | M3 v3.0 | OK |
Azure のセットアップ
- Azure アカウント作成
- 下記を参考に Azure アカウントを作成する。
- https://azure.microsoft.com/en-us/free/
- Azure IoT Hub 作成
- 下記を参考に Azure IoT Hub を作成する。
- https://docs.microsoft.com/ja-jp/azure/iot-hub/iot-hub-create-through-portal#create-an-iot-hub
- Azure Device 登録
- https://portal.azure.com/
- 上記にアクセスして作成した IoT Hub を選択する。
- サイドメニューの「デバイス管理」の「IoT Edge」→「+ IoT Edge デバイスの追加」を押下する。
- 「デバイスID」に任意の名前を設定し、他は変更せずに「保存」を押下する。
- サイドメニューの「デバイス管理」の「IoT Edge」で、作成したデバイスIDを押下して「プライマリ接続文字列」を確認する。
- プライマリ接続文字列は、ターゲットボードでの動作手順にて使用する。
- Azure モジュールの追加
- 下記を参考に Simulated Temperature Sensor モジュールを追加する。
- https://docs.microsoft.com/ja-jp/azure/iot-edge/quickstart-linux?view=iotedge-2018-06#deploy-a-module
ビルド手順
- 事前準備(パッケージのインストール)
$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \ build-essential chrpath socat cpio python3 python3-pip python3-pexpect \ xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa \ libsdl1.2-dev pylint3 xterm
- gitの設定
$ git config --global user.email "you@example.com" $ git config --global user.name "Your Name"
- ビルドスクリプトを任意のディレクトリに作成
- 18px <translate> Note:</translate>ビルドスクリプトはボードにCCPFが付いている場合とついていない場合で違うため、注意すること
- H3SK / M3SK の場合の build.sh
#!/bin/bash BOARD_LIST=("h3ulcb" "m3ulcb") TARGET_BOARD=$1 WORK=`pwd`/${TARGET_BOARD} # Commit ID POKY_COMMIT=6ebb33bdaccaeadff0c85aab27acf35723df00d8 META_OE_COMMIT=c38d2a74f762a792046f3d3c377827b08aade513 META_RENESAS_COMMIT=0fe77668f5d9a31a5d10449988c3d8fb8dc475c5 META_VIRTUALIZATION_COMMIT=92cd3467502bd27b98a76862ca6525ce425a8479 META_DOCKER_COMMIT=1ca1b5caf6f373dcc49db82dce50f4d8ab9f25cd META_RUST_COMMIT=7ff669d8cedd83a2d3efb73073a63b0a7efffddc META_IOTEDGE_COMMIT=06a968a4a662dc5c26aac8d72738767ed72aef52 Usage () { echo "Usage: $0 \${TARGET_BOARD_NAME}" echo "BOARD_NAME list: " for i in ${BOARD_LIST[@]}; do echo " - $i"; done exit } # Check Param. if ! `IFS=$'\n'; echo "${BOARD_LIST[*]}" | grep -qx "${TARGET_BOARD}"`; then Usage fi mkdir -p ${WORK} cd ${WORK} # Clone basic Yocto layers in parallel git clone git://git.yoctoproject.org/poky & git clone git://git.openembedded.org/meta-openembedded & git clone git://github.com/renesas-rcar/meta-renesas & git clone git://git.yoctoproject.org/meta-virtualization & git clone git://github.com/tkomagata/meta-docker & git clone git://github.com/meta-rust/meta-rust & git clone git://github.com/tkomagata/meta-iotedge & # Wait for all clone operations wait # Switch to proper branches/commits cd ${WORK}/poky git checkout -b tmp ${POKY_COMMIT} cd ${WORK}/meta-openembedded git checkout -b tmp ${META_OE_COMMIT} cd ${WORK}/meta-renesas git checkout -b tmp ${META_RENESAS_COMMIT} cd ${WORK}/meta-virtualization git checkout -b tmp ${META_VIRTUALIZATION_COMMIT} cd ${WORK}/meta-docker git checkout -b tmp ${META_DOCKER_COMMIT} cd ${WORK}/meta-rust git checkout -b tmp ${META_RUST_COMMIT} cd ${WORK}/meta-iotedge git checkout -b tmp ${META_IOTEDGE_COMMIT} TEMPLATECONF=${WORK}/meta-iotedge/conf/machine/${TARGET_BOARD}/bsp/ cd ${WORK} source poky/oe-init-build-env ${WORK}/build
- CCPF+H3SK / CCPF+M3SK の場合の build.sh
#!/bin/bash BOARD_LIST=("h3ulcb" "m3ulcb") TARGET_BOARD=$1 WORK=`pwd`/${TARGET_BOARD} # Commit ID POKY_COMMIT=6ebb33bdaccaeadff0c85aab27acf35723df00d8 META_OE_COMMIT=c38d2a74f762a792046f3d3c377827b08aade513 META_RENESAS_COMMIT=0fe77668f5d9a31a5d10449988c3d8fb8dc475c5 META_RENESAS_CCPF_COMMIT=2e264bba92128dd6c3be68068673b1fd2d3e36e8 META_VIRTUALIZATION_COMMIT=92cd3467502bd27b98a76862ca6525ce425a8479 META_DOCKER_COMMIT=1ca1b5caf6f373dcc49db82dce50f4d8ab9f25cd META_RUST_COMMIT=7ff669d8cedd83a2d3efb73073a63b0a7efffddc META_IOTEDGE_COMMIT=06a968a4a662dc5c26aac8d72738767ed72aef52 Usage () { echo "Usage: $0 \${TARGET_BOARD_NAME}" echo "BOARD_NAME list: " for i in ${BOARD_LIST[@]}; do echo " - $i"; done exit } # Check Param. if ! `IFS=$'\n'; echo "${BOARD_LIST[*]}" | grep -qx "${TARGET_BOARD}"`; then Usage fi mkdir -p ${WORK} cd ${WORK} # Clone basic Yocto layers in parallel git clone git://git.yoctoproject.org/poky & git clone git://git.openembedded.org/meta-openembedded & git clone git://github.com/renesas-rcar/meta-renesas & git clone git://github.com/renesas-rcar/meta-renesas-ccpf & git clone git://git.yoctoproject.org/meta-virtualization & git clone git://github.com/tkomagata/meta-docker & git clone git://github.com/meta-rust/meta-rust & git clone git://github.com/tkomagata/meta-iotedge & # Wait for all clone operations wait # Switch to proper branches/commits cd ${WORK}/poky git checkout -b tmp ${POKY_COMMIT} cd ${WORK}/meta-openembedded git checkout -b tmp ${META_OE_COMMIT} cd ${WORK}/meta-renesas git checkout -b tmp ${META_RENESAS_COMMIT} cd ${WORK}/meta-renesas-ccpf git checkout -b tmp ${META_RENESAS_CCPF_COMMIT} cd ${WORK}/meta-virtualization git checkout -b tmp ${META_VIRTUALIZATION_COMMIT} cd ${WORK}/meta-docker git checkout -b tmp ${META_DOCKER_COMMIT} cd ${WORK}/meta-rust git checkout -b tmp ${META_RUST_COMMIT} cd ${WORK}/meta-iotedge git checkout -b tmp ${META_IOTEDGE_COMMIT} TEMPLATECONF=${WORK}/meta-iotedge/conf/machine/${TARGET_BOARD}/bsp/ cd ${WORK} source poky/oe-init-build-env ${WORK}/build
- ビルドスクリプトを実行
- ビルド実行
$ cd <target_board_name> $ source poky/oe-init-build-env $ bitbake core-image-minimal
- イメージのビルドは、ホストシステムの性能によっては数時間かかることがある。
- ビルドが正常に完了すると、以下のような出力が表示される。
NOTE: Tasks Summary: Attempted 4704 tasks of which 31 didn't need to be rerun and all succeeded.
- ビルド生成物
- bitbake を実行して生成されたファイルは以下に格納される
- <target_board_name>/build/tmp/deploy/images/<target_board_name>/
- イメージを SD カードに書き込む
- SDカードにイメージを書き込む方法は、Loading kernel and rootfs via eMMC/SD cardを参照。
- 18px <translate> Note:</translate>上記の例はイメージが"weston"のため、"minimal"に置き換えることに注意すること
動作手順
- ターゲットボードでの動作手順
- R-Car SK の起動
- R-Car SK に uSD カードを挿入して、LANケーブルを接続する。
- USB デバッグシリアルケーブルを PC と接続して、AC 電源を投入する。
- PC 側では、ターミナルソフトを起動して、シリアル接続を行う。
- 電源をONにする。
- R-Car SK の POWER SW(SW8) を押下する。
- CCPFが付いている場合は、CCPF基板のPOWER SW(SW4)を押下する。
- SD ブートを U-Boot で設定
- SDブートの設定方法は、Configure U-Boot to boot from SD cardを参照。
- IoT Edge Device の動作確認
- R-Car SK の起動
- Azure IoT Explorer での動作手順
- Azure IoT Explorer で端末からメッセージが送信されていることを確認する。
- Azure IoT Explorer をダウンロード / インストール
- 下記サイトからインストーラーをダウンロードする。
- https://github.com/Azure/azure-iot-explorer/releases
- 18px <translate> Note:</translate>最新版のAzure.IoT.Explorer.preview.0.14.7 では、テレメトリが受信できなかったため、Azure.IoT.Explorer.preview.0.14.1 を使用
- Azure IoT Explorer を起動する
- IoT Hub の iothubowner 接続文字列を取得する。
- IoT Hub を IoT Explorer に登録する
- Azure IoT Explorerのサイドメニューから「IoT hubs」を選択し、「+ Add connection」を押下する。
- 「Connection string」に上記でコピーした「iothubowner 接続文字列」をペーストして、「Save」を押下する。
- テレメトリを確認する