LoginSignup
12
11

More than 3 years have passed since last update.

Ubuntu 20.04 + VirtualBox 6.1でAWS IoT EduKitの開発環境を作る

Posted at

AWS IoT EduKit は ESP-IDF v4.2 を必要としますが、特にWindowsでの環境構築に不安があるため、仮想マシン内のUbuntuに構築する方法を掲載します。

ちなみにワークショップドキュメントに微細な間違いや必要とされるライブラリが明記されていなかったりするので、そちらも追加済みです。(BugReport済)

VirtualBox の準備

  • バージョン 6.1とExtensionのインストール
  • メインメモリ: 4096MB以上
  • プロセッサ数: 2以上
  • ビデオメモリ: 64MB以上
  • ストレージ: 20GB以上

※ Hyper-Vでも可能だとは思います。私がHyper-VにおけるUSBのパススルー操作に不慣れなためVBoxとしました。

Ubuntu 20.04

https://www.ubuntulinux.jp/products/JA-Localized/download から ubuntu-ja-20.04.1-desktop-amd64.iso をダウンロードし、VirtualBox へインストールします。

  • インストール構成
    • 最小インストール、サードパーティ製ソフトウェアインストール

インストール後

ホームディレクトリの中身を英語化
$ LANG=C xdg-user-dirs-gtk-update

Visual Studio Code installation

ドキュメントからの変更はありません。メモとして記載しておきます。

https://code.visualstudio.com/download から .deb 64bit をダウンロード。

$ sudo apt install -y ~/Downloads/code_1.52.1-1608136922_amd64.deb

Installing PlatformIO

作業前に以下を実行します。

$ sudo apt install -y git python3-venv

以降はドキュメントの通りです。

Claiming and provisioning the device

フォントの関係でQRコードが読めない(と思う)ので、その下に表示されるURLをブラウザに貼るとQRコードが表示されます。

Installing ESP-IDF v4.2

以下のように進めます。

$ sudo apt install -y git wget flex bison gperf python-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util python3-virtualenv python-is-python3
$ mkdir ~/esp/
$ cd ~/esp/
$ git clone -b release/v4.2 --recursive https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ bash install.sh
$ source ~/esp/esp-idf/export.sh

変更点

  • apt に python3-virtualenv python-is-python3 を追加。
  • install.sh の実行方法を修正。
  • export.sh の読み込み方法を source に変更。

Miniconda setup and installation

ドキュメントからの変更はありませんが、情報が不足しているので追記しています。

https://docs.conda.io/en/latest/miniconda.html#linux-installers から Python 3.8 用をダウンロード。

$ bash ~/Downloads/Miniconda3-latest-Linux-x86_64.sh
  • インストール先は $HOME/miniconda3
  • Do you wish the installer to initialize Miniconda3 by running conda init?yes を回答。
$ source ~/.bashrc
$ conda create -n edukit python=3.7
$ conda activate edukit

変更点

  • Miniconda3のインストール時の情報を追加。
  • source ~/.bashrc を追加。

AWS CLI v2

少しだけドキュメントから変更しています。

$ sudo apt install -y curl
$ curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o ~/Downloads/awscliv2.zip
$ unzip -x ~/Downloads/awscliv2.zip
$ sudo aws/install
$ rm -rf aws 

AWS CLI Configuration 以降はドキュメント通り。

変更点

  • apt install -y curl を追加。
  • ZIPのダウンロード先を Downloads にしている。
  • 展開先ディレクトリの削除。

Retrieving the Device Certificate and Registering your AWS IoT thing

作業前に以下を実行します。

$ source ~/esp/esp-idf/export.sh
$ conda activate edukit
$ sudo apt install -y libusb-1.0-0-dev libudev-dev g++ python3-dev

以降はドキュメント通りです。

registration_helper.py の実行でesptoolのimportに失敗した場合は、環境変数 IDF_PATH が正しくセットされていません。
新しい Terminal で source ~/esp/esp-idf/export.sh => conda activate edukit の順で実行したあと、再度実行してください。

以降も新しいTerminalを開いてAWS IoT EduKitの開発を行う場合は、今後常にこれら2つの環境読み込みを行いましょう。

$ source ~/esp/esp-idf/export.sh
$ conda activate edukit

ここまでの時間

ダウンロード時間を含めて、トータルで2時間ほど。ネットワークが遅いともっとかかります。

EoT

12
11
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
12
11