目次
ESP32 Rust 開発環境のインストール
本家: The Rust on ESP Book 翻訳
ソースコード: esp-rs/book: The Rust on ESP Book
Rust のインストール
Rust 関連 - インストール
Rust 関連 - Rust の更新 も参照…🤔
Fedora での手順
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
info: downloading installer Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. Rustup metadata and toolchains will be installed into the Rustup home directory, located at: /home/tomoyan/.rustup This can be modified with the RUSTUP_HOME environment variable. The Cargo home directory is located at: /home/tomoyan/.cargo This can be modified with the CARGO_HOME environment variable. The cargo, rustc, rustup and other commands will be added to Cargo's bin directory, located at: /home/tomoyan/.cargo/bin This path will then be added to your PATH environment variable by modifying the profile files located at: /home/tomoyan/.profile /home/tomoyan/.bash_profile /home/tomoyan/.bashrc You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable (default) profile: default modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation > Enter で続行 info: profile set to 'default' info: default host triple is x86_64-unknown-linux-gnu info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: latest update on 2022-12-15, rust version 1.66.0 (69f9c33d7 2022-12-12) info: downloading component 'cargo' 6.5 MiB / 6.5 MiB (100 %) 1.2 MiB/s in 5s ETA: 0s info: downloading component 'clippy' 2.9 MiB / 2.9 MiB (100 %) 2.3 MiB/s in 1s ETA: 0s info: downloading component 'rust-docs' 19.0 MiB / 19.0 MiB (100 %) 1.7 MiB/s in 12s ETA: 0s info: downloading component 'rust-std' 29.7 MiB / 29.7 MiB (100 %) 1.9 MiB/s in 17s ETA: 0s info: downloading component 'rustc' 68.0 MiB / 68.0 MiB (100 %) 1.5 MiB/s in 45s ETA: 0s info: downloading component 'rustfmt' 4.4 MiB / 4.4 MiB (100 %) 1.0 MiB/s in 4s ETA: 0s info: installing component 'cargo' info: installing component 'clippy' info: installing component 'rust-docs' 19.0 MiB / 19.0 MiB (100 %) 5.5 MiB/s in 3s ETA: 0s info: installing component 'rust-std' 29.7 MiB / 29.7 MiB (100 %) 8.6 MiB/s in 3s ETA: 0s info: installing component 'rustc' 68.0 MiB / 68.0 MiB (100 %) 9.0 MiB/s in 7s ETA: 0s info: installing component 'rustfmt' info: default toolchain set to 'stable-x86_64-unknown-linux-gnu' stable-x86_64-unknown-linux-gnu installed - rustc 1.66.0 (69f9c33d7 2022-12-12) Rust is installed now. Great! To get started you may need to restart your current shell. This would reload your PATH environment variable to include Cargo's bin directory ($HOME/.cargo/bin). To configure your current shell, run: source "$HOME/.cargo/env"
$ echo 'source $HOME/.cargo/env' >> ~/.bashrc $ . ~/.bashrc $ rustup --version
rustup 1.27.0 (bbb9276d2 2024-03-08) info: This is the version for the rustup toolchain manager, not the rustc compiler. info: The currently active `rustc` version is `rustc 1.77.2 (25ef9e3d8 2024-04-09)`
$ rustc --version
rustc 1.77.2 (25ef9e3d8 2024-04-09)
$ cargo --version
cargo 1.77.2 (e52e36006 2024-03-26)
$ which rustup rustc cargo
~/.cargo/bin/rustup ~/.cargo/bin/rustc ~/.cargo/bin/cargo
espup のインストール
依存パッケージのインストール
参考: Linux - GitHub - esp-rs/espup: Tool for installing and maintaining ESP Rust ecosystem. 翻訳
Fedora での手順
$ sudo dnf install -y git python3 python3-pip perl gcc systemd-devel
メタデータの期限切れの最終確認: 0:57:25 前の 2024年05月06日 07時28分16秒 に実施しました。 依存関係が解決しました。 ============================================================================================================== パッケージ アーキテクチャー バージョン リポジトリー サイズ ============================================================================================================== インストール: gcc x86_64 14.0.1-0.15.fc40 fedora 37 M git x86_64 2.45.0-1.fc40 updates 53 k perl x86_64 4:5.38.2-506.fc40 fedora 14 k python3 x86_64 3.12.3-2.fc40 updates 27 k python3-pip noarch 23.3.2-1.fc40 fedora 3.2 M systemd-devel x86_64 255.4-1.fc40 fedora 651 k トランザクションの概要 ============================================================================================================== ダウンロードサイズの合計: 41 M インストール後のサイズ: 119 M パッケージのダウンロード: (1/6): perl-5.38.2-506.fc40.x86_64.rpm 33 kB/s | 14 kB 00:00 (2/6): python3-pip-23.3.2-1.fc40.noarch.rpm 1.7 MB/s | 3.2 MB 00:01 (3/6): git-2.45.0-1.fc40.x86_64.rpm 13 kB/s | 53 kB 00:03 (4/6): systemd-devel-255.4-1.fc40.x86_64.rpm 114 kB/s | 651 kB 00:05 (5/6): python3-3.12.3-2.fc40.x86_64.rpm 6.1 kB/s | 27 kB 00:04 (6/6): gcc-14.0.1-0.15.fc40.x86_64.rpm 2.7 MB/s | 37 MB 00:13 -------------------------------------------------------------------------------------------------------------- 合計 2.6 MB/s | 41 MB 00:15 トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中 準備 : 1/1 インストール中 : python3-3.12.3-2.fc40.x86_64 1/12 インストール中 : python3-pip-23.3.2-1.fc40.noarch 2/12 インストール中 : git-2.45.0-1.fc40.x86_64 3/12 インストール中 : systemd-devel-255.4-1.fc40.x86_64 4/12 インストール中 : perl-4:5.38.2-506.fc40.x86_64 5/12 インストール中 : gcc-14.0.1-0.15.fc40.x86_64 6/12 scriptletの実行中: gcc-14.0.1-0.15.fc40.x86_64 6/12 整理 : python3-pip-23.3.2-1.fc40.noarch 7/12 整理 : git-2.45.0-1.fc40.x86_64 8/12 整理 : systemd-devel-255.4-1.fc40.x86_64 9/12 整理 : perl-4:5.38.2-506.fc40.x86_64 10/12 整理 : python3-3.12.3-2.fc40.x86_64 11/12 整理 : gcc-14.0.1-0.15.fc40.x86_64 12/12 scriptletの実行中: gcc-14.0.1-0.15.fc40.x86_64 12/12 インストール済み: gcc-14.0.1-0.15.fc40.x86_64 git-2.45.0-1.fc40.x86_64 perl-4:5.38.2-506.fc40.x86_64 python3-3.12.3-2.fc40.x86_64 python3-pip-23.3.2-1.fc40.noarch systemd-devel-255.4-1.fc40.x86_64 完了しました!
Ubuntu/Debian
$ sudo apt install -y gcc build-essential curl pkg-config
Reading package lists... Done Building dependency tree... Done Reading state information... Done gcc is already the newest version (4:12.2.0-3+rpi1). build-essential is already the newest version (12.9). curl is already the newest version (7.88.1-10+rpi1+deb12u5). pkg-config is already the newest version (1.8.1-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
espup のインストール
公式: 1. Install espup - RISC-V and Xtensa targets - The Rust on ESP Book 翻訳
公式: Installation - GitHub - esp-rs/espup: Tool for installing and maintaining ESP Rust ecosystem. 翻訳
cargo でビルドせずにバイナリをインストールする場合🤔
$ curl -L https://github.com/esp-rs/espup/releases/latest/download/espup-x86_64-unknown-linux-gnu -o ~/.cargo/bin/espup
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 100 10.2M 100 10.2M 0 0 672k 0 0:00:15 0:00:15 --:--:-- 1003k
$ chmod a+x ~/.cargo/bin/espup
または、cargo でビルドを行ってインストールする🤔
$ cargo install espup
Updating crates.io index Downloaded espup v0.11.0 Downloaded 1 crate (44.6 KB) in 0.52s Installing espup v0.11.0 Updating crates.io index Downloaded anstream v0.6.14 Downloaded autocfg v1.3.0 Downloaded anstyle-query v1.0.3 Downloaded anstyle-parse v0.2.4 Downloaded anstyle v1.0.7 Downloaded base64 v0.21.7 Downloaded async-trait v0.1.80 Downloaded aes v0.8.4 Downloaded bytes v1.6.0 Downloaded clap_complete v4.5.2 Downloaded flate2 v1.0.30 Downloaded rustls-pki-types v1.5.0 Downloaded is_terminal_polyfill v1.70.0 Downloaded sync_wrapper v0.1.2 Downloaded colorchoice v1.0.1 Downloaded try-lock v0.2.5 Downloaded strum v0.26.2 Downloaded http-body v0.4.6 Downloaded supports-unicode v2.1.0 Downloaded rustversion v1.0.15 Downloaded base64 v0.22.1 Downloaded strum_macros v0.26.2 Downloaded pin-project-internal v1.1.5 Downloaded socket2 v0.5.7 Downloaded pin-project v1.1.5 Downloaded http v0.2.12 Downloaded ureq v2.9.7 Downloaded tokio-util v0.7.11 Downloaded h2 v0.3.26 Downloaded reqwest v0.11.27 Downloaded hyper v0.14.28 Downloaded rustls-webpki v0.102.3 Downloaded rustls v0.21.12 Downloaded webpki-roots v0.25.4 Downloaded webpki-roots v0.26.1 Downloaded openssl v0.10.64 Downloaded rustls v0.22.4 Downloaded zstd-sys v2.0.10+zstd.1.5.6 Downloaded tokio v1.37.0 Downloaded encoding_rs v0.8.34 Downloaded ring v0.17.8 Downloaded openssl-src v300.2.3+3.2.1 Downloaded 42 crates (20.0 MB) in 8.51s (largest was `openssl-src` at 9.6 MB) Compiling libc v0.2.154 Compiling once_cell v1.19.0 Compiling cfg-if v1.0.0 Compiling proc-macro2 v1.0.81 Compiling unicode-ident v1.0.12 Compiling pkg-config v0.3.30 Compiling autocfg v1.3.0 Compiling memchr v2.7.2 Compiling jobserver v0.1.31 Compiling quote v1.0.36 Compiling typenum v1.17.0 Compiling cc v1.0.96 Compiling syn v2.0.60 Compiling version_check v0.9.4 Compiling getrandom v0.2.14 Compiling generic-array v0.14.7 Compiling lock_api v0.4.12 Compiling pin-project-lite v0.2.14 Compiling parking_lot_core v0.9.10 Compiling itoa v1.0.11 Compiling log v0.4.21 Compiling openssl-src v300.2.3+3.2.1 Compiling vcpkg v0.2.15 Compiling bytes v1.6.0 Compiling smallvec v1.13.2 Compiling subtle v2.5.0 Compiling scopeguard v1.2.0 Compiling openssl-sys v0.9.102 Compiling bitflags v2.5.0 Compiling parking_lot v0.12.2 Compiling crypto-common v0.1.6 Compiling num_cpus v1.16.0 Compiling signal-hook-registry v1.4.2 Compiling socket2 v0.5.7 Compiling mio v0.8.11 Compiling adler v1.0.2 Compiling miniz_oxide v0.7.2 Compiling ring v0.17.8 Compiling tokio-macros v2.2.0 Compiling rand_core v0.6.4 Compiling slab v0.4.9 Compiling serde v1.0.200 Compiling futures-core v0.3.30 Compiling tinyvec_macros v0.1.1 Compiling tinyvec v1.6.0 Compiling tokio v1.37.0 Compiling serde_derive v1.0.200 Compiling zstd-sys v2.0.10+zstd.1.5.6 Compiling block-buffer v0.10.4 Compiling crc32fast v1.4.0 Compiling openssl v0.10.64 Compiling foreign-types-shared v0.1.1 Compiling utf8parse v0.2.1 Compiling fnv v1.0.7 Compiling percent-encoding v2.3.1 Compiling form_urlencoded v1.2.1 Compiling http v0.2.12 Compiling anstyle-parse v0.2.4 Compiling foreign-types v0.3.2 Compiling digest v0.10.7 Compiling unicode-normalization v0.1.23 Compiling openssl-macros v0.1.1 Compiling tracing-core v0.1.32 Compiling futures-sink v0.3.30 Compiling rustix v0.38.34 Compiling cpufeatures v0.2.12 Compiling unicode-bidi v0.3.15 Compiling colorchoice v1.0.1 Compiling rustls-pki-types v1.5.0 Compiling untrusted v0.9.0 Compiling anstyle-query v1.0.3 Compiling is_terminal_polyfill v1.70.0 Compiling futures-io v0.3.30 Compiling anstyle v1.0.7 Compiling native-tls v0.2.11 Compiling ryu v1.0.17 Compiling equivalent v1.0.1 Compiling futures-task v0.3.30 Compiling pin-utils v0.1.0 Compiling spin v0.9.8 Compiling httparse v1.8.0 Compiling hashbrown v0.14.5 Compiling indexmap v2.2.6 Compiling futures-util v0.3.30 Compiling anstream v0.6.14 Compiling idna v0.5.0 Compiling tracing v0.1.40 Compiling tokio-util v0.7.11 Compiling backtrace v0.3.71 Compiling bzip2-sys v0.1.11+1.0.8 Compiling is-terminal v0.4.12 Compiling aho-corasick v1.1.3 Compiling rustls v0.22.4 Compiling rustversion v1.0.15 Compiling regex-syntax v0.8.3 Compiling linux-raw-sys v0.4.13 Compiling openssl-probe v0.1.5 Compiling serde_json v1.0.116 Compiling gimli v0.28.1 Compiling zstd-safe v5.0.2+zstd.1.5.2 Compiling ppv-lite86 v0.2.17 Compiling try-lock v0.2.5 Compiling want v0.3.1 Compiling rand_chacha v0.3.1 Compiling addr2line v0.21.0 Compiling regex-automata v0.4.6 Compiling flate2 v1.0.30 Compiling h2 v0.3.26 Compiling url v2.5.0 Compiling rustls-webpki v0.102.3 Compiling http-body v0.4.6 Compiling futures-channel v0.3.30 Compiling lzma-sys v0.1.20 Compiling inout v0.1.3 Compiling object v0.32.2 Compiling heck v0.5.0 Compiling zeroize v1.7.0 Compiling httpdate v1.0.3 Compiling option-ext v0.2.0 Compiling unicode-width v0.1.12 Compiling thiserror v1.0.59 Compiling tower-service v0.3.2 Compiling powerfmt v0.2.0 Compiling rustc-demangle v0.1.23 Compiling strsim v0.11.1 Compiling clap_lex v0.7.0 Compiling semver v1.0.22 Compiling base64ct v1.6.0 Compiling password-hash v0.4.2 Compiling clap_builder v4.5.2 Compiling deranged v0.3.11 Compiling hyper v0.14.28 Compiling dirs-sys v0.4.1 Compiling clap_derive v4.5.4 Compiling cipher v0.4.4 Compiling regex v1.10.4 Compiling rand v0.8.5 Compiling webpki-roots v0.26.1 Compiling sha2 v0.10.8 Compiling hmac v0.12.1 Compiling thiserror-impl v1.0.59 Compiling pin-project-internal v1.1.5 Compiling time-core v0.1.2 Compiling is_ci v1.2.0 Compiling unicode-linebreak v0.1.5 Compiling heck v0.4.1 Compiling base64 v0.22.1 Compiling num-conv v0.1.0 Compiling smawk v0.3.2 Compiling base64 v0.21.7 Compiling textwrap v0.15.2 Compiling rustls-pemfile v1.0.4 Compiling ureq v2.9.7 Compiling time v0.3.36 Compiling strum_macros v0.26.2 Compiling supports-color v2.1.0 Compiling pin-project v1.1.5 Compiling pbkdf2 v0.11.0 Compiling bzip2 v0.4.4 Compiling env_filter v0.1.0 Compiling aes v0.8.4 Compiling clap v4.5.4 Compiling directories v5.0.1 Compiling backtrace-ext v0.2.1 Compiling xattr v1.3.1 Compiling supports-unicode v2.1.0 Compiling supports-hyperlinks v2.1.0 Compiling serde_urlencoded v0.7.1 Compiling sha1 v0.10.6 Compiling miette-derive v5.10.0 Compiling terminal_size v0.1.17 Compiling filetime v0.2.23 Compiling errno v0.2.8 Compiling encoding_rs v0.8.34 Compiling mime v0.3.17 Compiling fastrand v2.1.0 Compiling byteorder v1.5.0 Compiling humantime v2.1.0 Compiling ipnet v2.9.0 Compiling constant_time_eq v0.1.5 Compiling lazy_static v1.4.0 Compiling owo-colors v3.5.0 Compiling sync_wrapper v0.1.2 Compiling console v0.15.8 Compiling miette v5.10.0 Compiling env_logger v0.11.3 Compiling tempfile v3.10.1 Compiling zstd v0.11.2+zstd.1.5.2 Compiling guess_host_triple v0.1.3 Compiling zip v0.6.6 Compiling tar v0.4.40 Compiling update-informer v1.1.0 Compiling clap_complete v4.5.2 Compiling xz2 v0.1.7 Compiling tokio-retry v0.3.0 Compiling strum v0.26.2 Compiling retry v2.0.0 Compiling async-trait v0.1.80 Compiling tokio-native-tls v0.3.1 Compiling hyper-tls v0.5.0 Compiling reqwest v0.11.27 Compiling espup v0.11.0 Finished release [optimized] target(s) in 6m 34s Replacing /home/tomoyan/.cargo/bin/espup Replaced package `espup v0.5.0` with `espup v0.11.0` (executable `espup`)
動作確認する😉
$ espup --version
espup 0.12.2
ツールチェーンのインストール
Fedora
$ espup install
[info]: Installing the Espressif Rust ecosystem [info]: Checking Rust installation [info]: Installing RISC-V Rust targets ('riscv32imc-unknown-none-elf', 'riscv32imac-unknown-none-elf' and 'riscv32imafc-unknown-none-elf') for 'nightly' toolchain [info]: Installing GCC (xtensa-esp-elf) [info]: Installing Xtensa LLVM [info]: Downloading 'idf_tool_xtensa_elf_clang.tar.xz' [info]: Downloading 'xtensa-esp-elf.tar.xz' [info]: Uninstalling Xtensa Rust toolchain [info]: Installing Xtensa Rust 1.77.0.0 toolchain [info]: Downloading 'rust.tar.xz' [info]: Creating symlink between '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-16.0.4-20231113/esp-clang/lib' and '/home/tomoyan/.espup/esp-clang' [info]: Installing 'rust' component for Xtensa Rust toolchain [info]: Downloading 'rust-src.tar.xz' [info]: Installing 'rust-src' component for Xtensa Rust toolchain [info]: Installation successfully completed! To get started, you need to set up some environment variables by running: '. /home/tomoyan/export-esp.sh' This step must be done every time you open a new terminal. See other methods for setting the environment in https://esp-rs.github.io/book/installation/riscv-and-xtensa.html#3-set-up-the-environment-variables
esp ツールチェーンのコンパイラバージョンを確認する😉
$ rustup run esp rustc -V
rustc 1.77.0-nightly (424037dcb 2024-03-18) (1.77.0.0)
DietPi😢
$ espup install
[2023-08-18T00:00:25Z INFO ] 💽 Installing the Espressif Rust ecosystem [2023-08-18T00:00:25Z WARN ] uname returned unrecognised machine "armv6l" [2023-08-18T00:00:25Z WARN ] Could not guess triple for (Unknown, Little, Linux) thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/dietpi/.cargo/registry/src/index.crates.io-1cd66030c949c28d/espup-0.5.0/src/host_triple.rs:37:29 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
バージョン指定して古いツールチェーンをインストールしたい場合
$ espup install --toolchain-version 1.67.0.0
[info]: Installing the Espressif Rust ecosystem [info]: Checking Rust installation [info]: Installing RISC-V Rust targets ('riscv32imc-unknown-none-elf', 'riscv32imac-unknown-none-elf' and 'riscv32imafc-unknown-none-elf') for 'nightly' toolchain [info]: Installing GCC (xtensa-esp-elf) [warn]: Previous installation of GCC exists in: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928'. Reusing this installation [warn]: Previous installation of LLVM exists in: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-15.0.0-20221201'. Reusing this installation [info]: Creating symlink between '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-15.0.0-20221201/esp-clang/lib' and '/home/tomoyan/.espup/esp-clang' [info]: Uninstalling Xtensa Rust toolchain [info]: Installing Xtensa Rust 1.67.0.0 toolchain [info]: Downloading 'rust.tar.xz' [info]: Installing 'rust' component for Xtensa Rust toolchain [info]: Downloading 'rust-src.tar.xz' [info]: Installing 'rust-src' component for Xtensa Rust toolchain [info]: Installation successfully completed! To get started, you need to set up some environment variables by running: '. /home/tomoyan/export-esp.sh' This step must be done every time you open a new terminal. See other methods for setting the environment in https://esp-rs.github.io/book/installation/riscv-and-xtensa.html#3-set-up-the-environment-variables
ツールチェーンは esp の名前でインストールされている🤔
$ rustup toolchain list
stable-x86_64-unknown-linux-gnu (default) nightly-x86_64-unknown-linux-gnu esp
esp ツールチェーンのコンパイラバージョンを確認する😉
$ rustup run esp rustc -V
rustc 1.67.0-nightly (725e31c21 2023-01-25)
環境変数の設定
Fedora
$ bat -p ~/export-esp.sh
export PATH="/home/tomoyan/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:$PATH" export LIBCLANG_PATH="/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-15.0.0-20221201/esp-clang/lib"
$ . ~/export-esp.sh
Z shell の場合
$ cat << EOF >> ~/.zshrc
# espup initialize . ~/export-esp.sh EOF
bash の場合
$ cat << EOF >> ~/.bashrc
# espup initialize
. ~/export-esp.sh
EOF
std アプリケーションの構築要件
公式: std Development Requirements - The Rust on ESP Book 翻訳
Fedora
$ python -VV
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 14.0.1 20240411 (Red Hat 14.0.1-0)]
$ git version
git version 2.45.0
$ cargo install ldproxy
Updating crates.io index Ignored package `ldproxy v0.3.3` is already installed, use --force to override
プロジェクトテンプレートの使用
公式: Generating Projects from Templates - The Rust on ESP Book 翻訳
公式: Installation - Cargo Generate Documentation 翻訳 も参照。
プロジェクトテンプレートより独自のプロジェクトを生成することで、起こり得るエラーを防いで時間を短縮できます。
cargo-generateのインストール or 更新
$ cargo install cargo-generate
Updating crates.io index Downloaded cargo-generate v0.22.0 Downloaded 1 crate (102.2 KB) in 0.66s Installing cargo-generate v0.22.0 Updating crates.io index Locking 219 packages to latest compatible versions Adding encode_unicode v0.3.6 (latest: v1.0.0) Adding faster-hex v0.9.0 (latest: v0.10.0) Adding generic-array v0.14.7 (latest: v1.1.0) Adding idna v0.5.0 (latest: v1.0.2) Adding linux-raw-sys v0.4.14 (latest: v0.6.5) Adding prodash v28.0.0 (latest: v29.0.0) Adding regex v1.10.6 (latest: v1.11.0) Adding tempfile v3.10.1 (latest: v3.13.0) Adding unicode-width v0.1.14 (latest: v0.2.0) Adding wasi v0.11.0+wasi-snapshot-preview1 (latest: v0.13.3+wasi-0.2.2) Adding windows-sys v0.48.0 (latest: v0.59.0) Adding windows-sys v0.52.0 (latest: v0.59.0) Adding windows-targets v0.48.5 (latest: v0.52.6) Adding windows_aarch64_gnullvm v0.48.5 (latest: v0.52.6) Adding windows_aarch64_msvc v0.48.5 (latest: v0.52.6) Adding windows_i686_gnu v0.48.5 (latest: v0.52.6) Adding windows_i686_msvc v0.48.5 (latest: v0.52.6) Adding windows_x86_64_gnu v0.48.5 (latest: v0.52.6) Adding windows_x86_64_gnullvm v0.48.5 (latest: v0.52.6) Adding windows_x86_64_msvc v0.48.5 (latest: v0.52.6) Adding zerocopy v0.7.35 (latest: v0.8.6) Adding zerocopy-derive v0.7.35 (latest: v0.8.6) Downloaded anstream v0.6.15 Downloaded anstyle-query v1.1.1 Downloaded cfg_aliases v0.2.1 Downloaded zeroize v1.8.1 Downloaded is_terminal_polyfill v1.70.1 Downloaded anstyle v1.0.8 Downloaded colorchoice v1.0.2 Downloaded anstyle-parse v0.2.5 Downloaded gix-glob v0.16.5 Downloaded gix-actor v0.32.0 Downloaded env_filter v0.1.2 Downloaded cpufeatures v0.2.14 Downloaded autocfg v1.4.0 Downloaded auth-git2 v0.5.5 Downloaded anyhow v1.0.90 Downloaded clap_lex v0.7.2 Downloaded gix-lock v14.0.0 Downloaded fastrand v2.1.1 Downloaded either v1.13.0 Downloaded gix-fs v0.11.3 Downloaded gix-date v0.9.0 Downloaded lazy_static v1.5.0 Downloaded liquid v0.26.9 Downloaded gix-sec v0.10.8 Downloaded gix-trace v0.1.10 Downloaded gix-path v0.10.11 Downloaded normpath v1.3.0 Downloaded gix-tempfile v14.0.2 Downloaded gix-validate v0.9.0 Downloaded gix-features v0.38.2 Downloaded env_logger v0.11.5 Downloaded gix-config-value v0.14.8 Downloaded fs_at v0.2.1 Downloaded clap_derive v4.5.18 Downloaded ppv-lite86 v0.2.20 Downloaded bitflags v2.6.0 Downloaded pkg-config v0.3.31 Downloaded sha1_smol v1.0.1 Downloaded remove_dir_all v0.8.4 Downloaded version_check v0.9.5 Downloaded thiserror v1.0.64 Downloaded shlex v1.3.0 Downloaded serde_spanned v0.6.8 Downloaded thiserror-impl v1.0.64 Downloaded terminal_size v0.4.0 Downloaded liquid-derive v0.26.8 Downloaded jobserver v0.1.32 Downloaded memmap2 v0.9.5 Downloaded pest_derive v2.7.14 Downloaded pest_generator v2.7.14 Downloaded gix-object v0.44.0 Downloaded kstring v2.0.2 Downloaded clap v4.5.20 Downloaded toml_datetime v0.6.8 Downloaded quote v1.0.37 Downloaded once_cell v1.20.2 Downloaded rhai_codegen v2.2.0 Downloaded zerocopy-derive v0.7.35 Downloaded globset v0.4.15 Downloaded proc-macro2 v1.0.88 Downloaded pest_meta v2.7.14 Downloaded liquid-lib v0.26.9 Downloaded log v0.4.22 Downloaded unicode-ident v1.0.13 Downloaded tinyvec v1.8.0 Downloaded ucd-trie v0.1.7 Downloaded gix-config v0.40.0 Downloaded toml v0.8.19 Downloaded ignore v0.4.23 Downloaded openssl-sys v0.9.104 Downloaded gix-ref v0.47.0 Downloaded liquid-core v0.26.9 Downloaded serde_derive v1.0.210 Downloaded cc v1.1.31 Downloaded unicode-bidi v0.3.17 Downloaded indexmap v2.6.0 Downloaded serde v1.0.210 Downloaded url v2.5.2 Downloaded unicode-segmentation v1.12.0 Downloaded toml_edit v0.22.22 Downloaded hashbrown v0.15.0 Downloaded pest v2.7.14 Downloaded clap_builder v4.5.20 Downloaded zerocopy v0.7.35 Downloaded unicode-normalization v0.1.24 Downloaded winnow v0.6.20 Downloaded portable-atomic v1.9.0 Downloaded git2 v0.19.0 Downloaded regex v1.10.6 Downloaded unicode-width v0.1.14 Downloaded syn v2.0.80 Downloaded rhai v1.19.0 Downloaded nix v0.29.0 Downloaded regex-syntax v0.8.5 Downloaded bstr v1.10.0 Downloaded rustix v0.38.37 Downloaded jiff v0.1.13 Downloaded regex-automata v0.4.8 Downloaded libc v0.2.161 Downloaded libz-sys v1.1.20 Downloaded libgit2-sys v0.17.0+1.8.1 Downloaded 101 crates (11.0 MB) in 21.63s (largest was `libgit2-sys` at 1.8 MB) Compiling proc-macro2 v1.0.88 Compiling unicode-ident v1.0.13 Compiling libc v0.2.161 Compiling thiserror v1.0.64 Compiling memchr v2.7.4 Compiling autocfg v1.4.0 Compiling quote v1.0.37 Compiling aho-corasick v1.1.3 Compiling syn v2.0.80 Compiling regex-syntax v0.8.5 Compiling bitflags v2.6.0 Compiling cfg-if v1.0.0 Compiling tinyvec_macros v0.1.1 Compiling tinyvec v1.8.0 Compiling jobserver v0.1.32 Compiling regex-automata v0.4.8 Compiling shlex v1.3.0 Compiling cc v1.1.31 Compiling unicode-normalization v0.1.24 Compiling pkg-config v0.3.31 Compiling thiserror-impl v1.0.64 Compiling once_cell v1.20.2 Compiling fastrand v2.1.1 Compiling serde v1.0.210 Compiling vcpkg v0.2.15 Compiling serde_derive v1.0.210 Compiling bstr v1.10.0 Compiling rustix v0.38.37 Compiling same-file v1.0.6 Compiling linux-raw-sys v0.4.14 Compiling gix-trace v0.1.10 Compiling walkdir v2.5.0 Compiling gix-utils v0.1.12 Compiling faster-hex v0.9.0 Compiling itoa v1.0.11 Compiling gix-hash v0.14.2 Compiling openssl-sys v0.9.104 Compiling libz-sys v1.1.20 Compiling smallvec v1.13.2 Compiling prodash v28.0.0 Compiling sha1_smol v1.0.1 Compiling gix-features v0.38.2 Compiling zerocopy-derive v0.7.35 Compiling lock_api v0.4.12 Compiling ucd-trie v0.1.7 Compiling version_check v0.9.5 Compiling byteorder v1.5.0 Compiling crunchy v0.2.2 Compiling parking_lot_core v0.9.10 Compiling zerocopy v0.7.35 Compiling pest v2.7.14 Compiling libssh2-sys v0.3.0 Compiling regex v1.10.6 Compiling getrandom v0.2.15 Compiling num-traits v0.2.19 Compiling winnow v0.6.20 Compiling scopeguard v1.2.0 Compiling tiny-keccak v2.0.2 Compiling static_assertions v1.1.0 Compiling percent-encoding v2.3.1 Compiling log v0.4.22 Compiling pest_meta v2.7.14 Compiling tempfile v3.10.1 Compiling cfg_aliases v0.2.1 Compiling num-conv v0.1.0 Compiling jiff v0.1.13 Compiling crossbeam-utils v0.8.20 Compiling time-core v0.1.2 Compiling utf8parse v0.2.2 Compiling powerfmt v0.2.0 Compiling home v0.5.9 Compiling gix-path v0.10.11 Compiling deranged v0.3.11 Compiling anstyle-parse v0.2.5 Compiling time-macros v0.2.18 Compiling nix v0.29.0 Compiling parking_lot v0.12.3 Compiling pest_generator v2.7.14 Compiling gix-date v0.9.0 Compiling gix-fs v0.11.3 Compiling libgit2-sys v0.17.0+1.8.1 Compiling anstyle v1.0.8 Compiling anstyle-query v1.1.1 Compiling lazy_static v1.5.0 Compiling colorchoice v1.0.2 Compiling is_terminal_polyfill v1.70.1 Compiling unicode-bidi v0.3.17 Compiling either v1.13.0 Compiling idna v0.5.0 Compiling itertools v0.13.0 Compiling time v0.3.36 Compiling anstream v0.6.15 Compiling gix-tempfile v14.0.2 Compiling gix-actor v0.32.0 Compiling pest_derive v2.7.14 Compiling const-random-macro v0.1.16 Compiling form_urlencoded v1.2.1 Compiling kstring v2.0.2 Compiling rand_core v0.6.4 Compiling ppv-lite86 v0.2.20 Compiling ahash v0.8.11 Compiling smartstring v1.0.1 Compiling gix-validate v0.9.0 Compiling liquid-derive v0.26.8 Compiling unicode-width v0.1.14 Compiling equivalent v1.0.1 Compiling hashbrown v0.15.0 Compiling anymap2 v0.13.0 Compiling option-ext v0.2.0 Compiling portable-atomic v1.9.0 Compiling doc-comment v0.3.3 Compiling indexmap v2.6.0 Compiling liquid-core v0.26.9 Compiling dirs-sys v0.4.1 Compiling console v0.15.8 Compiling gix-object v0.44.0 Compiling rand_chacha v0.3.1 Compiling crossbeam-epoch v0.9.18 Compiling url v2.5.2 Compiling const-random v0.1.18 Compiling gix-lock v14.0.0 Compiling serde_spanned v0.6.8 Compiling toml_datetime v0.6.8 Compiling terminal_size v0.4.0 Compiling cvt v0.1.2 Compiling memmap2 v0.9.5 Compiling fs-err v2.11.0 Compiling names v0.14.0 Compiling heck v0.5.0 Compiling openssl-probe v0.1.5 Compiling anyhow v1.0.90 Compiling paste v1.0.15 Compiling strsim v0.11.1 Compiling semver v1.0.23 Compiling clap_lex v0.7.2 Compiling unicode-segmentation v1.12.0 Compiling clap_builder v4.5.20 Compiling liquid-lib v0.26.9 Compiling clap_derive v4.5.18 Compiling gix-ref v0.47.0 Compiling fs_at v0.2.1 Compiling toml_edit v0.22.22 Compiling crossbeam-deque v0.8.5 Compiling rand v0.8.5 Compiling dirs v5.0.1 Compiling gix-glob v0.16.5 Compiling gix-config-value v0.14.8 Compiling globset v0.4.15 Compiling env_filter v0.1.2 Compiling path-dedot v3.1.1 Compiling rhai_codegen v2.2.0 Compiling gix-sec v0.10.8 Compiling terminal-prompt v0.2.3 Compiling unicode-bom v2.0.3 Compiling zeroize v1.8.1 Compiling humantime v2.1.0 Compiling number_prefix v0.4.0 Compiling normpath v1.3.0 Compiling thin-vec v0.2.13 Compiling shell-words v1.1.0 Compiling dialoguer v0.11.0 Compiling rhai v1.19.0 Compiling remove_dir_all v0.8.4 Compiling indicatif v0.17.8 Compiling env_logger v0.11.5 Compiling gix-config v0.40.0 Compiling path-absolutize v3.1.1 Compiling ignore v0.4.23 Compiling toml v0.8.19 Compiling liquid v0.26.9 Compiling clap v4.5.20 Compiling sanitize-filename v0.5.0 Compiling git2 v0.19.0 Compiling auth-git2 v0.5.5 Compiling cargo-generate v0.22.0 Finished `release` profile [optimized] target(s) in 6m 11s Replacing /home/tomoyan/.cargo/bin/cargo-generate Replaced package `cargo-generate v0.20.0` with `cargo-generate v0.22.0` (executable `cargo-generate`)
動作確認
$ cargo generate -V
cargo generate-generate 0.22.0
プロジェクトの作成
- esp-template - no_std テンプレート
- esp-idf-template - std テンプレート
公式: Introduction - Cargo Generate Documentation
「お気に入り `esp-rs/esp-template` が設定に見つかりません。」と言われる場合🤔
$ cargo generate esp-rs/esp-template
⚠️ Favorite `esp-rs/esp-template` not found in config, using it as a git repository: https://github.com/esp-rs/esp-template.git 🤷 Project Name:
-g
または --git
オプションを使用して git の URL をフルで指定する🤔
$ cargo generate --git https://github.com/esp-rs/esp-template
🤷 Project Name:
または、予めテンプレートを clone してから…
$ git clone --depth 1 https://github.com/esp-rs/esp-template
Cloning into 'esp-template'... remote: Enumerating objects: 37, done. remote: Counting objects: 100% (37/37), done. remote: Compressing objects: 100% (32/32), done. remote: Total 37 (delta 1), reused 21 (delta 1), pack-reused 0 Receiving objects: 100% (37/37), 17.57 KiB | 148.00 KiB/s, done. Resolving deltas: 100% (1/1), done.
プロジェクトテンプレートからプロジェクトを作成する😉
$ cargo generate --path ./esp-template
no_std テンプレートの場合
公式: Generating using a local template - Cargo Generate Documentation 翻訳
ローカルテンプレートからプロジェクトを作成する🤔
$ git clone --depth 1 https://github.com/esp-rs/esp-template
Cloning into 'esp-template'... remote: Enumerating objects: 37, done. remote: Counting objects: 100% (37/37), done. remote: Compressing objects: 100% (32/32), done. remote: Total 37 (delta 1), reused 21 (delta 1), pack-reused 0 Receiving objects: 100% (37/37), 17.57 KiB | 148.00 KiB/s, done. Resolving deltas: 100% (1/1), done.
$ cargo generate --path ./esp-template
🤷 Project Name: haruo_nostd_esp32 ->プロジェクト名を入力して Enter
⚠️ Renaming project called `haruo_nostd_esp32` to `haruo-nostd-esp32`... 🔧 Destination: /home/tomoyan/my_projects/haruo-nostd-esp32 ... 🔧 project-name: haruo-nostd-esp32 ... 🔧 Generating template ...
? 🤷 Which MCU to target? › ❯ esp32 ->MCU を選択して Enter esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
✔ 🤷 Which MCU to target? · esp32
? 🤷 Configure advanced template options? › ❯ false ->Enter true
✔ 🤷 Configure advanced template options? · false 🔧 Moving generated files into: `/home/tomoyan/my_projects/haruo-nostd-esp32`... 🔧 Initializing a fresh Git repository ✨ Done! New project created /home/tomoyan/my_projects/haruo-nostd-esp32
std テンプレートの場合
公式: Generating using a local template - Cargo Generate Documentation 翻訳
ローカルテンプレートからプロジェクトを作成する🤔
$ git clone --depth 1 https://github.com/esp-rs/esp-idf-template
Cloning into 'esp-idf-template'... remote: Enumerating objects: 64, done. remote: Counting objects: 100% (64/64), done. remote: Compressing objects: 100% (53/53), done. remote: Total 64 (delta 8), reused 38 (delta 1), pack-reused 0 Receiving objects: 100% (64/64), 27.56 KiB | 4.59 MiB/s, done. Resolving deltas: 100% (8/8), done.
$ cargo generate --path ./esp-idf-template
? 🤷 Which template should be expanded? ›
❯ cargo ->Enter cmake
✔ 🤷 Which template should be expanded? · cargo
🤷 Project Name: haruo_eps32 ->プロジェクト名を入力して Enter
⚠️ Renaming project called `haruo_std_esp32` to `haruo_std_esp32`... 🔧 Destination: /home/tomoyan/my_projects/haruo_std_esp32 ... 🔧 project-name: haruo_std_esp32 ... 🔧 Generating template ... ? 🤷 Which MCU to target? ›
❯ esp32 ->MCU を選択して Enter esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
✔ 🤷 Which MCU to target? · esp32 ? 🤷 Configure advanced template options? ›
❯ false ->Enter true
✔ 🤷 Configure advanced template options? · false 🔧 Moving generated files into: `/home/tomoyan/my_projects/haruo_std_esp32`... 🔧 Initializing a fresh Git repository ✨ Done! New project created /home/tomoyan/my_projects/haruo_std_esp32
Cargo B(inary)Install のインストール
公式: GitHub - cargo-bins/cargo-binstall: Binary installation for rust projects 翻訳
$ cargo install cargo-binstall
Updating crates.io index Downloaded cargo-binstall v1.10.8 Downloaded 1 crate (64.4 KB) in 0.39s Installing cargo-binstall v1.10.8 Updating crates.io index Locking 426 packages to latest compatible versions Adding bitflags v1.3.2 (latest: v2.6.0) Adding core-foundation v0.9.4 (latest: v0.10.0) Adding dlopen2 v0.5.0 (latest: v0.7.0) Adding errno v0.2.8 (latest: v0.3.9) Adding faster-hex v0.9.0 (latest: v0.10.0) Adding foreign-types v0.3.2 (latest: v0.5.0) Adding foreign-types-shared v0.1.1 (latest: v0.3.1) Adding generic-array v0.14.7 (latest: v1.1.0) Adding h3 v0.0.5 (latest: v0.0.6) Adding h3-quinn v0.0.6 (latest: v0.0.7) Adding hashbrown v0.14.5 (latest: v0.15.0) Adding hermit-abi v0.3.9 (latest: v0.4.0) Adding hostname v0.3.1 (latest: v0.4.0) Adding idna v0.5.0 (latest: v1.0.2) Adding linux-raw-sys v0.4.14 (latest: v0.6.5) Adding netlink-packet-route v0.17.1 (latest: v0.21.0) Adding nix v0.27.1 (latest: v0.29.0) Adding nu-ansi-term v0.46.0 (latest: v0.50.1) Adding prodash v28.0.0 (latest: v29.0.0) Adding quick-error v1.2.3 (latest: v2.0.1) Adding redox_syscall v0.3.5 (latest: v0.5.7) Adding security-framework v2.11.1 (latest: v3.0.0) Adding system-configuration v0.5.1 (latest: v0.6.1) Adding system-configuration-sys v0.5.0 (latest: v0.6.0) Adding terminal_size v0.3.0 (latest: v0.4.0) Adding unicode-width v0.1.14 (latest: v0.2.0) Adding vergen v8.3.2 (latest: v9.0.1) Adding wasi v0.11.0+wasi-snapshot-preview1 (latest: v0.13.3+wasi-0.2.2) Adding windows v0.48.0 (latest: v0.58.0) Adding windows-registry v0.2.0 (latest: v0.3.0) Adding windows-strings v0.1.0 (latest: v0.2.0) Adding windows-sys v0.48.0 (latest: v0.59.0) Adding windows-sys v0.52.0 (latest: v0.59.0) Adding windows-targets v0.48.5 (latest: v0.52.6) Adding windows_aarch64_gnullvm v0.48.5 (latest: v0.52.6) Adding windows_aarch64_msvc v0.48.5 (latest: v0.52.6) Adding windows_i686_gnu v0.48.5 (latest: v0.52.6) Adding windows_i686_msvc v0.48.5 (latest: v0.52.6) Adding windows_x86_64_gnu v0.48.5 (latest: v0.52.6) Adding windows_x86_64_gnullvm v0.48.5 (latest: v0.52.6) Adding windows_x86_64_msvc v0.48.5 (latest: v0.52.6) Adding winreg v0.50.0 (latest: v0.52.0) Adding zerocopy v0.7.35 (latest: v0.8.6) Adding zerocopy-derive v0.7.35 (latest: v0.8.6) Downloaded alloc-no-stdlib v2.0.4 Downloaded alloc-stdlib v0.2.2 Downloaded adler2 v2.0.0 Downloaded async-recursion v1.1.1 Downloaded cargo-toml-workspace v6.0.1 Downloaded atomic-file-install v1.0.5 Downloaded arrayvec v0.7.6 Downloaded strum v0.26.3 Downloaded rustversion v1.0.18 Downloaded fs-lock v0.1.5 Downloaded http-body v1.0.1 Downloaded leon-macros v1.0.2 Downloaded normalize-path v0.2.1 Downloaded tower-service v0.3.3 Downloaded binstalk-bins v0.6.0 Downloaded binstalk-manifests v0.15.5 Downloaded castaway v0.2.3 Downloaded binstalk-registry v0.11.1 Downloaded binstalk-types v0.9.0 Downloaded base16 v0.2.1 Downloaded serde-tuple-vec-map v1.0.1 Downloaded binstalk-git-repo-api v0.5.3 Downloaded derive_destructure2 v0.1.3 Downloaded futures-sink v0.3.31 Downloaded futures-executor v0.3.31 Downloaded gix-attributes v0.22.5 Downloaded embed-resource v2.5.0 Downloaded async-trait v0.1.83 Downloaded gix-revwalk v0.15.0 Downloaded async-compression v0.4.16 Downloaded gix-url v0.27.5 Downloaded gix-refspec v0.25.0 Downloaded gix-packetline v0.17.6 Downloaded gix-pathspec v0.7.7 Downloaded futures-macro v0.3.31 Downloaded futures-core v0.3.31 Downloaded simple-git v0.2.12 Downloaded futures-task v0.3.31 Downloaded fs4 v0.10.0 Downloaded filetime v0.2.25 Downloaded gix-command v0.3.9 Downloaded deflate64 v0.1.9 Downloaded subtle v2.6.1 Downloaded futures-io v0.3.31 Downloaded gix-prompt v0.8.7 Downloaded gix-discover v0.35.0 Downloaded gix-negotiate v0.15.0 Downloaded human_format v1.1.0 Downloaded gix-credentials v0.24.5 Downloaded gix-packetline-blocking v0.17.5 Downloaded gix-ignore v0.11.4 Downloaded gix-worktree v0.36.0 Downloaded gix-traverse v0.41.0 Downloaded minisign-verify v0.2.2 Downloaded guess_host_triple v0.1.4 Downloaded lru-cache v0.1.2 Downloaded gix-commitgraph v0.24.3 Downloaded maybe-owned v0.3.4 Downloaded linked-hash-map v0.5.6 Downloaded h3-quinn v0.0.6 Downloaded gix-worktree-state v0.13.0 Downloaded leon v3.0.1 Downloaded tokio-macros v2.4.0 Downloaded quick-error v1.2.3 Downloaded binstalk-fetchers v0.10.1 Downloaded parking v2.2.1 Downloaded beef v0.5.2 Downloaded uluru v3.1.0 Downloaded binstalk-downloader v0.13.1 Downloaded cargo_toml v0.20.5 Downloaded camino v1.1.9 Downloaded futures-channel v0.3.31 Downloaded gix-diff v0.46.0 Downloaded enum-as-inner v0.6.1 Downloaded gix-protocol v0.45.3 Downloaded gix-submodule v0.14.0 Downloaded gix-filter v0.13.0 Downloaded detect-targets v0.1.24 Downloaded jobslot v0.2.19 Downloaded gix-revision v0.29.0 Downloaded zstd-safe v7.2.1 Downloaded quinn-udp v0.5.5 Downloaded supports-color v3.0.1 Downloaded rustc_version v0.4.1 Downloaded rustc-hash v2.0.0 Downloaded reflink-copy v0.1.19 Downloaded resolv-conf v0.7.0 Downloaded httparse v1.9.5 Downloaded native-tls v0.2.12 Downloaded ipnet v2.10.1 Downloaded hyper-rustls v0.27.3 Downloaded binstall-tar v0.4.42 Downloaded pin-project-internal v1.1.6 Downloaded tempfile v3.13.0 Downloaded owo-colors v4.1.0 Downloaded file-format v0.25.0 Downloaded gix-odb v0.63.0 Downloaded zstd v0.13.2 Downloaded futures v0.3.31 Downloaded miniz_oxide v0.8.0 Downloaded bytes v1.7.2 Downloaded binstalk v0.28.8 Downloaded rustls-native-certs v0.8.0 Downloaded gix-transport v0.42.3 Downloaded gix-index v0.35.0 Downloaded rustls-pemfile v2.2.0 Downloaded tokio-stream v0.1.16 Downloaded tokio-rustls v0.26.0 Downloaded vergen v8.3.2 Downloaded hyper-util v0.1.9 Downloaded target-lexicon v0.12.16 Downloaded compact_str v0.8.0 Downloaded pin-project v1.1.6 Downloaded tokio-tar v0.3.1 Downloaded hickory-resolver v0.25.0-alpha.2 Downloaded crossbeam-channel v0.5.13 Downloaded async_zip v0.0.17 Downloaded gix-pack v0.53.0 Downloaded flate2 v1.0.34 Downloaded h3 v0.0.5 Downloaded mio v1.0.2 Downloaded rustls-pki-types v1.10.0 Downloaded quinn v0.11.5 Downloaded tokio-util v0.7.12 Downloaded hyper v1.5.0 Downloaded serde_json v1.0.132 Downloaded h2 v0.4.6 Downloaded futures-util v0.3.31 Downloaded brotli-decompressor v4.0.1 Downloaded command-group v5.0.1 Downloaded reqwest v0.12.8 Downloaded gix v0.66.0 Downloaded regex v1.11.0 Downloaded quinn-proto v0.11.8 Downloaded rustls-webpki v0.102.8 Downloaded openssl v0.10.68 Downloaded rustls v0.23.15 Downloaded hickory-proto v0.25.0-alpha.2 Downloaded webpki-roots v0.26.6 Downloaded zstd-sys v2.0.13+zstd.1.5.6 Downloaded tokio v1.40.0 Downloaded brotli v7.0.0 Downloaded openssl-src v300.3.2+3.3.2 Downloaded 143 crates (19.6 MB) in 46.76s (largest was `openssl-src` at 9.8 MB) Compiling proc-macro2 v1.0.88 Compiling unicode-ident v1.0.13 Compiling libc v0.2.161 Compiling cfg-if v1.0.0 Compiling thiserror v1.0.64 Compiling once_cell v1.20.2 Compiling memchr v2.7.4 Compiling bytes v1.7.2 Compiling quote v1.0.37 Compiling syn v2.0.80 Compiling autocfg v1.4.0 Compiling tinyvec_macros v0.1.1 Compiling tinyvec v1.8.0 Compiling fastrand v2.1.1 Compiling bitflags v2.6.0 Compiling itoa v1.0.11 Compiling smallvec v1.13.2 Compiling lock_api v0.4.12 Compiling unicode-normalization v0.1.24 Compiling shlex v1.3.0 Compiling scopeguard v1.2.0 Compiling parking_lot_core v0.9.10 Compiling jobserver v0.1.32 Compiling adler2 v2.0.0 Compiling miniz_oxide v0.8.0 Compiling cc v1.1.31 Compiling crc32fast v1.4.2 Compiling regex-automata v0.4.8 Compiling flate2 v1.0.34 Compiling bstr v1.10.0 Compiling parking_lot v0.12.3 Compiling gix-trace v0.1.10 Compiling pin-project-lite v0.2.14 Compiling faster-hex v0.9.0 Compiling rustix v0.38.37 Compiling crossbeam-utils v0.8.20 Compiling gix-utils v0.1.12 Compiling linux-raw-sys v0.4.14 Compiling serde v1.0.210 Compiling thiserror-impl v1.0.64 Compiling serde_derive v1.0.210 Compiling bytesize v1.3.0 Compiling same-file v1.0.6 Compiling human_format v1.1.0 Compiling gix-hash v0.14.2 Compiling prodash v28.0.0 Compiling walkdir v2.5.0 Compiling crossbeam-channel v0.5.13 Compiling sha1_smol v1.0.1 Compiling gix-features v0.38.2 Compiling zerocopy-derive v0.7.35 Compiling socket2 v0.5.7 Compiling futures-core v0.3.31 Compiling log v0.4.22 Compiling byteorder v1.5.0 Compiling zerocopy v0.7.35 Compiling tokio-macros v2.4.0 Compiling mio v1.0.2 Compiling signal-hook-registry v1.4.2 Compiling tracing-core v0.1.32 Compiling tokio v1.40.0 Compiling winnow v0.6.20 Compiling futures-io v0.3.31 Compiling version_check v0.9.5 Compiling tracing-attributes v0.1.27 Compiling slab v0.4.9 Compiling pkg-config v0.3.31 Compiling home v0.5.9 Compiling futures-sink v0.3.31 Compiling gix-path v0.10.11 Compiling getrandom v0.2.15 Compiling tracing v0.1.40 Compiling jiff v0.1.13 Compiling fnv v1.0.7 Compiling ring v0.17.8 Compiling rustls-pki-types v1.10.0 Compiling hashbrown v0.15.0 Compiling equivalent v1.0.1 Compiling indexmap v2.6.0 Compiling futures-channel v0.3.31 Compiling gix-validate v0.9.0 Compiling futures-macro v0.3.31 Compiling gix-date v0.9.0 Compiling gix-actor v0.32.0 Compiling futures-task v0.3.31 Compiling percent-encoding v2.3.1 Compiling pin-utils v0.1.0 Compiling futures-util v0.3.31 Compiling form_urlencoded v1.2.1 Compiling gix-object v0.44.0 Compiling http v1.1.0 Compiling tempfile v3.13.0 Compiling unicode-bidi v0.3.17 Compiling untrusted v0.9.0 Compiling rustversion v1.0.18 Compiling spin v0.9.8 Compiling idna v0.5.0 Compiling ahash v0.8.11 Compiling memmap2 v0.9.5 Compiling rustls v0.23.15 Compiling static_assertions v1.1.0 Compiling url v2.5.2 Compiling tokio-util v0.7.12 Compiling rustls-webpki v0.102.8 Compiling zeroize v1.8.1 Compiling ryu v1.0.18 Compiling semver v1.0.23 Compiling subtle v2.6.1 Compiling zstd-sys v2.0.13+zstd.1.5.6 Compiling allocator-api2 v0.2.18 Compiling hashbrown v0.14.5 Compiling gix-chunk v0.4.8 Compiling atomic-waker v1.1.2 Compiling h2 v0.4.6 Compiling gix-hashtable v0.5.2 Compiling lzma-sys v0.1.20 Compiling bzip2-sys v0.1.11+1.0.8 Compiling gix-fs v0.11.3 Compiling httparse v1.9.5 Compiling zstd-safe v7.2.1 Compiling alloc-no-stdlib v2.0.4 Compiling alloc-stdlib v0.2.2 Compiling gix-tempfile v14.0.2 Compiling http-body v1.0.1 Compiling rustls-pemfile v2.2.0 Compiling heck v0.5.0 Compiling try-lock v0.2.5 Compiling want v0.3.1 Compiling brotli-decompressor v4.0.1 Compiling tokio-rustls v0.26.0 Compiling gix-commitgraph v0.24.3 Compiling gix-quote v0.4.12 Compiling gix-revwalk v0.15.0 Compiling brotli v7.0.0 Compiling hyper v1.5.0 Compiling bzip2 v0.4.4 Compiling zstd v0.13.2 Compiling rand_core v0.6.4 Compiling gix-glob v0.16.5 Compiling ppv-lite86 v0.2.20 Compiling filetime v0.2.25 Compiling encoding_rs v0.8.34 Compiling unicode-bom v2.0.3 Compiling openssl-probe v0.1.5 Compiling xz2 v0.1.7 Compiling ipnet v2.10.1 Compiling tower-service v0.3.3 Compiling deflate64 v0.1.9 Compiling async-compression v0.4.16 Compiling hyper-util v0.1.9 Compiling rustls-native-certs v0.8.0 Compiling rand_chacha v0.3.1 Compiling gix-lock v14.0.0 Compiling castaway v0.2.3 Compiling webpki-roots v0.26.6 Compiling gix-config-value v0.14.8 Compiling shell-words v1.1.0 Compiling gix-command v0.3.9 Compiling hyper-rustls v0.27.3 Compiling compact_str v0.8.0 Compiling rand v0.8.5 Compiling http-body-util v0.1.2 Compiling serde_urlencoded v0.7.1 Compiling kstring v2.0.2 Compiling sync_wrapper v1.0.1 Compiling gix-sec v0.10.8 Compiling rustc-hash v2.0.0 Compiling base64 v0.22.1 Compiling mime v0.3.17 Compiling quinn-proto v0.11.8 Compiling gix-attributes v0.22.5 Compiling reqwest v0.12.8 Compiling futures-executor v0.3.31 Compiling quinn-udp v0.5.5 Compiling typenum v1.17.0 Compiling owo-colors v4.1.0 Compiling powerfmt v0.2.0 Compiling serde_json v1.0.132 Compiling deranged v0.3.11 Compiling quinn v0.11.5 Compiling futures v0.3.31 Compiling strum_macros v0.26.4 Compiling gix-url v0.27.5 Compiling h3 v0.0.5 Compiling generic-array v0.14.7 Compiling maybe-owned v0.3.4 Compiling async-trait v0.1.83 Compiling match_cfg v0.1.0 Compiling time-core v0.1.2 Compiling is_ci v1.2.0 Compiling smawk v0.3.2 Compiling unicode-linebreak v0.1.5 Compiling unicode-width v0.1.14 Compiling strum v0.26.3 Compiling num-conv v0.1.0 Compiling time v0.3.36 Compiling binstalk-types v0.9.0 Compiling textwrap v0.16.1 Compiling supports-color v3.0.1 Compiling hostname v0.3.1 Compiling h3-quinn v0.0.6 Compiling gix-prompt v0.8.7 Compiling gix-ref v0.47.0 Compiling gix-traverse v0.41.0 Compiling enum-as-inner v0.6.1 Compiling serde_spanned v0.6.8 Compiling toml_datetime v0.6.8 Compiling xattr v1.3.1 Compiling terminal_size v0.3.0 Compiling gix-bitmap v0.2.11 Compiling async-recursion v1.1.1 Compiling pin-project-internal v1.1.6 Compiling miette-derive v7.2.0 Compiling supports-unicode v3.0.0 Compiling linked-hash-map v0.5.6 Compiling supports-hyperlinks v3.0.0 Compiling quick-error v1.2.3 Compiling data-encoding v2.6.0 Compiling arrayvec v0.7.6 Compiling parking v2.2.1 Compiling futures-lite v2.3.0 Compiling uluru v3.1.0 Compiling miette v7.2.0 Compiling hickory-proto v0.25.0-alpha.2 Compiling resolv-conf v0.7.0 Compiling lru-cache v0.1.2 Compiling pin-project v1.1.6 Compiling gix-index v0.35.0 Compiling toml_edit v0.22.22 Compiling gix-credentials v0.24.5 Compiling gix-ignore v0.11.4 Compiling gix-revision v0.29.0 Compiling tokio-stream v0.1.16 Compiling gix-packetline-blocking v0.17.5 Compiling gix-packetline v0.17.6 Compiling camino v1.1.9 Compiling clru v0.6.2 Compiling gix-pack v0.53.0 Compiling gix-transport v0.42.3 Compiling tokio-tar v0.3.1 Compiling gix-filter v0.13.0 Compiling gix-refspec v0.25.0 Compiling gix-worktree v0.36.0 Compiling hickory-resolver v0.25.0-alpha.2 Compiling async_zip v0.0.17 Compiling binstall-tar v0.4.42 Compiling gix-config v0.40.0 Compiling aho-corasick v1.1.3 Compiling gix-pathspec v0.7.7 Compiling maybe-async v0.2.10 Compiling io-close v0.3.7 Compiling regex-syntax v0.8.5 Compiling arc-swap v1.7.1 Compiling anyhow v1.0.90 Compiling httpdate v1.0.3 Compiling binstalk-downloader v0.13.1 Compiling gix-odb v0.63.0 Compiling gix-worktree-state v0.13.0 Compiling gix-protocol v0.45.3 Compiling gix-submodule v0.14.0 Compiling block-buffer v0.10.4 Compiling crypto-common v0.1.6 Compiling toml v0.8.19 Compiling rustc_version v0.4.1 Compiling leon v3.0.1 Compiling gix-discover v0.35.0 Compiling gix-negotiate v0.15.0 Compiling cargo-platform v0.1.8 Compiling vergen v8.3.2 Compiling gix-diff v0.46.0 Compiling serde-tuple-vec-map v1.0.1 Compiling derive_destructure2 v0.1.3 Compiling utf8parse v0.2.2 Compiling num_threads v0.1.7 Compiling normalize-path v0.2.1 Compiling anstyle-parse v0.2.5 Compiling gix v0.66.0 Compiling cargo_metadata v0.18.1 Compiling cargo_toml v0.20.5 Compiling digest v0.10.7 Compiling regex v1.11.0 Compiling reflink-copy v0.1.19 Compiling errno v0.2.8 Compiling anstyle v1.0.8 Compiling target-lexicon v0.12.16 Compiling detect-targets v0.1.24 Compiling colorchoice v1.0.2 Compiling is_terminal_polyfill v1.70.1 Compiling either v1.13.0 Compiling cpufeatures v0.2.14 Compiling anstyle-query v1.1.1 Compiling glob v0.3.1 Compiling cargo-toml-workspace v6.0.1 Compiling anstream v0.6.15 Compiling sha2 v0.10.8 Compiling itertools v0.13.0 Compiling guess_host_triple v0.1.4 Compiling atomic-file-install v1.0.5 Compiling leon-macros v1.0.2 Compiling embed-resource v2.5.0 Compiling simple-git v0.2.12 Compiling binstalk-git-repo-api v0.5.3 Compiling fs4 v0.10.0 Compiling nix v0.27.1 Compiling clap_lex v0.7.2 Compiling strsim v0.11.1 Compiling overload v0.1.1 Compiling minisign-verify v0.2.2 Compiling option-ext v0.2.0 Compiling base16 v0.2.1 Compiling lazy_static v1.5.0 Compiling sharded-slab v0.1.7 Compiling binstalk-registry v0.11.1 Compiling dirs-sys v0.4.1 Compiling binstalk-fetchers v0.10.1 Compiling nu-ansi-term v0.46.0 Compiling command-group v5.0.1 Compiling clap_builder v4.5.20 Compiling fs-lock v0.1.5 Compiling cargo-binstall v1.10.8 Compiling binstalk-bins v0.6.0 Compiling jobslot v0.2.19 Compiling clap_derive v4.5.18 Compiling tracing-serde v0.1.3 Compiling beef v0.5.2 Compiling thread_local v1.1.8 Compiling binstalk-manifests v0.15.5 Compiling tracing-subscriber v0.3.18 Compiling clap v4.5.20 Compiling binstalk v0.28.8 Compiling dirs v5.0.1 Compiling tracing-log v0.2.0 Compiling file-format v0.25.0 Finished `release` profile [optimized] target(s) in 9m 58s Replacing /home/tomoyan/.cargo/bin/cargo-binstall Replaced package `cargo-binstall v1.6.5` with `cargo-binstall v1.10.8` (executable `cargo-binstall`)
または…
$ curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
++ mktemp -d + cd /tmp/tmp.aFNKUP4XyV + base_url=https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall- ++ uname -s + os=Linux + '[' Linux == Darwin ']' + '[' Linux == Linux ']' ++ uname -m + machine=x86_64 + target=x86_64-unknown-linux-musl + '[' x86_64 == armv7 ']' + url=https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz + curl -L --proto =https --tlsv1.2 -sSf https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz + tar -xvzf - cargo-binstall + ./cargo-binstall -y --force cargo-binstall WARN Failed to retrieve token from `gh auth token` err=Os { code: 2, kind: NotFound, message: "No such file or directory" } WARN Failed to read git credential file INFO resolve: Resolving package: 'cargo-binstall' INFO resolve: Verified signature for package 'cargo-binstall': gh=cargo-bins/cargo-binstall git=dfdaf6952e30a0fc88fe8f8afc4906244bdeccf8 ts=2024-05-03T08:38:48.184Z run=8936278573 WARN The package cargo-binstall v1.6.5 (x86_64-unknown-linux-gnu) has been downloaded from github.com INFO This will install the following binaries: INFO - cargo-binstall (cargo-binstall -> /home/tomoyan/.cargo/bin/cargo-binstall) INFO Installing binaries... INFO Done in 7.661177467s + CARGO_HOME=/home/tomoyan/.cargo + [[ :/home/tomoyan/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin:/home/tomoyan/.rustup/toolchains/esp/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin:/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin:/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf/bin:/home/tomoyan/micromamba/condabin:/home/tomoyan/.local/bin:/home/tomoyan/go/bin:/home/tomoyan/.anyenv/envs/nodenv/shims:/home/tomoyan/.anyenv/envs/nodenv/bin:/home/tomoyan/.anyenv/bin:/home/tomoyan/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin: == *\:\/\h\o\m\e\/\t\o\m\o\y\a\n\/\.\c\a\r\g\o\/\b\i\n\:* ]]
動作確認🤔
$ cargo binstall -V
1.10.8
espflash のインストール
公式: Running the Code - Understanding esp-template - The Rust on ESP Book 翻訳
cargo run
コマンドで esp32 ボードにコードをフラッシュするには、espflash をインストールしておく必要がある🤔
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.21s Running `espflash flash --monitor target/xtensa-esp32-none-elf/debug/haruo-nostd-esp32` error: could not execute process `espflash flash --monitor target/xtensa-esp32-none-elf/debug/haruo-nostd-esp32` (never executed) Caused by: No such file or directory (os error 2)
公式: espflash/espflash at main · esp-rs/espflash · GitHub 翻訳 の手順で espflash をインストールする🤔
※ esp-rs/espflash リポジトリには cargo-espflash も存在するが、cargo-espflash ではなく espflash です🤔
Fedora
systemd-devel がインストールされていない場合はインストールする🤔
$ sudo dnf install systemd-devel
メタデータの期限切れの最終確認: 1:06:39 前の 2023年11月30日 11時33分17秒 に実施しました。 パッケージ systemd-devel-253.12-1.fc38.x86_64 は既にインストールされています。 依存関係が解決しました。 行うべきことはありません。 完了しました!
espflash のインストール🤔
$ cargo install espflash
Updating crates.io index Downloaded espflash v3.0.0 Downloaded 1 crate (5.4 MB) in 3.32s Installing espflash v3.0.0 Updating crates.io index Downloaded bytemuck v1.15.0 Downloaded defmt-parser v0.3.4 Downloaded derive_more v0.99.17 Downloaded esp-idf-part v0.5.0 Downloaded defmt-decoder v0.3.10 Downloaded bytemuck_derive v1.6.0 Downloaded hash32 v0.3.1 Downloaded miette-derive v7.2.0 Downloaded num-traits v0.2.19 Downloaded supports-hyperlinks v3.0.0 Downloaded miette v7.2.0 Downloaded supports-unicode v3.0.0 Downloaded supports-color v3.0.0 Downloaded unescaper v0.1.4 Downloaded slip-codec v0.4.0 Downloaded owo-colors v4.0.0 Downloaded serialport v4.3.0 Downloaded heapless v0.8.0 Downloaded ruzstd v0.5.0 Downloaded comfy-table v7.1.1 Downloaded 20 crates (718.3 KB) in 1.92s Compiling proc-macro2 v1.0.81 Compiling unicode-ident v1.0.12 Compiling libc v0.2.154 Compiling cfg-if v1.0.0 Compiling serde v1.0.200 Compiling syn v1.0.109 Compiling memchr v2.7.2 Compiling bitflags v2.5.0 Compiling cc v1.0.96 Compiling quote v1.0.36 Compiling syn v2.0.60 Compiling crc32fast v1.4.0 Compiling autocfg v1.3.0 Compiling byteorder v1.5.0 Compiling adler v1.0.2 Compiling miniz_oxide v0.7.2 Compiling rustix v0.38.34 Compiling thiserror v1.0.59 Compiling flate2 v1.0.30 Compiling smallvec v1.13.2 Compiling static_assertions v1.1.0 Compiling stable_deref_trait v1.2.0 Compiling typenum v1.17.0 Compiling version_check v0.9.4 Compiling linux-raw-sys v0.4.13 Compiling generic-array v0.14.7 Compiling twox-hash v1.6.3 Compiling ring v0.17.8 Compiling itoa v1.0.11 Compiling serde_derive v1.0.200 Compiling thiserror-impl v1.0.59 Compiling derive_more v0.99.17 Compiling fnv v1.0.7 Compiling rustversion v1.0.15 Compiling tinyvec_macros v0.1.1 Compiling hashbrown v0.14.5 Compiling unicode-width v0.1.12 Compiling strsim v0.10.0 Compiling ident_case v1.0.1 Compiling cpp_demangle v0.4.3 Compiling ryu v1.0.17 Compiling ruzstd v0.5.0 Compiling utf8parse v0.2.1 Compiling equivalent v1.0.1 Compiling indexmap v2.2.6 Compiling object v0.32.2 Compiling log v0.4.21 Compiling anstyle-parse v0.2.4 Compiling darling_core v0.14.4 Compiling tinyvec v1.6.0 Compiling gimli v0.28.1 Compiling lock_api v0.4.12 Compiling getrandom v0.2.14 Compiling aho-corasick v1.1.3 Compiling untrusted v0.9.0 Compiling spin v0.9.8 Compiling regex-syntax v0.8.3 Compiling radium v0.7.0 Compiling anstyle v1.0.7 Compiling scopeguard v1.2.0 Compiling winnow v0.5.40 Compiling toml_datetime v0.6.5 Compiling signal-hook v0.3.17 Compiling serde_json v1.0.116 Compiling parking_lot_core v0.9.10 Compiling rustls-pki-types v1.5.0 Compiling colorchoice v1.0.1 Compiling anstyle-query v1.0.3 Compiling pkg-config v0.3.30 Compiling is_terminal_polyfill v1.70.0 Compiling lazy_static v1.4.0 Compiling anstream v0.6.14 Compiling libudev-sys v0.1.4 Compiling toml_edit v0.19.15 Compiling regex-automata v0.4.6 Compiling darling_macro v0.14.4 Compiling unicode-normalization v0.1.23 Compiling terminal_size v0.3.0 Compiling num-traits v0.2.19 Compiling backtrace v0.3.71 Compiling signal-hook-registry v1.4.2 Compiling memmap2 v0.5.10 Compiling zeroize v1.7.0 Compiling unicode-bidi v0.3.15 Compiling rustc-demangle v0.1.23 Compiling tap v1.0.1 Compiling heck v0.4.1 Compiling fallible-iterator v0.3.0 Compiling rustls v0.22.4 Compiling percent-encoding v2.3.1 Compiling once_cell v1.19.0 Compiling cfg_aliases v0.1.1 Compiling nix v0.28.0 Compiling proc-macro-crate v1.3.1 Compiling addr2line v0.21.0 Compiling form_urlencoded v1.2.1 Compiling strum_macros v0.26.2 Compiling wyz v0.5.1 Compiling idna v0.5.0 Compiling darling v0.14.4 Compiling rustls-webpki v0.102.3 Compiling regex v1.10.4 Compiling block-buffer v0.10.4 Compiling crypto-common v0.1.6 Compiling mio v0.8.11 Compiling portable-atomic v1.6.0 Compiling heck v0.5.0 Compiling clap_lex v0.7.0 Compiling semver v1.0.22 Compiling strsim v0.11.1 Compiling powerfmt v0.2.0 Compiling option-ext v0.2.0 Compiling num-conv v0.1.0 Compiling subtle v2.5.0 Compiling funty v2.0.0 Compiling anyhow v1.0.82 Compiling time-core v0.1.2 Compiling heapless v0.8.0 Compiling time-macros v0.2.18 Compiling bitvec v1.0.1 Compiling dirs-sys v0.4.1 Compiling deranged v0.3.11 Compiling clap_builder v4.5.2 Compiling clap_derive v4.5.4 Compiling signal-hook-mio v0.2.3 Compiling digest v0.10.7 Compiling parking_lot v0.12.2 Compiling deku_derive v0.16.0 Compiling strum v0.26.2 Compiling url v2.5.0 Compiling console v0.15.8 Compiling webpki-roots v0.26.1 Compiling serde_spanned v0.6.5 Compiling hash32 v0.3.1 Compiling csv-core v0.1.11 Compiling smawk v0.3.2 Compiling fastrand v2.1.0 Compiling unicode-linebreak v0.1.5 Compiling bitflags v1.3.2 Compiling is_ci v1.2.0 Compiling winnow v0.6.7 Compiling minimal-lexical v0.2.1 Compiling base64 v0.22.1 Compiling ureq v2.9.7 Compiling toml_edit v0.22.12 Compiling nom v7.1.3 Compiling time v0.3.36 Compiling supports-color v3.0.0 Compiling nix v0.26.4 Compiling textwrap v0.16.1 Compiling tempfile v3.10.1 Compiling csv v1.3.0 Compiling deku v0.16.0 Compiling backtrace-ext v0.2.1 Compiling parse_int v0.6.0 Compiling clap v4.5.4 Compiling crossterm v0.27.0 Compiling libudev v0.3.0 Compiling directories v5.0.1 Compiling env_filter v0.1.0 Compiling colored v2.1.0 Compiling defmt-json-schema v0.1.0 Compiling serde_plain v1.0.2 Compiling defmt-parser v0.3.4 Compiling unescaper v0.1.4 Compiling miette-derive v7.2.0 Compiling bytemuck_derive v1.6.0 Compiling number_prefix v0.4.0 Compiling zero v0.1.3 Compiling shell-words v1.1.0 Compiling cpufeatures v0.2.12 Compiling owo-colors v4.0.0 Compiling humantime v2.1.0 Compiling supports-unicode v3.0.0 Compiling dissimilar v1.0.8 Compiling supports-hyperlinks v3.0.0 Compiling md5 v0.7.0 Compiling defmt-decoder v0.3.10 Compiling miette v7.2.0 Compiling esp-idf-part v0.5.0 Compiling env_logger v0.11.3 Compiling bytemuck v1.15.0 Compiling sha2 v0.10.8 Compiling dialoguer v0.11.0 Compiling xmas-elf v0.9.1 Compiling indicatif v0.17.8 Compiling serialport v4.3.0 Compiling update-informer v1.1.0 Compiling comfy-table v7.1.1 Compiling ctrlc v3.4.4 Compiling clap_complete v4.5.2 Compiling toml v0.8.12 Compiling md-5 v0.10.6 Compiling hex v0.4.3 Compiling slip-codec v0.4.0 Compiling espflash v3.0.0 Finished release [optimized] target(s) in 3m 55s Replacing /home/tomoyan/.cargo/bin/espflash Replaced package `espflash v2.1.0` with `espflash v3.0.0` (executable `espflash`)
動作確認🤔
$ espflash -V
espflash 3.0.0
シリアルポートの権限設定
標準ではシリアルポートの権限を設定する必要がある🤔
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.11s Running `espflash flash --monitor target/xtensa-esp32-none-elf/debug/haruo-nostd-esp32` [2023-11-30T05:26:14Z INFO ] Serial port: '/dev/ttyUSB0' [2023-11-30T05:26:14Z INFO ] Connecting... Error: espflash::serial_error × Failed to open serial port /dev/ttyUSB0 ├─▶ Failed to open serial port /dev/ttyUSB0 ├─▶ Error while connecting to device ├─▶ IO error while using serial port: Permission denied ╰─▶ Permission denied
ESP32 の USB ポートを調べる
ESP32-WROOM-32 (cp210x)
ESP32 の接続ポートを確認
lsusb
コマンドで Bus と Device 番号、デバイス名を調べる🤔
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 003: ID 04f2:b34c Chicony Electronics Co., Ltd [unknown] Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 003: ID 0bda:8723 Realtek Semiconductor Corp. RTL8723A Bluetooth Bus 002 Device 004: ID 10c4:ea60 Silicon Labs CP210x UART Bridge Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 004 Device 004: ID 046d:c52b Logitech, Inc. Unifying Receiver
lsusb -t
コマンドでドライバを調べる🤔
$ lsusb -t
/: Bus 001.Port 001: Dev 001, Class=root_hub, Driver=ehci-pci/2p, 480M |__ Port 001: Dev 002, If 0, Class=Hub, Driver=hub/6p, 480M |__ Port 006: Dev 003, If 0, Class=Video, Driver=uvcvideo, 480M |__ Port 006: Dev 003, If 1, Class=Video, Driver=uvcvideo, 480M /: Bus 002.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/4p, 480M |__ Port 001: Dev 004, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M |__ Port 004: Dev 003, If 0, Class=Wireless, Driver=btusb, 12M |__ Port 004: Dev 003, If 1, Class=Wireless, Driver=btusb, 12M /: Bus 003.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/4p, 5000M /: Bus 004.Port 001: Dev 001, Class=root_hub, Driver=ehci-pci/2p, 480M |__ Port 001: Dev 002, If 0, Class=Hub, Driver=hub/6p, 480M |__ Port 002: Dev 004, If 0, Class=Human Interface Device, Driver=usbhid, 12M |__ Port 002: Dev 004, If 1, Class=Human Interface Device, Driver=usbhid, 12M |__ Port 002: Dev 004, If 2, Class=Human Interface Device, Driver=usbhid, 12M
シリアルデバイスの by-id、by-path で /dev/ttyUSB0
であることが確認できる🤔
$ ls -l /dev/serial/{by-id,by-path}
/dev/serial/by-id: 合計 0 lrwxrwxrwx 1 root root 13 5月 6 09:22 usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 -> ../../ttyUSB0 /dev/serial/by-path: 合計 0 lrwxrwxrwx 1 root root 13 5月 6 09:22 pci-0000:00:14.0-usb-0:1:1.0-port0 -> ../../ttyUSB0 lrwxrwxrwx 1 root root 13 5月 6 09:22 pci-0000:00:14.0-usbv2-0:1:1.0-port0 -> ../../ttyUSB0
ユーザーのアクセス権限を設定
公式: espflash/espflash/README.md at main · esp-rs/espflash · GitHub 翻訳
シリアルコンソールに接続する前に、ポートの権限を設定
/dev/ttyUSB0
は dialout
グループで読み書きできる🤔
$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 11月 30 12:16 /dev/ttyUSB0
現在のユーザー $USER
を dialout
グループに所属させる🤔
$ sudo usermod -a -G dialout $USER
$ id tomoyan
uid=1000(tomoyan) gid=1000(tomoyan) groups=1000(tomoyan),10(wheel),18(dialout),135(mock),974(docker)
dialout
グループへの所属を再ログインせずに反映するには newgrp dialout
コマンドを実行する🤔
$ newgrp dialout $ id
uid=1000(tomoyan) gid=18(dialout) groups=18(dialout),10(wheel),135(mock),974(docker),1000(tomoyan)
ESP32 のフラッシュへの書き込み
公式: Running the Code - Understanding esp-template - The Rust on ESP Book 翻訳
上記までの手順でフラッシュへ書き込む準備ができているので、cargo run
コマンドでビルドからフラッシュ書き込みができる😉
サンプル: esp32-nostd-ssd1306 - Wokwi ESP32, STM32, Arduino Simulator
$ cargo run
Updating crates.io index Downloaded float-cmp v0.9.0 Downloaded profont v0.7.0 Downloaded esp-backtrace v0.9.0 Downloaded esp-hal-procmacros v0.7.0 Downloaded embedded-io v0.6.1 Downloaded micromath v2.1.0 Downloaded mipidsi v0.7.1 Downloaded ssd1306 v0.8.4 Downloaded esp32-hal v0.16.0 Downloaded esp-hal-common v0.13.1 Downloaded embedded-graphics v0.8.1 Downloaded esp32 v0.27.0 Downloaded 12 crates (3.7 MB) in 4.42s (largest was `embedded-graphics` at 2.5 MB) Downloaded addr2line v0.17.0 Downloaded getopts v0.2.21 Downloaded cc v1.0.76 Downloaded rustc-demangle v0.1.21 Downloaded miniz_oxide v0.5.3 Downloaded libc v0.2.138 Downloaded object v0.29.0 Downloaded gimli v0.26.1 Downloaded compiler_builtins v0.1.84 Downloaded 9 crates (1.9 MB) in 6.86s Compiling compiler_builtins v0.1.84 Compiling core v0.0.0 (/home/tomoyan/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core) Compiling proc-macro2 v1.0.70 Compiling unicode-ident v1.0.12 Compiling autocfg v1.1.0 Compiling syn v1.0.109 Compiling rustversion v1.0.14 Compiling serde v1.0.193 Compiling quote v1.0.33 Compiling heck v0.4.1 Compiling syn v2.0.39 Compiling version_check v0.9.4 Compiling memchr v2.6.4 Compiling aho-corasick v1.1.2 Compiling regex-syntax v0.8.2 Compiling anyhow v1.0.75 Compiling fnv v1.0.7 Compiling ident_case v1.0.1 Compiling strsim v0.10.0 Compiling darling_core v0.20.3 Compiling serde_derive v1.0.193 Compiling rustc-std-workspace-core v1.99.0 (/home/tomoyan/.rustup/toolchains/esp/lib/rustlib/src/rust/library/rustc-std-workspace-core) Compiling nb v1.1.0 Compiling nb v0.1.3 Compiling byteorder v1.5.0 Compiling void v1.0.2 Compiling regex-automata v0.4.3 Compiling lock_api v0.4.11 Compiling xtensa-lx v0.8.0 Compiling az v1.2.1 Compiling semver v1.0.20 Compiling darling_macro v0.20.3 Compiling embedded-hal v0.2.7 Compiling regex v1.10.2 Compiling scopeguard v1.2.0 Compiling strum_macros v0.24.3 Compiling enum-as-inner v0.4.0 Compiling proc-macro-error-attr v1.0.4 Compiling hashbrown v0.14.3 Compiling strum v0.24.1 Compiling equivalent v1.0.1 Compiling indexmap v2.1.0 Compiling core-isa-parser v0.2.0 Compiling darling v0.20.3 Compiling minijinja v1.0.10 Compiling bare-metal v1.0.0 Compiling critical-section v1.1.2 Compiling stable_deref_trait v1.2.0 Compiling proc-macro-error v1.0.4 Compiling num-traits v0.2.17 Compiling winnow v0.5.19 Compiling toml_datetime v0.6.5 Compiling embedded-graphics-core v0.4.0 Compiling rustc_version v0.4.0 Compiling basic-toml v0.1.7 Compiling toml_edit v0.20.7 Compiling spin v0.9.8 Compiling mutex-trait v0.2.0 Compiling display-interface v0.4.1 Compiling paste v1.0.14 Compiling esp32 v0.27.0 Compiling esp-hal-common v0.13.1 Compiling proc-macro-crate v2.0.0 Compiling heapless v0.7.16 Compiling xtensa-lx-rt-proc-macros v0.2.1 Compiling vcell v0.1.3 Compiling embedded-hal v1.0.0-rc.1 Compiling r0 v1.0.0 Compiling gcd v2.3.0 Compiling strum_macros v0.25.3 Compiling litrs v0.4.1 Compiling esp-println v0.7.1 Compiling esp-hal-procmacros v0.7.0 Compiling fugit v0.3.7 Compiling embedded-hal-nb v1.0.0-rc.1 Compiling float-cmp v0.9.0 Compiling strum v0.25.0 Compiling embedded-dma v0.2.0 Compiling hash32 v0.2.1 Compiling embedded-can v0.4.1 Compiling cfg-if v1.0.0 Compiling byte-slice-cast v0.3.5 Compiling bitfield v0.14.0 Compiling micromath v2.1.0 Compiling embedded-io v0.6.1 Compiling bitflags v2.4.1 Compiling esp-backtrace v0.9.0 Compiling xtensa-lx-rt v0.16.0 Compiling esp32-hal v0.16.0 Compiling embedded-graphics v0.8.1 Compiling display-interface-spi v0.4.1 Compiling display-interface-i2c v0.4.0 Compiling ssd1306 v0.8.4 Compiling profont v0.7.0 Compiling mipidsi v0.7.1 Compiling rust_project_esp32 v0.1.0 (/home/tomoyan/my_projects/haruo-nostd-esp32)
Finished dev [optimized + debuginfo] target(s) in 7m 41s Running `espflash flash --monitor target/xtensa-esp32-none-elf/debug/rust_project_esp32` [2024-05-06T00:37:27Z INFO ] Serial port: '/dev/ttyUSB0' [2024-05-06T00:37:27Z INFO ] Connecting... [2024-05-06T00:37:27Z INFO ] Using flash stub Chip type: esp32 (revision v1.0) Crystal frequency: 40 MHz Flash size: 4MB Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None MAC address: 7c:9e:bd:36:81:8c App/part. size: 108,688/4,128,768 bytes, 2.63% [00:00:01] [========================================] 17/17 0x1000 [2024-05-06T00:37:31Z INFO ] Segment at address '0x8000' has not changed, skipping write [00:00:04] [========================================] 40/40 0x10000 [2024-05-06T00:37:36Z INFO ] Flashing has completed! Commands: CTRL+R Reset chip CTRL+C Exit ets Jun 8 2016 00:22:57 rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:7104 load:0x40078000,len:15576 load:0x40080400,len:4 ho 8 tail 4 room 4 load:0x40080404,len:3876 entry 0x4008064c 0x4008064c - core::fmt::Arguments::new_v1 at /home/tomoyan/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:398 I (30) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader I (31) boot: compile time Jun 7 2023 07:48:23 I (33) boot: Multicore bootloader I (37) boot: chip revision: v1.0 I (41) boot.esp32: SPI Speed : 40MHz I (45) boot.esp32: SPI Mode : DIO I (50) boot.esp32: SPI Flash Size : 4MB I (54) boot: Enabling RNG early entropy source... I (60) boot: Partition Table: I (63) boot: ## Label Usage Type ST Offset Length I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (78) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (86) boot: 2 factory factory app 00 00 00010000 003f0000 I (93) boot: End of partition table I (97) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=07f24h ( 32548) map I (118) esp_image: segment 1: paddr=00017f4c vaddr=3ffb0000 size=00004h ( 4) load I (118) esp_image: segment 2: paddr=00017f58 vaddr=40080000 size=01098h ( 4248) load I (127) esp_image: segment 3: paddr=00018ff8 vaddr=00000000 size=07020h ( 28704) I (143) esp_image: segment 4: paddr=00020020 vaddr=400d0020 size=0a84ch ( 43084) map I (160) boot: Loaded app from partition at offset 0x10000 I (160) boot: Disabling RNG early entropy source... esp-hal Chip: ESP32... Haruo World!... esp-hal Chip: ESP32... Haruo World!... esp-hal Chip: ESP32... Haruo World!...
cargo-xtask によるビルド
cargo-xtask コマンドは初回実行時にビルドされる...🤔
$ git clone https://github.com/esp-rs/esp-hal.git
Cloning into 'esp-hal'... remote: Enumerating objects: 19603, done. remote: Counting objects: 100% (1222/1222), done. remote: Compressing objects: 100% (725/725), done. remote: Total 19603 (delta 732), reused 861 (delta 493), pack-reused 18381 Receiving objects: 100% (19603/19603), 24.43 MiB | 3.92 MiB/s, done. Resolving deltas: 100% (15018/15018), done.
$ cd esp-hal $ cargo xtask --help
Updating crates.io index Compiling proc-macro2 v1.0.83 Compiling unicode-ident v1.0.12 Compiling memchr v2.7.2 Compiling serde v1.0.202 Compiling utf8parse v0.2.1 Compiling anstyle-parse v0.2.4 Compiling aho-corasick v1.1.3 Compiling regex-syntax v0.8.3 Compiling quote v1.0.36 Compiling syn v2.0.65 Compiling autocfg v1.3.0 Compiling anstyle v1.0.7 Compiling colorchoice v1.0.1 Compiling is_terminal_polyfill v1.70.0 Compiling anstyle-query v1.0.3 Compiling rustversion v1.0.17 Compiling anstream v0.6.14 Compiling regex-automata v0.4.6 Compiling num-traits v0.2.19 Compiling log v0.4.21 Compiling hashbrown v0.14.5 Compiling clap_lex v0.7.0 Compiling heck v0.5.0 Compiling regex v1.10.4 Compiling equivalent v1.0.1 Compiling heck v0.4.1 Compiling strsim v0.11.1 Compiling anyhow v1.0.86 Compiling semver v1.0.23 Compiling clap_builder v4.5.2 Compiling env_filter v0.1.0 Compiling indexmap v2.2.6 Compiling serde_derive v1.0.202 Compiling strum_macros v0.26.2 Compiling clap_derive v4.5.4 Compiling csv-core v0.1.11 Compiling itoa v1.0.11 Compiling humantime v2.1.0 Compiling ryu v1.0.18 Compiling toml_datetime v0.6.6 Compiling iana-time-zone v0.1.60 Compiling winnow v0.6.8 Compiling chrono v0.4.38 Compiling env_logger v0.11.3 Compiling clap v4.5.4 Compiling strum v0.26.2 Compiling toml_edit v0.22.13 Compiling csv v1.3.0 Compiling basic-toml v0.1.9 Compiling minijinja v1.0.21 Compiling xtask v0.0.0 (/home/tomoyan/my_projects/esp-hal/xtask) Finished `dev` profile [unoptimized + debuginfo] target(s) in 52.14s Running `target/debug/xtask --help`
Usage: xtask <COMMAND> Commands: build-documentation Build documentation for the specified chip build-examples Build all examples for the specified chip build-package Build the specified package with the given options build-tests Build all applicable tests or the specified test for a specified chip bump-version Bump the version of the specified package(s) fmt-packages Format all packages in the workspace with rustfmt generate-efuse-fields Generate the eFuse fields source file from a CSV run-example Run the given example for the specified chip run-tests Run all applicable tests or the specified test for a specified chip run-elfs Run all ELFs in a folder help Print this message or the help of the given subcommand(s) Options: -h, --help Print help
次回からはビルド済みなので即実行される😊
$ cargo xtask --help
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s Running `target/debug/xtask --help` Usage: xtask <COMMAND> Commands: build-documentation Build documentation for the specified chip build-examples Build all examples for the specified chip build-package Build the specified package with the given options build-tests Build all applicable tests or the specified test for a specified chip bump-version Bump the version of the specified package(s) fmt-packages Format all packages in the workspace with rustfmt generate-efuse-fields Generate the eFuse fields source file from a CSV run-example Run the given example for the specified chip run-tests Run all applicable tests or the specified test for a specified chip run-elfs Run all ELFs in a folder help Print this message or the help of the given subcommand(s) Options: -h, --help Print help
cargo-xtask の仕組み
$ bat -p .cargo/config.toml
[alias] xtask = "run --package xtask --"
$ cargo --list
Installed Commands: add Add dependencies to a Cargo.toml manifest file b alias: build bench Execute all benchmarks of a local package binstall bootimage build Compile a local package and all of its dependencies c alias: check check Check a local package and all of its dependencies for errors clean Remove artifacts that cargo has generated in the past clippy Checks a package to catch common mistakes and improve your Rust code. config Inspect configuration values cov d alias: doc doc Build a package's documentation embed espflash fetch Fetch dependencies of a package from the network fix Automatically fix lint warnings reported by rustc flash fmt Formats all bin and lib files of the current crate using rustfmt. generate generate-lockfile Generate the lockfile for a package git-checkout This command has been removed help Displays help for a cargo subcommand init Create a new cargo package in an existing directory install Install a Rust binary locate-project Print a JSON representation of a Cargo.toml file's location login Log in to a registry. logout Remove an API token from the registry locally metadata Output the resolved dependencies of a package, the concrete used versions including overrides, in machine-readable format miri new Create a new cargo package at <path> nm objcopy objdump owner Manage the owners of a crate on the registry package Assemble the local package into a distributable tarball pkgid Print a fully qualified package specification profdata publish Upload a package to the registry r alias: run read-manifest Print a JSON representation of a Cargo.toml manifest. readobj remove Remove dependencies from a Cargo.toml manifest file report Generate and display various kinds of reports rm alias: remove run Run a binary or example of the local package rustc Compile a package, and pass extra options to the compiler rustdoc Build a package's documentation, using specified custom flags. search Search packages in the registry. Default registry is crates.io shuttle size strip t alias: test test Execute all unit and integration tests and build examples of a local package tree Display a tree visualization of a dependency graph uninstall Remove a Rust binary update Update dependencies as recorded in the local lock file vendor Vendor all dependencies for a project locally verify-project Check correctness of crate manifest
version Show version information xtask alias: run --package xtask -- yank Remove a pushed crate from the index
$ cargo run --package xtask -- --help
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s Running `target/debug/xtask --help` Usage: xtask <COMMAND> Commands: build-documentation Build documentation for the specified chip build-examples Build all examples for the specified chip build-package Build the specified package with the given options build-tests Build all applicable tests or the specified test for a specified chip bump-version Bump the version of the specified package(s) fmt-packages Format all packages in the workspace with rustfmt generate-efuse-fields Generate the eFuse fields source file from a CSV run-example Run the given example for the specified chip run-tests Run all applicable tests or the specified test for a specified chip run-elfs Run all ELFs in a folder help Print this message or the help of the given subcommand(s) Options: -h, --help Print help
ESP32 サンプルのビルド
公式: esp-hal/examples at main · esp-rs/esp-hal
$ cargo xtask build-examples esp-hal esp32 embassy_hello_world
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s Running `target/debug/xtask build-examples esp-hal esp32 embassy_hello_world` [2024-05-24T04:51:14Z WARN xtask] Package 'esp-hal' specified, using 'examples' instead [2024-05-24T04:51:14Z INFO xtask] Building example '/home/tomoyan/my_projects/esp-hal/examples/src/bin/embassy_hello_world.rs' for 'esp32' [2024-05-24T04:51:14Z INFO xtask] Features: embassy,embassy-time-timg0,embassy-generic-timers [2024-05-24T04:51:14Z INFO xtask] Package: "src/bin/embassy_hello_world.rs" Compiling compiler_builtins v0.1.105 Compiling core v0.0.0 (/home/tomoyan/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core) Compiling proc-macro2 v1.0.83 Compiling unicode-ident v1.0.12 Compiling version_check v0.9.4 Compiling typenum v1.17.0 Compiling generic-array v0.14.7 Compiling rustversion v1.0.17 Compiling quote v1.0.36 Compiling syn v2.0.66 Compiling heck v0.4.1 Compiling syn v1.0.109 Compiling autocfg v1.3.0 Compiling serde v1.0.202 Compiling fnv v1.0.7 Compiling ident_case v1.0.1 Compiling termcolor v1.4.1 Compiling strsim v0.11.1 Compiling memchr v2.7.2 Compiling aho-corasick v1.1.3 Compiling darling_core v0.20.9 Compiling anyhow v1.0.86 Compiling xtensa-lx v0.9.0 Compiling regex-syntax v0.8.3 Compiling serde_derive v1.0.202 Compiling rustc-std-workspace-core v1.99.0 (/home/tomoyan/.rustup/toolchains/esp/lib/rustlib/src/rust/library/rustc-std-workspace-core) Compiling esp-build v0.1.0 (/home/tomoyan/my_projects/esp-hal/esp-build) Compiling darling_macro v0.20.9 Compiling alloc v0.0.0 (/home/tomoyan/.rustup/toolchains/esp/lib/rustlib/src/rust/library/alloc) Compiling darling v0.20.9 Compiling strum_macros v0.26.2 Compiling regex-automata v0.4.6 Compiling zeroize v1.7.0 Compiling subtle v2.5.0 Compiling nb v1.1.0 Compiling byteorder v1.5.0 Compiling critical-section v1.1.2 Compiling rand_core v0.6.4 Compiling stable_deref_trait v1.2.0 Compiling void v1.0.2 Compiling embedded-hal v1.0.0 Compiling lock_api v0.4.12 Compiling litrs v0.4.1 Compiling embassy-time-driver v0.1.0 Compiling portable-atomic v1.6.0 Compiling basic-toml v0.1.9 Compiling document-features v0.2.8 Compiling nb v0.1.3 Compiling strum v0.26.2 Compiling regex v1.10.4 Compiling const-oid v0.9.6 Compiling cfg-if v1.0.0 Compiling scopeguard v1.2.0 Compiling enum-as-inner v0.4.0 Compiling strum_macros v0.24.3 Compiling proc-macro-error-attr v1.0.4 Compiling lazy_static v1.4.0 Compiling hashbrown v0.14.5 Compiling strum v0.24.1 Compiling equivalent v1.0.1 Compiling heapless v0.8.0 Compiling esp-metadata v0.1.0 (/home/tomoyan/my_projects/esp-hal/esp-metadata) Compiling indexmap v2.2.6 Compiling der v0.7.9 Compiling embedded-hal v0.2.7 Compiling minijinja v1.0.21 Compiling ff v0.13.0 Compiling crypto-common v0.1.6 Compiling core-isa-parser v0.2.0 Compiling hash32 v0.3.1 Compiling bare-metal v1.0.0 Compiling base16ct v0.2.0 Compiling proc-macro-error v1.0.4 Compiling az v1.2.1 Compiling winnow v0.5.40 Compiling toml_datetime v0.6.6 Compiling esp-hal v0.17.0 (/home/tomoyan/my_projects/esp-hal/esp-hal) Compiling sec1 v0.7.3 Compiling group v0.13.0 Compiling spin v0.9.8 Compiling crypto-bigint v0.5.5 Compiling bytemuck v1.16.0 Compiling toml_edit v0.21.1 Compiling log v0.4.21 Compiling mutex-trait v0.2.0 Compiling num-traits v0.2.19 Compiling paste v1.0.15 Compiling embedded-hal-async v1.0.0 Compiling embassy-executor v0.5.0 Compiling esp32 v0.30.0 (https://github.com/esp-rs/esp-pacs/?rev=9a36a93#9a36a937) Compiling proc-macro-crate v3.1.0 Compiling elliptic-curve v0.13.8 Compiling rgb v0.8.37 Compiling cipher v0.3.0 Compiling block-buffer v0.10.4 Compiling futures-task v0.3.30 Compiling pin-project-lite v0.2.14 Compiling futures-core v0.3.30 Compiling vcell v0.1.3 Compiling pin-utils v0.1.0 Compiling r0 v1.0.0 Compiling embedded-io v0.6.1 Compiling display-interface v0.4.1 Compiling gcd v2.3.0 Compiling xtensa-lx-rt-proc-macros v0.2.1 Compiling embassy-executor-macros v0.4.1 Compiling enumset_derive v0.8.1 Compiling esp-println v0.9.1 (/home/tomoyan/my_projects/esp-hal/esp-println) Compiling embedded-io-async v0.6.1 Compiling xtensa-lx-rt v0.16.0 Compiling embassy-time-queue-driver v0.1.0 Compiling esp-hal-procmacros v0.10.0 (/home/tomoyan/my_projects/esp-hal/esp-hal-procmacros) Compiling embedded-graphics-core v0.4.0 Compiling enumset v1.1.3 Compiling fugit v0.3.7 Compiling futures-util v0.3.30 Compiling digest v0.10.7 Compiling ctr v0.8.0 Compiling smart-leds-trait v0.3.0 Compiling primeorder v0.13.6 Compiling embedded-hal-nb v1.0.0 Compiling embedded-dma v0.2.0 Compiling aead v0.4.3 Compiling micromath v1.1.1 Compiling inout v0.1.3 Compiling embedded-can v0.4.1 Compiling byte-slice-cast v0.3.5 Compiling bitfield v0.15.0 Compiling bitflags v2.5.0 Compiling esp-backtrace v0.11.1 (/home/tomoyan/my_projects/esp-hal/esp-backtrace) Compiling delegate v0.12.0 Compiling num_enum_derive v0.7.2 Compiling embassy-sync v0.5.0 Compiling embedded-hal-bus v0.1.0 Compiling display-interface-spi v0.4.1 Compiling accelerometer v0.12.0 Compiling cipher v0.4.4 Compiling ccm v0.4.3 Compiling float-cmp v0.9.0 Compiling display-interface-i2c v0.4.0 Compiling usb-device v0.3.2 Compiling hash32 v0.2.1 Compiling byte v0.2.7 Compiling micromath v2.1.0 Compiling linked_list_allocator v0.10.5 Compiling hash32-derive v0.1.1 Compiling num_enum v0.7.2 Compiling examples v0.0.0 (/home/tomoyan/my_projects/esp-hal/examples) Compiling lis3dh-async v0.9.2 Compiling esp-alloc v0.3.0 (/home/tomoyan/my_projects/esp-hal/esp-alloc) Compiling embedded-graphics v0.8.1 Compiling usbd-serial v0.2.2 Compiling ssd1306 v0.8.4 Compiling ieee802154 v0.6.1 Compiling embassy-time v0.3.0 Compiling aes v0.8.4 Compiling p192 v0.13.0 Compiling p256 v0.13.2 Compiling smart-leds v0.4.0 Compiling hmac v0.12.1 Compiling sha2 v0.10.8 Compiling static_cell v2.1.0 Compiling embassy-futures v0.1.1 Compiling hex-literal v0.4.1 Compiling esp-hal-smartled v0.10.0 (/home/tomoyan/my_projects/esp-hal/esp-hal-smartled) Finished release [optimized + debuginfo] target(s) in 2m 39s
ESP32 のフラッシュへの書き込み
$ cargo xtask run-example esp-hal esp32 embassy_hello_world
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s Running `target/debug/xtask run-example esp-hal esp32 embassy_hello_world` [2024-05-24T04:57:00Z WARN xtask] Package 'esp-hal' specified, using 'examples' instead [2024-05-24T04:57:00Z INFO xtask] Building example '/home/tomoyan/my_projects/esp-hal/examples/src/bin/embassy_hello_world.rs' for 'esp32' [2024-05-24T04:57:00Z INFO xtask] Features: embassy,embassy-time-timg0,embassy-generic-timers [2024-05-24T04:57:00Z INFO xtask] Package: "src/bin/embassy_hello_world.rs" Finished release [optimized + debuginfo] target(s) in 0.30s Running `espflash flash --monitor target/xtensa-esp32-none-elf/release/embassy_hello_world` [2024-05-24T04:57:01Z INFO ] Serial port: '/dev/ttyUSB0' [2024-05-24T04:57:01Z INFO ] Connecting... [2024-05-24T04:57:01Z INFO ] Using flash stub Chip type: esp32 (revision v1.0) Crystal frequency: 40 MHz Flash size: 4MB Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None MAC address: 7c:9e:bd:36:81:8c App/part. size: 88,624/4,128,768 bytes, 2.15% [2024-05-24T04:57:03Z INFO ] Segment at address '0x1000' has not changed, skipping write [2024-05-24T04:57:03Z INFO ] Segment at address '0x8000' has not changed, skipping write [2024-05-24T04:57:03Z INFO ] Segment at address '0x10000' has not changed, skipping write [2024-05-24T04:57:03Z INFO ] Flashing has completed! Commands: CTRL+R Reset chip CTRL+C Exit ets Jun 8 2016 00:22:57 rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:7104 load:0x40078000,len:15576 load:0x40080400,len:4 ho 8 tail 4 room 4 load:0x40080404,len:3876 entry 0x4008064c 0x4008064c - core::ptr::read_volatile at /home/tomoyan/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1583 I (30) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader I (31) boot: compile time Jun 7 2023 07:48:23 I (33) boot: Multicore bootloader I (37) boot: chip revision: v1.0 I (41) boot.esp32: SPI Speed : 40MHz I (45) boot.esp32: SPI Mode : DIO I (50) boot.esp32: SPI Flash Size : 4MB I (54) boot: Enabling RNG early entropy source... I (60) boot: Partition Table: I (63) boot: ## Label Usage Type ST Offset Length I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (78) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (86) boot: 2 factory factory app 00 00 00010000 003f0000 I (93) boot: End of partition table I (97) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=01f1ch ( 7964) map I (109) esp_image: segment 1: paddr=00011f44 vaddr=3ffb0000 size=00004h ( 4) load I (114) esp_image: segment 2: paddr=00011f50 vaddr=40080000 size=01b54h ( 6996) load I (126) esp_image: segment 3: paddr=00013aac vaddr=00000000 size=0c56ch ( 50540) I (149) esp_image: segment 4: paddr=00020020 vaddr=400d0020 size=059e4h ( 23012) map I (159) boot: Loaded app from partition at offset 0x10000 I (159) boot: Disabling RNG early entropy source... Init! Bing! Hello world from embassy using esp-hal-async! Hello world from embassy using esp-hal-async! Hello world from embassy using esp-hal-async! Hello world from embassy using esp-hal-async! Hello world from embassy using esp-hal-async!
トラブルシューティング
error: package `esp-hal-embassy v0.4.0 (path)` cannot be built because it requires rustc 1.79.0 or newer, while the currently active rustc version is 1.77.0-nightly エラーが発生する🤪
$ cargo xtask build-examples esp-hal esp32 embassy_hello_world
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s Running `target/debug/xtask build-examples esp-hal esp32 embassy_hello_world` [2024-10-28T06:04:51Z WARN xtask] Package 'esp-hal' specified, using 'examples' instead [2024-10-28T06:04:51Z INFO xtask] Building example '/home/tomoyan/my_projects/_crates_src/esp-hal/examples/src/bin/embassy_hello_world.rs' for 'esp32' [2024-10-28T06:04:51Z INFO xtask] Features: embassy,esp-hal-embassy/integrated-timers [2024-10-28T06:04:51Z INFO xtask] Package: src/bin/embassy_hello_world.rs error: package `esp-hal-embassy v0.4.0 (/home/tomoyan/my_projects/_crates_src/esp-hal/esp-hal-embassy)` cannot be built because it requires rustc 1.79.0 or newer, while the currently active rustc version is 1.77.0-nightly Error: Failed to execute cargo subcommand
cannot be built because it requires rustc 1.79.0 or newer, while the currently active rustc version is 1.77.0-nightly
現在アクティブな rustc バージョンは 1.77.0-nightly ですが、rustc 1.79.0 以降が必要なためビルドできません。
Xtensa Rust toolchain を最新化してから実行し直す🤔
$ espup install
[info]: Installing the Espressif Rust ecosystem [info]: Checking Rust installation [info]: Installing RISC-V Rust targets ('riscv32imc-unknown-none-elf', 'riscv32imac-unknown-none-elf' and 'riscv32imafc-unknown-none-elf') for 'nightly' toolchain [info]: Installing GCC (xtensa-esp-elf) [warn]: Previous installation of GCC exists in: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928'. Reusing this installation [info]: Installing Xtensa LLVM [info]: Downloading 'idf_tool_xtensa_elf_clang.libs.tar.xz' [info]: Uninstalling Xtensa Rust toolchain [info]: Installing Xtensa Rust 1.82.0.1 toolchain [info]: Downloading 'rust.tar.xz' [info]: Creating symlink between '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-17.0.1_20240419/esp-clang/lib' and '/home/tomoyan/.espup/esp-clang' [info]: Installing 'rust' component for Xtensa Rust toolchain [info]: Downloading 'rust-src.tar.xz' [info]: Installing 'rust-src' component for Xtensa Rust toolchain [info]: Installation successfully completed! To get started, you need to set up some environment variables by running: '. /home/tomoyan/export-esp.sh' This step must be done every time you open a new terminal. See other methods for setting the environment in https://esp-rs.github.io/book/installation/riscv-and-xtensa.html#3-set-up-the-environment-variables
error: several matching instances of `target.'cfg(..)'.runner` in configurations エラーが発生する🤪
$ cargo xtask build-examples esp-hal esp32 embassy_hello_world
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.53s Running `target/debug/xtask build-examples esp-hal esp32 embassy_hello_world` [2024-05-24T21:46:30Z WARN xtask] Package 'esp-hal' specified, using 'examples' instead [2024-05-24T21:46:30Z INFO xtask] Building example '/home/tomoyan/my_projects/esp-hal/examples/src/bin/embassy_hello_world.rs' for 'esp32' [2024-05-24T21:46:30Z INFO xtask] Features: embassy,embassy-time-timg0,embassy-generic-timers [2024-05-24T21:46:30Z INFO xtask] Package: "src/bin/embassy_hello_world.rs" error: several matching instances of `target.'cfg(..)'.runner` in configurations first match `cfg(any(target_arch = "riscv32", target_arch = "xtensa", target_arch = "esp32"))` located in /home/tomoyan/.cargo/config.toml second match `cfg(target_arch = "xtensa")` located in /home/tomoyan/my_projects/esp-hal/examples/.cargo/config.toml Error: Failed to execute cargo subcommand
複数の一致する target.'cfg(..)'.runner インスタンスが存在するのでエラーになっている🤔
$ bat -p ~/.cargo/config.toml
[target.'cfg(any(target_arch = "riscv32", target_arch = "xtensa", target_arch = "esp32"))'] runner = "espflash flash --baud=921600 --monitor /dev/ttyUSB0"
$ bat -p ../esp-hal/examples/.cargo/config.toml
[alias] esp32 = "run --release --features=esp32 --target=xtensa-esp32-none-elf" esp32c2 = "run --release --features=esp32c2 --target=riscv32imc-unknown-none-elf" esp32c3 = "run --release --features=esp32c3 --target=riscv32imc-unknown-none-elf" esp32c6 = "run --release --features=esp32c6 --target=riscv32imac-unknown-none-elf" esp32h2 = "run --release --features=esp32h2 --target=riscv32imac-unknown-none-elf" esp32s2 = "run --release --features=esp32s2 --target=xtensa-esp32s2-none-elf" esp32s3 = "run --release --features=esp32s3 --target=xtensa-esp32s3-none-elf" [target.'cfg(target_arch = "riscv32")'] runner = "espflash flash --monitor" rustflags = [ "-C", "link-arg=-Tlinkall.x", "-C", "force-frame-pointers", ] [target.'cfg(target_arch = "xtensa")'] runner = "espflash flash --monitor" rustflags = [ # GNU LD "-C", "link-arg=-Wl,-Tlinkall.x", "-C", "link-arg=-nostartfiles", # LLD # "-C", "link-arg=-Tlinkall.x", # "-C", "linker=rust-lld", ] [env] ESP_LOGLEVEL = "info" [unstable] build-std = ["alloc", "core"]
ひとまず ~/.cargo/config.toml
をリネームするとエラーを回避できる😊
$ mv ~/.cargo/config.toml ~/.cargo/config.toml.bak
参考文献
関連文献
GitHub - esp-rs/espup: Tool for installing and maintaining ESP Rust ecosystem.
Introduction - The Rust on ESP Book
100日後にRustをちょっと知ってる人になる: [Day 25]cargo-generate
How can we share a bus between multiple drivers? · Issue #35 · rust-embedded/embedded-hal