LoginSignup
2
0

More than 3 years have passed since last update.

M5StackでAmazon FreeRTOSを使用する7(Greengrass編)

Posted at

はじめに

M5StackでAmazon FreeRTOSを動かすと、効率的にアプリケーション開発、デバイス管理ができることがわかってきました。とはいえ、多数のM5Stackデバイスが直接クラウドに接続しないとうまく管理できない状況は非効率です。そこでAWS IoT Greengrassを利用してみましょう。
AWS IoT Greengrassを使うと、IoTデバイスの通信をローカルネットワークで行うことができ、サーバーレスで使い慣れたLambdaを使って処理を行ったり、データを格納したりすることができるようになります。

greengrass.png

AWS IoT Greengrassの要件はこちら サポートされているプラットフォームと要件 にありますが、CPUはARMまたはx86、メモリ128Mバイト以上など、ということで、今回は、仕事で関わっているRecord Meetingという自動議事メモ作成サービスで利用しているスピーカーでAWS IoT Greengrassを動かしてみます。このスピーカーは残念ながら一般に市販されていないのですが、この投稿では以降Raspberry Piと読み替えて頂ければ問題ないと思います。

COET Record Meeting

インストール

AWSのドキュメント AWS IoT Greengrass の使用開始 に沿ってAWS IoT Greengrassを設定します。

また、こちら Raspberry PiでAWS GreenGrassをセットアップし、AWS Lambda 関数を設定するまで のページでも詳しく説明して頂いているので、非常に助かりました。

チュートリアルに記載されていますが、IoT Greengrass 依存関係チェッカーを使用するとAWS IoT Greengrassの動作環境をチェックしてくれます。(以下サンプル)

==========================Checking script dependencies==============================
The device has all commands required for the script to run.

========================Dependency check report for GGC v1.10.x=========================
System configuration:
Kernel architecture: armv7l
Init process: /lib/systemd/systemd

(省略)

------------------------------------Results-----------------------------------------
Note:
1. It looks like the kernel uses 'systemd' as the init process. Be sure to set the
'useSystemd' field in the file 'config.json' to 'yes' when configuring Greengrass core.

Missing optional dependencies:
1. Could not find the binary 'python3.7'.

If Python 3.7 is installed on the device, name the binary 'python3.7' and add its parent
directory to the PATH environment variable. Python 3.7 is required to execute Python 3.7
lambdas on Greengrass core.

2. Could not find the binary 'nodejs8.10'.

If NodeJS 8.10 or later is installed on the device, name the binary 'nodejs8.10' and
add its parent directory to the PATH environment variable. NodeJS 8.10 or later is
required to execute NodeJS lambdas on Greengrass core.

3. Could not find the binary 'java8'.

If Java 8 or later is installed on the device name the binary 'java8' and add its
parent directory to the PATH environment variable. Java 8 or later is required to
execute Java lambdas as well as stream management features on Greengrass core.

(Optional) Greengrass container dependencies
Missing required dependencies:
1. The 'memory' cgroup is not enabled on the device.
Greengrass will fail to set the memory limit of user lambdas.

Supported lambda isolation modes:
No Container: Supported
Greengrass Container: Not supported

----------------------------------Exit status---------------------------------------
You can now proceed to installing the Greengrass core 1.10.x software on the device.
Please reach out to the AWS Greengrass support if issues arise.


Greengrassグループを作成する際、チュートリアルでは「簡易なグループの作成」で行いますが、この場合ストリームマネージャーが有効になります。ストリームマネージャーがJava8を使用するため、Java8のインストールがおすすめされます。今回の環境では、ストレージの残りが少なかったため、Python3.7、Java8をインストールしませんでした。

Python2.7はサポートが 終了予定 のため、利用は推奨されていませんが、まだ利用できるようです。

手順通りに、/boot/cmdline.txt に次の行を追加を追加してますが、'memory' cgroup が有効でないと言われています。今回はコンテナーを使用しないのでそのままにしました。

cgroup_enable=memory cgroup_memory=1

インストール後に、ロール設定とストリームマネージャーを無効にします。

greengrass2.png

greengrass3.png

おわり

Greengrassのインストールは完了です。

greengrass4.png

メモ

第1回 Amazon FreeRTOSインストール
第2回 Lチカ
第3回 TFT
第4回 SDカード
第5回 AWS Shadows
第6回 OTA

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