Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JAWS_UG_IoT専門支部_FreeRTOSの概要とESP32デバイス上での動作事例

 JAWS_UG_IoT専門支部_FreeRTOSの概要とESP32デバイス上での動作事例

JAWS発表資料

Avatar for Tsugunao Kobayashi

Tsugunao Kobayashi

December 19, 2024
Tweet

Other Decks in Technology

Transcript

  1. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 2 本⽇お話すること • IoTにおけるFreeRTOSの位置づけ • FreeRTOSの概要 • ESP32デバイス上でのFreeRTOS動作事例
  2. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 3 ⼩林 嗣直 (Kobayashi Tsugunao) Senior IoT Consultant AWS Professional Services 略歴 • ⼤⼿電機メーカーにて約17年間、コンシューマ向けのプロダクト開発・設計に 従事。OS制御のデバイスドライバからミドルウエア、Webフロントエンドの ソフトウエア開発に従事 • 2015年より⼤⼿インターネット通販事業者にてECサイトのバックエンドシス テムの開発、運⽤に従事。 • 2017年よりアマゾンジャパンにてベンダー様向けシステムの要件定義、機能 開発に従事 • 2020 年より現職 得意分野 • AWS IoTを活⽤したシステムの構築 • プロジェクトマネジメント • 組み込み機器システム開発、Webシステムバックエンド開発 Who am I?
  3. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 4 宣伝(最近本を出版しました) AWS IoT 実践講座 https://amzn.asia/d/1hWReT4
  4. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 5 本⽇お話すること • IoTにおけるFreeRTOSの位置づけ • FreeRTOSの概要 • ESP32デバイス上でのFreeRTOS動作事例
  5. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 6 AWS IoT と繋がるデバイスを作るには︖ ?
  6. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 7 何億もの IoT デバイスは マイコンやマイクロプロセッサで動作している マイコン マイクロプロセッサ
  7. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 8 セキュアに AWS IoT と接続 AWS IoT Greengrass Or AWS IoT Device SDK マイコン マイクロプロセッサ freeRTOS
  8. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 9 マイコン向けのOS No scheduler プロセッサパワー (プロセッサの価格) μCLinux, eCos Linux FreeRTOS 適用性 スケジューラ機能 省電⼒、安価
  9. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 10 本⽇お話すること • IoTにおけるFreeRTOSの位置づけ • FreeRTOSの概要 • ESP32デバイス上でのFreeRTOS動作事例
  10. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 11 FreeRTOSの前に、そもそもRTOSとは何か︖ RTOS = リアルタイムOS 組み込み向けシステムではリアルタイム性が求められることが多い RTOSの特徴 最悪応答時間の保証 優先度によるスケジューリング ⼩さなフットプリントで 動作可能
  11. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 13 FreeRTOSとは︖ 20+ 年間にわたり広く配布された信頼性 RISC-V や Arm v8-M など 40以上のアーキテクチャでサポート 広範なエコシステム MIT ライセンスの無償オープンソース IoT デバイスに必要な機能をサポートする 豊富なライブラリ群 最⼤ 2 年間の安定バージョン (LTS) や 加えて最⼤ 10 年間の追加メンテナンスプラン 提供 https://aws.amazon.com/freertos/ https://freertos.org
  12. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 14 FreeRTOS System Stack 下記で構成 • FreeRTOS Kernel • FreeRTOS ライブラリ HTTP User (application) code Vendor supplied libraries & drivers Hardware FreeRTOS Kernel FreeRTOS internal libraries HTTP library MQTT library Cellular LTE-M library OTA Agent … FreeRTOS カーネル FreeRTOS ライブラリ
  13. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 18 FreeRTOS FAQ Q: Amazon FreeRTOSとFreeRTOSはどのような関係ですか︖ A: Amazon FreeRTOSはFreeRTOSプロジェクトの拡張であるため、2017年以 来2つの名前を統⼀しました Q: FreeRTOSのソースコードを変更することはできますか︖ A: 25MHz以上の処理速度と64kB以上のRAMが必要になります Q: ハードウェアの最⼩仕様要件はどのようなものですか︖ A: Yes. FreeRTOSはMITライセンスで配布されるオープンソースのソフトウ エアであるためニーズに合わせて変更することができます。MIT ライセンス では、FreeRTOS (カーネルを含む) を使⽤して商⽤製品を開発および販売でき ますが、ソースコードの変更を公開する義務はありません。
  14. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 19 本⽇お話すること • IoTにおけるFreeRTOSの位置づけ • FreeRTOSの概要 • ESP32デバイス上でのFreeRTOS動作事例
  15. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 20 ESP32とは︖ • Espressif Systems社が提供す るWi-fi,Bluetooth内臓のマイ コン • 「ESP32-DevKitC」と呼ばれ る開発ボードの互換品が各社 から発売されている • ESP32はXtensa 32bit LX6 CPU CoreのRISC archでDual Coreとなっている デバイスカタログにも認定デバイスが登録されています https://partners.amazonaws.com/search/qualified-devices/?keyword=esp32
  16. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 21 ESP32開発環境: ESP-IDF https://docs.espressif.com/projects/esp-idf/en/stable/esp32/index.html
  17. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 22 ESP-IDF開発環境でのFreeRTOS • ESP-IDFのアプリケーションや多くのESP-IDFのコンポーネントはFreeRTOS をベースに書かれている • オフィシャルのFreeRTOSはシングルコア⽤のRTOSとなっている • マルチコアのESPチップ向けに2つの実装がある 1)Espressif System社が提供するESP-IDF FreeRTOS 2)Amazonが提供する Amazon SMP FreeRTOS • ESP-IDFのデフォルトのFreeRTOSは 1) ESP-IDF FreeRTOSとなっている • Amazon SMP FreeRTOSを選択したい場合にはCONFIG_FREERTOS_SMPを 有効にする。ただしこちらは現状ベータ版の位置づけ。 https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api- reference/system/freertos.html
  18. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 23 ESP32⽤のAWS IoT向けライブラリ︓esp-aws-iot https://developer.espressif.com/blog/support-for-lts-release-of-aws-iot-device-sdk-for-embedded-c-on-esp3/ 過去に存在したAmazon FreeRTOS⽤の実装と なっていて、現在はDeprecated扱い。 IoT Device SDK for Embedded Cを使⽤した実装 となっている。esp-aws-iotとして公開されてい る。
  19. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 24 esp-aws-iotのexamples $ cd esp-aws-iot/examples/mqtt/tls_mutual_auth $ idf.py -p [PORT] build flash monitor I (12035) coreMQTT: Delay before continuing to next iteration. I (13035) coreMQTT: Sending Publish to the MQTT topic esp32-thing/example/topic. I (13035) coreMQTT: PUBLISH sent for topic esp32-thing/example/topic to broker with packet ID 3. I (13075) coreMQTT: Ack packet deserialized with result: MQTTSuccess. I (13075) coreMQTT: State record updated. New state=MQTTPublishDone. I (13075) coreMQTT: PUBACK received for packet id 3. I (13085) coreMQTT: Cleaned up outgoing publish packet with packet id 3. I (13095) coreMQTT: De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. I (13095) coreMQTT: State record updated. New state=MQTTPubAckSend. I (13105) coreMQTT: Incoming QOS : 1. I (13105) coreMQTT: Incoming Publish Topic Name: esp32-thing01/example/topic matches subscribed topic. Incoming Publish message Packet Id is 1. Incoming Publish Message : Hello World!. I (18135) coreMQTT: Delay before continuing to next iteration. MQTT通信やShadow, Jobsの機能を試してみることができます
  20. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 25 動作事例 (1): esp-aws-iotのexamples: mqtt/tls- mutual-auth
  21. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 26 動作事例 (2)︓温度センサー(DHT11)からのデータの取得 DHT11のドライバ︓ esp32-DHT11: https://github.com/Anacron-sec/esp32-DHT11 デバイス上で以下のようにデータ取得してAWSへ送信 #include “dht11.h” struct dht11_reading dht_data = DHT11_read(); //dht_data.temperature //dht_data.humidity AWS マネジメントコンソール
  22. © 2024, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. 27 本⽇お話すること • IoTにおけるFreeRTOSの位置づけ • FreeRTOSの概要 • ESP32デバイス上でのFreeRTOS動作事例