diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aa8fa0a..0ee9f00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,10 +9,10 @@ jobs: submodules: recursive - uses: ./.github/actions/setup - name: Build - run: source $HOME/.local/share/xs-dev-export.sh && npm run build + run: source $HOME/.local/share/xs-dev-export.sh && sh ./setting_scripts/unset_psram.sh && npm run build working-directory: ./firmware - name: Build CoreS3 - run: source $HOME/.local/share/xs-dev-export.sh && npm run build --target=esp32/m5stack_cores3 + run: source $HOME/.local/share/xs-dev-export.sh && sh ./setting_scripts/unset_psram.sh && npm run build --target=esp32/m5stack_cores3 working-directory: ./firmware - name: Check Format run: npm run format diff --git a/README.md b/README.md index 21edd94..2011a47 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,11 @@ This repository includes the following contents. * For Windows: [(WSL2) Windows 11 Stack-chan Environment Setup Manual (Japanese)](firmware/docs/getting-started-wsl2_ja.md) * For MacOS/Linux: [Getting Started (MacOS/Linux)](./firmware/docs/getting-started.md) +* For Web: Follow the steps below (Reference: [Tried Flashing a Program to Stack-chan via Web Browser (Japanese)](https://rt-net.jp/humanoid/archives/5907)): + 1. Access the web-flash page from your PC. + 2. Connect Stack-chan to the PC using a cable. + 3. Select `M5Stack CoreS3`. + 4. Press the `Flash Stack-chan firmware [・_・]` button. ## Contribution diff --git a/README_ja.md b/README_ja.md index e4daa55..81eaafa 100644 --- a/README_ja.md +++ b/README_ja.md @@ -54,6 +54,11 @@ * Windowsの場合:[Windows 11 のスタックチャン環境構築マニュアル(WSL2)](firmware/docs/getting-started-wsl2_ja.md) * MacOS/Linuxの場合:[環境構築(MacOS/Linux)マニュアル](./firmware/docs/getting-started_ja.md) +* Webの場合:以下の手順を実行(参考:[Webブラウザからスタックチャンにプログラムを書き込んでみた](https://rt-net.jp/humanoid/archives/5907)) + 1. PCから[web-flahページ](https://rt-net.github.io/stack-chan/web/flash/)にアクセス + 2. スタックチャンとPCをケーブルで接続 + 3. `M5Stack CoreS3`を選択 + 4. `Flash Stack-chan firmware [・_・]`ボタンを押下 ## コントリビューション diff --git a/firmware/docs/flashing-firmware.md b/firmware/docs/flashing-firmware.md index 5820f58..07883ea 100644 --- a/firmware/docs/flashing-firmware.md +++ b/firmware/docs/flashing-firmware.md @@ -36,7 +36,9 @@ Additionally, you can specify the paths of other manifest files in a list format ## Writing the base program (hosts) As stated above, Stack-chan's firmware comprises a base program (host) and a user application (MOD). -The handling of PSRAM connected to esp32 has changed from esp-idf version 5.x. The default settings do not work smoothly, so we will change some of them. ~/.local/share/moddable/build/devices/esp32/targets/m5stack_cores3/sdkconifg. CONFIG_SPIRAM=y to CONFIG_SPIRAM_n. + +**The handling of PSRAM connected to esp32 has changed from esp-idf version 5.x. The default settings do not work smoothly, so we changed some of them.** +**When [setting the PSRAM environment variables](./getting-started.md#set-up-manual), `CONFIG_SPIRAM=y` in `~/.local/share/moddable/build/devices/esp32/targets/m5stack_cores3/sdkconfig/sdkconfig.defaults` is rewritten to `CONFIG_SPIRAM=n`.** The following commands are used to build and write a host. diff --git a/firmware/docs/flashing-firmware_ja.md b/firmware/docs/flashing-firmware_ja.md index f5d8dfa..90ad097 100644 --- a/firmware/docs/flashing-firmware_ja.md +++ b/firmware/docs/flashing-firmware_ja.md @@ -39,11 +39,12 @@ ## 基本プログラム(ホスト)の書き込み -前述の通りスタックチャンのファームウェアは基本プログラム(ホスト)とユーザアプリケーション(MOD)から構成されます。 -esp-idfのバージョンが5.xからesp32に接続しているPSRAMの扱いが変わっています。デフォルト設定ではスムーズに動かないため一部変更します。 -~/.local/share/moddable/build/devices/esp32/targets/m5stack_cores3/sdkconifgのファイルにある -CONFIG_SPIRAM=yをCONFIG_SPIRAM_nに書き換えます。 +前述の通りスタックチャンのファームウェアは基本プログラム(ホスト)とユーザアプリケーション(MOD)から構成されます。 +**esp-idfのバージョンが`5.x`からesp32に接続しているPSRAMの扱いが変わっています。デフォルト設定ではスムーズに動かないため一部変更しています。** +**[環境構築の設定変更スクリプト実行時](./getting-started_ja.md#設定の変更)に、`~/.local/share/moddable/build/devices/esp32/targets/m5stack_cores3/sdkconfig/sdkconfig.defaults`に記述された`CONFIG_SPIRAM=y`を`CONFIG_SPIRAM=n`に書き換えています。** + +
次のコマンドで基本プログラム(ホスト)の書き込みを行います。 @@ -56,6 +57,7 @@ $ npm run deploy --target=esp32/m5stack_cores3 ``` Ubuntuの場合、書き込みポートがReadOnlyになっています。sudo chmod 666 /dev/ttyACM0でモードを書き換えるが、永続的にUSBポートの使用権限を変更する場合は、次のコマンドを実行してPCを再起動します。 + ```console $sudo usermod -aG dialout $USER ``` diff --git a/firmware/docs/getting-started-wsl2_ja.md b/firmware/docs/getting-started-wsl2_ja.md index 4c2a3a4..3d729f6 100644 --- a/firmware/docs/getting-started-wsl2_ja.md +++ b/firmware/docs/getting-started-wsl2_ja.md @@ -227,17 +227,31 @@ $ npm run setup -- --device=esp32 +### PSRAMと環境変数のセットアップ -最後にmoddableの環境設定スクリプト xs-dev-export.sh がターミナル起動時に自動で読み込まれません。~/.bashrcに -source ~/.local/share/xs-dev-export.sh -を追加してください。 +次のコマンドを実行して、PSRAM無効化の設定をします。 +```sh +$ ./setting_scripts/unset_psram.sh +``` + + + + +次のコマンドを実行し、Shellの設定ファイルに`source ~/.local/share/xs-dev-export.sh`を追加します。これにより、Shellの起動時に自動で環境変数が設定されるようになります。 +```sh +$ ./setting_scripts/set_xs-dev_env.sh +``` + + ### 構築した環境の確認 -以下のコマンドで環境のテストをします。 +#### Moddableの環境確認 + +以下のコマンドでModdableの環境のテストをします。 ```bash $ npm run doctor @@ -247,6 +261,20 @@ $ npm run doctor `Moddable`のバージョンが`v4.9.5`で、`ESP32 IDF Directory`のパスが正しく表示されており、`Supported target devices`が`lin, esp32`となっていれば成功です。 +#### PSRAMの環境確認 + +以下のコマンドでM5Stack CoreS3のPARAMの設定を確認します。 + +```bash +$ grep CONFIG_SPIRAM= $MODDABLE/build/devices/esp32/targets/m5stack_cores3/sdkconfig/sdkconfig.defaults +``` + + + + +`CONFIG_SPIRAM=n`と表示されれば成功です。 + + ここまで完了次第、Ubuntuのウインドウを閉じてください。 diff --git a/firmware/docs/getting-started.md b/firmware/docs/getting-started.md index c6ff614..fbac210 100644 --- a/firmware/docs/getting-started.md +++ b/firmware/docs/getting-started.md @@ -13,12 +13,14 @@ Stack-chan can be developed on Windows 11, MacOS, and Linux. For Windows 11, ple * Tested on MaxOS (Sonoma 14 Apple silicon) * [Stack-chan RT ver.](https://rt-net.jp/products/rt-stackchan/) or its compatible product * USB type-C cable -* [git](https://git-scm.com/) -* [Node.js](https://nodejs.org/en/) - * As for the mod for cherrup_ble_lite, you need to use V18.x.x as it does not support the new Node.js. - * I've confirmed that other mods work with v22.8.x. -* The operation has been confirmed with Python 3.12. (Please download and install macOS from https://www.python.org instead of installing it with brew.)) -* xcode-select (macOS only) +* Tools + * [cmake](https://cmake.org/) + * [git](https://git-scm.com/) + * [Node.js](https://nodejs.org/en/) + * As for the mod for cherrup_ble_lite, you need to use V18.x.x as it does not support the new Node.js. + * I've confirmed that other mods work with v22.8.x. + * The operation has been confirmed with Python 3.12. (Please download and install macOS from https://www.python.org instead of installing it with brew.)) + * xcode-select (macOS only) ## Clone the Stack-chan repository and install the module on node @@ -38,9 +40,13 @@ There are two ways to do this. - Set up manually ### Using xs-dev(CLI) (recommended) -Stack-chan has npm scripted setup instructions. In the stack-chan/firmware directory, run the following command: +Stack-chan has npm scripted setup instructions. + +In the `stack-chan/firmware` directory, run the following command: + Immediately after executing the first command shown below, you will be asked to enter the password set in Ubuntu. After entering the password, the password will not be requested even if the same command is executed for a certain period of time. + For the second command, run it before you are prompted for a password again. If, for some reason, it takes a long time to execute the first command, please start over from the execution of the first command. ```console @@ -58,12 +64,29 @@ Add source ~/.local/share/xs-dev-export.sh to ~/.bashrc or ~/.zshrc. The script internally uses [`xs-dev`](https://github.com/HipsterBrown/xs-dev) to automate the setup of ModdableSDK and ESP-IDF. -### Set up Manual +## Set up Manual Follow the instructions on the [official website (English)](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/Moddable%20SDK%20-%20Getting%20Started.md) to install ModdableSDK and ESP-IDF. If you cannot setup xs-dev(CLI) properly, please do this. -**Stack-chan RT version assumes that Moddable SDK 4.9.5 and ESP-IDF 5.3.0 will work. I have confirmed that intel mac works with Moddable SDK 4.7.0 + ESP-IDF 5.1.0 python 3.9.0. To use it on Intel Macs, you can install it by changing "setup": "xs-dev setup --target-branch 4.9.5" to "setup": "xs-dev setup --target-branch 4.7.0" in firmware/package.json, but it is not supported.** +- **Stack-chan RT version assumes that Moddable SDK 4.9.5 and ESP-IDF 5.3.0 will work.** +- **We have confirmed that intel mac works with Moddable SDK 4.7.0 + ESP-IDF 5.1.0 python 3.9.0. To use it on Intel Macs, you can install it by changing "setup": "xs-dev setup --target-branch 4.9.5" to "setup": "xs-dev setup --target-branch 4.7.0" in firmware/package.json, but it is not supported.** + +## Set up PSRAM and Environment Variable + +To configure the PSRAM settings, execute the following command. + +```console +$ ./setting_scripts/unset_psram.sh +``` + +Next, run the following command to automatically add source `~/.local/share/xs-dev-export.sh` to your shell's configuration file. This ensures that the necessary environment variables are set each time the shell is started. + +```console +$ ./setting_scripts/set_xs-dev_env.sh +``` + +By completing these steps, your shell environment will be configured correctly for the Moddable SDK and ESP-IDF. ## Test the environment @@ -91,6 +114,15 @@ xs-dev environment info: ESP32 IDF Directory /home/ubuntu/.local/share/esp32/esp-idf ``` + +You can check the PARAM settings for the M5Stack CoreS3 with the `grep CONFIG_SPIRAM= $MODDABLE/build/devices/esp32/targets/m5stack_cores3/sdkconfig/sdkconfig.defaults` command. +If the setting are correctly, `CONFIG_SPIRAM=n` will be displayed + +```console +$ grep CONFIG_SPIRAM= $MODDABLE/build/devices/esp32/targets/m5stack_cores3/sdkconfig/sdkconfig.defaults +CONFIG_SPIRAM=n +``` + ## Next step - [Build and Flash firmware](./flashing-firmware.md) diff --git a/firmware/docs/getting-started_ja.md b/firmware/docs/getting-started_ja.md index da5df05..9ea2c58 100644 --- a/firmware/docs/getting-started_ja.md +++ b/firmware/docs/getting-started_ja.md @@ -14,6 +14,7 @@ * [スタックチャン アールティver.](https://rt-net.jp/products/rt-stackchan/) または その互換品 * USB type-Cケーブル * 事前にインストールしておくアプリ + * [cmake](https://cmake.org/) * [git](https://git-scm.com/) * [Node.js](https://nodejs.org/en/) * cherrup_ble_liteのmodに関しては、新しいNode.jsに対応していないためV18.x.xを使用する必要があります。 @@ -42,29 +43,43 @@ $ npm install スタックチャンはセットアップ手順をnpmスクリプト化しています。 `stack-chan/firmware`ディレクトリで次のコマンドを実行します。 -以下に示す1つ目のコマンドの実行直後、Ubuntuに設定したパスワードの入力が要求されますので入力してください。 パスワード入力後、一定時間は同様のコマンドを実行してもパスワードは要求されません。 2つ目のコマンドでは、再度パスワードが要求されない内に実行してください。 もし、何らかの理由で1つめのコマンド実行から時間がかかってしまった場合は1つ目のコマンドの実行からやり直してください。 + +以下に示す1つ目のコマンドの実行直後、Ubuntuに設定したパスワードの入力が要求されますので入力してください。 パスワード入力後、一定時間は同様のコマンドを実行してもパスワードは要求されません。 + +2つ目のコマンドでは、再度パスワードが要求されない内に実行してください。 もし、何らかの理由で1つめのコマンド実行から時間がかかってしまった場合は1つ目のコマンドの実行からやり直してください。 ```console $ sudo echo "emporary SuperUser Grant" $ npm run setup $ npm run setup -- --device=esp32 ``` -macOSの場合は、npm run setup -- --device=esp32のインストールの時、xcode-selectのバージョンが古いと"Error: Command failed with exit code 1: python3 -m pip install pyserial"で止まることがあります。その場合は、xcode-selectを手動で削除してから再度xcode-select(xcord-select –install)をインストールしてください。 + +macOSの場合は、npm run setup -- --device=esp32のインストールの時、xcode-selectのバージョンが古いと"Error: Command failed with exit code 1: python3 -m pip install pyserial"で止まることがあります。その場合は、xcode-selectを手動で削除してから再度xcode-select(xcord-select –install)をインストールしてください。 xcode-selectの削除は"sudo rm -rf /Library/Developer/CommandLineTools"でできます。 内部で[`xs-dev`](https://github.com/HipsterBrown/xs-dev)を使ってModdableSDKやESP-IDFのセットアップを自動化しています。 -moddableの環境設定スクリプト xs-dev-export.sh がターミナル起動時に自動で読み込まれません。~/.bashrcや ~/.zshrcに -source ~/.local/share/xs-dev-export.sh -を追加してください。 ### 手動でセットアップする [公式サイトの手順(英語)](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/Moddable%20SDK%20-%20Getting%20Started.md)に従ってModdableSDKとESP-IDFをインストールします。 xs-dev(CLI)でうまくセットアップできない場合はこちらを行ってください。 -**スタックチャン アールティver.では、Moddable SDK 4.9.5、ESP-IDF 5.3.0 での動作を想定しています。** -**intel macはModdable SDK 4.7.0 + ESP-IDF 5.1.0 python3.9.0で動作することは確認しています。intel macで使用するにはfirmware/package.jsonの"setup": "xs-dev setup --target-branch 4.9.5"を"setup": "xs-dev setup --target-branch 4.7.0"にすることでインストールできますがサポート対象外になります。** +- **スタックチャン アールティver.では、Moddable SDK 4.9.5、ESP-IDF 5.3.0 での動作を想定しています。** +- **intel macはModdable SDK 4.7.0 + ESP-IDF 5.1.0 python3.9.0で動作することは確認しています。intel macで使用するには`firmware/package.json`の`"setup": "xs-dev setup --target-branch 4.9.5"`を`"setup": "xs-dev setup --target-branch 4.7.0"`にすることでインストールできますがサポート対象外になります。** + +### PSRAMと環境変数のセットアップ + +次のコマンドを実行して、PSRAMの設定をします。 + +```console +$ ./setting_scripts/unset_psram.sh +``` +次のコマンドを実行し、Shellの設定ファイルに`source ~/.local/share/xs-dev-export.sh`を追加します。これにより、Shellの起動時に環境変数を設定されます。 + +```console +$ ./setting_scripts/set_xs-dev_env.sh +``` ## 環境のテスト @@ -92,6 +107,14 @@ xs-dev environment info: ESP32 IDF Directory /home/ubuntu/.local/share/esp32/esp-idf ``` +`grep CONFIG_SPIRAM= $MODDABLE/build/devices/esp32/targets/m5stack_cores3/sdkconfig/sdkconfig.defaults`コマンドでM5Stack CoreS3のPARAMの設定を確認できます。 +設定が完了していれば、`CONFIG_SPIRAM=n`と出力されます。 + +```console +$ grep CONFIG_SPIRAM= $MODDABLE/build/devices/esp32/targets/m5stack_cores3/sdkconfig/sdkconfig.defaults +CONFIG_SPIRAM=n +``` + ## 次のステップ - [プログラムのビルドと書き込み](./flashing-firmware_ja.md) diff --git a/firmware/docs/images/getting-started-wsl2_ja/grep_config_spiram.jpg b/firmware/docs/images/getting-started-wsl2_ja/grep_config_spiram.jpg new file mode 100644 index 0000000..835d9de Binary files /dev/null and b/firmware/docs/images/getting-started-wsl2_ja/grep_config_spiram.jpg differ diff --git a/firmware/docs/images/getting-started-wsl2_ja/set_xs-dev_env.jpg b/firmware/docs/images/getting-started-wsl2_ja/set_xs-dev_env.jpg new file mode 100644 index 0000000..b864801 Binary files /dev/null and b/firmware/docs/images/getting-started-wsl2_ja/set_xs-dev_env.jpg differ diff --git a/firmware/docs/images/getting-started-wsl2_ja/unset_psram.jpg b/firmware/docs/images/getting-started-wsl2_ja/unset_psram.jpg new file mode 100644 index 0000000..e14b366 Binary files /dev/null and b/firmware/docs/images/getting-started-wsl2_ja/unset_psram.jpg differ diff --git a/firmware/setting_scripts/set_xs-dev_env.sh b/firmware/setting_scripts/set_xs-dev_env.sh new file mode 100755 index 0000000..26663b1 --- /dev/null +++ b/firmware/setting_scripts/set_xs-dev_env.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# 追記するコマンドを設定 +XS_DEV_SH="source ~/.local/share/xs-dev-export.sh" + +# 現在のシェルを取得 +CURRENT_SHELL=$(basename "$SHELL") + +# 設定ファイルを決定 +if [ "$CURRENT_SHELL" = "bash" ]; then + CONFIG_FILE="$HOME/.bashrc" +elif [ "$CURRENT_SHELL" = "zsh" ]; then + CONFIG_FILE="$HOME/.zshrc" +else + echo "Unsupported shell: $CURRENT_SHELL" + exit 1 +fi + +# 設定ファイルが存在しない場合は作成 +if [ ! -f "$CONFIG_FILE" ]; then + touch "$CONFIG_FILE" + echo "# Created $CONFIG_FILE for $CURRENT_SHELL settings" >> "$CONFIG_FILE" + echo "$CONFIG_FILE was created." +fi + +# ファイルに追記 +if grep -Fxq "$XS_DEV_SH" "$CONFIG_FILE"; then + echo "The string '$XS_DEV_SH' already exists in $CONFIG_FILE. No changes made." +else + echo "$XS_DEV_SH" >> "$CONFIG_FILE" + echo "The string '$XS_DEV_SH' has been added to $CONFIG_FILE." +fi \ No newline at end of file diff --git a/firmware/setting_scripts/unset_psram.sh b/firmware/setting_scripts/unset_psram.sh new file mode 100755 index 0000000..df038c5 --- /dev/null +++ b/firmware/setting_scripts/unset_psram.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# 設定ファイルパスを取得 +SDKCONFIG="$HOME/.local/share/moddable/build/devices/esp32/targets/m5stack_cores3/sdkconfig/sdkconfig.defaults" + +# macOS と Linux の sed コマンドの互換性を考慮 +if [ "$(uname)" = "Darwin" ]; then + # macOS 用 + sed -i '' 's/CONFIG_SPIRAM=y/CONFIG_SPIRAM=n/' "$SDKCONFIG" +else + # Linux 用 + sed -i 's/CONFIG_SPIRAM=y/CONFIG_SPIRAM=n/' "$SDKCONFIG" +fi + +# 結果を表示 +cat "$SDKCONFIG"