LoginSignup
1
1

Moddable SDK 4.2, ESP-IDF v5, xs-dev, Node-RED MCU Edition, node-red-mcu-pluginインストールメモ (ラズパイ編)

Last updated at Posted at 2023-10-09

はじめに

Node-RED MCU Editionの大幅アップデートのインストールメモです。

環境

  • Raspberry Pi 4B (4GB)
  • micro SDカード (32GB)
  • Raspberry Pi Imager (1.7.5)
  • Raspberry Pi OS with desktop (64bit 2023/5/3版)

環境構築

Raspberry Pi Imager, Raspberry Pi OSのダウンロード、SDカードへの書き込み、Raspberry Pi OSの起動の手順は省略します。

必要なパッケージのインストール

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install gcc git wget make libncurses-dev flex bison gperf
$ sudo apt install libgtk-3-dev

Moddable SDKのインストール

xs-devツールを使用して環境構築を行います。
最初にNode.js 18.x系をインストールします。

$ sudo apt install -y ca-certificates curl gnupg
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
$ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
$ sudo apt update
$ sudo apt install nodejs -y

バージョンを表示して動作確認します。

$ node -v
v18.18.0
$ npm -v
9.8.1

xs-devツールをインストールします。

$ sudo npm install -g xs-dev

以下のコマンドで動作確認します。

$ xs-dev -v
0.27.5

Moddable SDKをインストールします。

$ xs-dev setup

環境変数を有効にするため、一度ターミナルを閉じて新しく開きます。
以下のコマンドでインストール後の環境を確認します。

$ xs-dev info

xs-dev environment info:
  CLI Version                0.27.5
  OS                         Linux
  Arch                       arm64
  Shell                      /bin/bash
  NodeJS Version             v18.18.0 (/usr/bin/node)
  Python Version             3.9.2 (/usr/bin/python)
  Moddable SDK Version       4.2.0 (/home/pi/.local/share/moddable)
  Supported target devices   lin

以下のコマンドでサンプルプログラム(helloworld)を実行します。

$ xs-dev run --example helloworld

シミュレータ(mcsim)とデバッガ(xsbug)が起動します。

2023-10-09-205019_1920x1080_scrot.png

ESP32デバイスのセットアップ

以下のコマンドでESP32デバイスのビルドツール(ESP-IDF)をインストールします。

$ xs-dev setup --device esp32

環境変数を有効にするため、一度ターミナルを閉じて新しく開きます。
以下のコマンドでインストール後の環境を確認します。

$ xs-dev info

xs-dev environment info:
  CLI Version                0.27.5
  OS                         Linux
  Arch                       arm64
  Shell                      /bin/bash
  NodeJS Version             v18.18.0 (/usr/bin/node)
  Python Version             3.9.2 (/home/pi/.espressif/python_env/idf4.4_py3.9_env/bin/python)
  Moddable SDK Version       4.2.0 (/home/pi/.local/share/moddable)
  Supported target devices   lin, esp32
  ESP32 IDF Directory        /home/pi/.local/share/esp32/esp-idf

以下のコマンドでESP32デバイスの接続ポート番号を確認します。

(M5StickC Plusの例)

$ xs-dev scan

✔ Found the following available devices!
  Port          Device                       Features                                                                                   
  /dev/cuUSB0   ESP32-PICO-D4 (revision 1)   WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None

以下のコマンドでESP32デバイスでサンプルプログラムを実行します。
(xs-dev scanコマンドでPortが/dev/cuUSB0と表示されますが、実際は/dev/ttyUSB0として認識されているので、/dev/ttyUSB0を指定します。)

(M5StickC Plusでサンプルプログラム(helloworld)を実行する例)

$ xs-dev run --example helloworld --port /dev/ttyUSB0 --device esp32/m5stick_cplus

⠇ Building and deploying project /home/pi/.local/share/moddable/examples/helloworld on esp32/m5stick_cplus
⠙ Building and deploying project /home/pi/.local/share/moddable/examples/helloworld on esp32/m5stick_cplus
*** Update required to ESP-IDF v5.1.1 (found v4.4.3)
  See update instructions at: https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/esp32.md
Expected ESP IDF v5.1.1, found v4.4.3
make: *** [/home/pi/.local/share/moddable/build/tmp/esp32/m5stick_cplus/debug/helloworld/makefile:779: idfVersionCheck] Error 1

Moddable SDK 4.2はESP-IDFのバージョンがv4だとエラーが出ます。

xs-devツールはまだESP-IDF v5に対応していません
→ 2023/10/12 xs-dev 0.28.0でESP-IDF v5に対応しました。

$ xs-dev info

xs-dev environment info:
  CLI Version                0.28.0
  OS                         Linux
  Arch                       arm64
  Shell                      /bin/bash
  NodeJS Version             v18.18.0 (/usr/bin/node)
  Python Version             3.9.2 (/home/pi/.espressif/python_env/idf5.1_py3.9_env/bin/python)
  Moddable SDK Version       4.2.1 (/home/pi/.local/share/moddable)
  Supported target devices   lin, esp32
  ESP32 IDF Directory        /home/pi/.local/share/esp32/esp-idf

→ 2023/10/12 下記の手順は不要になりました。
ESP-IDFをマニュアルでv5.1.1へアップデートします。

$ cd ~/.local/share/esp32
$ mv esp-idf esp-idf.old
$ git clone -b v5.1.1 --recursive https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ ./install.sh

環境変数を有効にするため、一度ターミナルを閉じて新しく開きます。
もう一度、ESP32デバイスでサンプルプログラムを実行します。

2023-10-09-223241_1920x1080_scrot.png

(M5StickC Plusでボールデモ(piu/balls)を実行する例)

$ xs-dev run --example piu/balls --port /dev/tUSB0 --device esp32/m5stick_cplus

Node-REDとnode-red-mcu-pluginのインストール

インストール手順に変更はありません。
node-red-mcu-plugin 1.4.0でnRF52に対応しました。

$ bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
$ cd ~/.node-red
$ npm i @ralphwetzel/node-red-mcu-plugin

1.jpg

2.jpg

3.jpg

1
1
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
1
1