rust:rust_on_esp_install

文書の過去の版を表示しています。


ESP32 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

参考: 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    

完了しました!

公式: 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 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 espup

または、cargo でビルドを行ってインストールする🤔

$ cargo install espup

    Updating crates.io index
  Downloaded espup v0.2.4
  Downloaded 1 crate (42.3 KB) in 1.09s
  Installing espup v0.2.4
  Downloaded tempfile v3.3.0
  Downloaded bzip2-sys v0.1.11+1.0.8
  Downloaded time-core v0.1.0
  Downloaded hmac v0.12.1
  Downloaded env_logger v0.10.0
  Downloaded directories-next v2.0.0
  Downloaded termcolor v1.1.3
  Downloaded itoa v1.0.5
  Downloaded guess_host_triple v0.1.3
  Downloaded directories v4.0.1
  Downloaded constant_time_eq v0.1.5
  Downloaded time v0.3.17
  Downloaded syn v1.0.107
  Downloaded tinyvec v1.6.0
  Downloaded time-macros v0.2.6
  Downloaded is_ci v1.1.1
  Downloaded embuild v0.31.0
  Downloaded tokio-native-tls v0.3.0
  Downloaded tracing v0.1.37
  Downloaded which v4.3.0
  Downloaded bytes v1.3.0
  Downloaded untrusted v0.7.1
  Downloaded miniz_oxide v0.6.2
  Downloaded owo-colors v3.5.0
  Downloaded smawk v0.3.1
  Downloaded mio v0.8.5
  Downloaded object v0.30.1
  Downloaded supports-hyperlinks v1.2.0
  Downloaded tinyvec_macros v0.1.0
  Downloaded tar v0.4.38
  Downloaded heck v0.4.0
  Downloaded dirs-sys v0.3.7
  Downloaded openssl v0.10.45
  Downloaded num_cpus v1.15.0
  Downloaded once_cell v1.17.0
  Downloaded native-tls v0.2.11
  Downloaded webpki-roots v0.22.6
  Downloaded bzip2 v0.4.4
  Downloaded xz2 v0.1.7
  Downloaded base64ct v1.5.3
  Downloaded cipher v0.3.0
  Downloaded tokio v1.24.0
  Downloaded is-terminal v0.4.2
  Downloaded adler v1.0.2
  Downloaded addr2line v0.19.0
  Downloaded pkg-config v0.3.26
  Downloaded openssl-sys v0.9.80
  Downloaded ryu v1.0.12
  Downloaded spin v0.5.2
  Downloaded sct v0.7.0
  Downloaded update-informer v0.6.0
  Downloaded strum v0.24.1
  Downloaded atty v0.2.14
  Downloaded serde_urlencoded v0.7.1
  Downloaded aes v0.7.5
  Downloaded typenum v1.16.0
  Downloaded url v2.3.1
  Downloaded version_check v0.9.4
  Downloaded memchr v2.5.0
  Downloaded try-lock v0.2.3
  Downloaded unicode-ident v1.0.6
  Downloaded unicode-width v0.1.10
  Downloaded unicode-bidi v0.3.8
  Downloaded unicode-linebreak v0.1.4
  Downloaded hyper-tls v0.5.0
  Downloaded proc-macro-error-attr v1.0.4
  Downloaded openssl-probe v0.1.5
  Downloaded openssl-macros v0.1.0
  Downloaded lazy_static v1.4.0
  Downloaded futures-io v0.3.25
  Downloaded toml v0.5.10
  Downloaded tower-service v0.3.2
  Downloaded log v0.4.17
  Downloaded httparse v1.8.0
  Downloaded sha2 v0.10.6
  Downloaded clap_derive v4.0.21
  Downloaded hyper v0.14.23
  Downloaded anyhow v1.0.68
  Downloaded ahash v0.7.6
  Downloaded jobserver v0.1.25
  Downloaded byteorder v1.4.3
  Downloaded tokio-util v0.7.4
  Downloaded serde_json v1.0.91
  Downloaded pin-utils v0.1.0
  Downloaded miette-derive v5.5.0
  Downloaded miette v5.5.0
  Downloaded remove_dir_all v0.7.0
  Downloaded pbkdf2 v0.11.0
  Downloaded supports-color v1.3.1
  Downloaded opaque-debug v0.3.0
  Downloaded strsim v0.10.0
  Downloaded proc-macro2 v1.0.49
  Downloaded password-hash v0.4.2
  Downloaded sha1 v0.10.5
  Downloaded pin-project-lite v0.2.9
  Downloaded rustversion v1.0.11
  Downloaded proc-macro-error v1.0.4
  Downloaded slab v0.4.7
  Downloaded rand_core v0.6.4
  Downloaded quote v1.0.23
  Downloaded digest v0.10.6
  Downloaded textwrap v0.15.2
  Downloaded rustc-demangle v0.1.21
  Downloaded os_str_bytes v6.4.1
  Downloaded terminal_size v0.1.17
  Downloaded autocfg v1.1.0
  Downloaded subtle v2.4.1
  Downloaded regex v1.7.0
  Downloaded semver v1.0.16
  Downloaded percent-encoding v2.2.0
  Downloaded shlex v1.1.0
  Downloaded aho-corasick v0.7.20
  Downloaded supports-unicode v1.0.2
  Downloaded strum_macros v0.24.3
  Downloaded regex-syntax v0.6.28
  Downloaded reqwest v0.11.13
  Downloaded socket2 v0.4.7
  Downloaded thiserror-impl v1.0.38
  Downloaded tracing-core v0.1.30
  Downloaded thiserror v1.0.38
  Downloaded remove_dir_all v0.5.3
  Downloaded ureq v2.6.1
  Downloaded zstd-safe v5.0.2+zstd.1.5.2
  Downloaded serde_derive v1.0.152
  Downloaded want v0.3.0
  Downloaded serde v1.0.152
  Downloaded zip v0.6.3
  Downloaded linux-raw-sys v0.1.4
  Downloaded rustls v0.20.7
  Downloaded webpki v0.22.0
  Downloaded zstd v0.11.2+zstd.1.5.2
  Downloaded rustix v0.36.6
  Downloaded backtrace v0.3.67
  Downloaded libc v0.2.139
  Downloaded futures-sink v0.3.25
  Downloaded dirs-sys-next v0.1.2
  Downloaded crypto-common v0.1.6
  Downloaded block-buffer v0.10.3
  Downloaded console v0.15.4
  Downloaded cc v1.0.78
  Downloaded cfg-if v1.0.0
  Downloaded base64 v0.13.1
  Downloaded clap v4.0.32
  Downloaded errno v0.2.8
  Downloaded clap_lex v0.3.0
  Downloaded filetime v0.2.19
  Downloaded foreign-types v0.3.2
  Downloaded flate2 v1.0.25
  Downloaded fastrand v1.8.0
  Downloaded xattr v0.2.3
  Downloaded cpufeatures v0.2.5
  Downloaded h2 v0.3.15
  Downloaded fnv v1.0.7
  Downloaded futures-util v0.3.25
  Downloaded getrandom v0.2.8
  Downloaded mime v0.3.16
  Downloaded dirs v4.0.0
  Downloaded generic-array v0.14.6
  Downloaded bitflags v1.3.2
  Downloaded futures-core v0.3.25
  Downloaded crc32fast v1.3.2
  Downloaded hashbrown v0.12.3
  Downloaded http v0.2.8
  Downloaded idna v0.3.0
  Downloaded either v1.8.0
  Downloaded httpdate v1.0.2
  Downloaded humantime v2.1.0
  Downloaded futures-channel v0.3.25
  Downloaded http-body v0.4.5
  Downloaded ipnet v2.7.0
  Downloaded form_urlencoded v1.1.0
  Downloaded io-lifetimes v1.0.3
  Downloaded futures-task v0.3.25
  Downloaded foreign-types-shared v0.1.1
  Downloaded indexmap v1.9.2
  Downloaded unicode-normalization v0.1.22
  Downloaded lzma-sys v0.1.20
  Downloaded zstd-sys v2.0.4+zstd.1.5.2
  Downloaded encoding_rs v0.8.31
  Downloaded gimli v0.27.0
  Downloaded ring v0.16.20
  Downloaded openssl-src v111.24.0+1.1.1s
  Downloaded 182 crates (25.1 MB) in 13.92s (largest was `openssl-src` at 5.1 MB)
    Compiling libc v0.2.139
    Compiling cfg-if v1.0.0
    Compiling version_check v0.9.4
    Compiling proc-macro2 v1.0.49
    Compiling unicode-ident v1.0.6
    Compiling quote v1.0.23
    Compiling syn v1.0.107
    Compiling memchr v2.5.0
    Compiling jobserver v0.1.25
    Compiling autocfg v1.1.0
    Compiling cc v1.0.78
    Compiling once_cell v1.17.0
    Compiling pkg-config v0.3.26
    Compiling log v0.4.17
    Compiling typenum v1.16.0
    Compiling itoa v1.0.5
    Compiling generic-array v0.14.6
    Compiling openssl-src v111.24.0+1.1.1s
    Compiling serde_derive v1.0.152
    Compiling pin-project-lite v0.2.9
    Compiling bitflags v1.3.2
    Compiling openssl-sys v0.9.80
    Compiling ring v0.16.20
    Compiling futures-core v0.3.25
    Compiling bytes v1.3.0
    Compiling serde v1.0.152
    Compiling tokio v1.24.0
    Compiling ahash v0.7.6
    Compiling getrandom v0.2.8
    Compiling mio v0.8.5
    Compiling num_cpus v1.15.0
    Compiling socket2 v0.4.7
    Compiling slab v0.4.7
    Compiling tinyvec_macros v0.1.0
    Compiling untrusted v0.7.1
    Compiling spin v0.5.2
    Compiling futures-task v0.3.25
    Compiling subtle v2.4.1
    Compiling adler v1.0.2
    Compiling miniz_oxide v0.6.2
    Compiling tinyvec v1.6.0
    Compiling aho-corasick v0.7.20
    Compiling crypto-common v0.1.6
    Compiling block-buffer v0.10.3
    Compiling zstd-sys v2.0.4+zstd.1.5.2
    Compiling tracing-core v0.1.30
    Compiling indexmap v1.9.2
    Compiling futures-util v0.3.25
    Compiling crc32fast v1.3.2
    Compiling fnv v1.0.7
    Compiling regex-syntax v0.6.28
    Compiling openssl v0.10.45
    Compiling io-lifetimes v1.0.3
    Compiling ryu v1.0.12
    Compiling foreign-types-shared v0.1.1
    Compiling percent-encoding v2.2.0
    Compiling form_urlencoded v1.1.0
    Compiling regex v1.7.0
    Compiling foreign-types v0.3.2
    Compiling http v0.2.8
    Compiling tracing v0.1.37
    Compiling digest v0.10.6
    Compiling unicode-normalization v0.1.22
    Compiling hashbrown v0.12.3
    Compiling openssl-macros v0.1.0
    Compiling proc-macro-error-attr v1.0.4
    Compiling futures-io v0.3.25
    Compiling unicode-bidi v0.3.8
    Compiling rustix v0.36.6
    Compiling httparse v1.8.0
    Compiling heck v0.4.0
    Compiling serde_json v1.0.91
    Compiling native-tls v0.2.11
    Compiling pin-utils v0.1.0
    Compiling rustversion v1.0.11
    Compiling futures-channel v0.3.25
    Compiling cpufeatures v0.2.5
    Compiling futures-sink v0.3.25
    Compiling tokio-util v0.7.4
    Compiling idna v0.3.0
    Compiling unicode-linebreak v0.1.4
    Compiling webpki v0.22.0
    Compiling bzip2-sys v0.1.11+1.0.8
    Compiling dirs-sys v0.3.7
    Compiling atty v0.2.14
    Compiling proc-macro-error v1.0.4
    Compiling linux-raw-sys v0.1.4
    Compiling zstd-safe v5.0.2+zstd.1.5.2
    Compiling rustls v0.20.7
    Compiling try-lock v0.2.3
    Compiling openssl-probe v0.1.5
    Compiling thiserror v1.0.38
    Compiling want v0.3.0
    Compiling h2 v0.3.15
    Compiling flate2 v1.0.25
    Compiling url v2.3.1
    Compiling http-body v0.4.5
    Compiling sct v0.7.0
    Compiling thiserror-impl v1.0.38
    Compiling lzma-sys v0.1.20
    Compiling backtrace v0.3.67
    Compiling time-core v0.1.0
    Compiling semver v1.0.16
    Compiling base64ct v1.5.3
    Compiling unicode-width v0.1.10
    Compiling rand_core v0.6.4
    Compiling anyhow v1.0.68
    Compiling tower-service v0.3.2
    Compiling base64 v0.13.1
    Compiling gimli v0.27.0
    Compiling httpdate v1.0.2
    Compiling encoding_rs v0.8.31
    Compiling hyper v0.14.23
    Compiling password-hash v0.4.2
    Compiling time-macros v0.2.6
    Compiling addr2line v0.19.0
    Compiling strum_macros v0.24.3
    Compiling is-terminal v0.4.2
    Compiling webpki-roots v0.22.6
    Compiling sha2 v0.10.6
    Compiling hmac v0.12.1
    Compiling cipher v0.3.0
    Compiling object v0.30.1
    Compiling filetime v0.2.19
    Compiling remove_dir_all v0.5.3
    Compiling termcolor v1.1.3
    Compiling is_ci v1.1.1
    Compiling either v1.8.0
    Compiling opaque-debug v0.3.0
    Compiling fastrand v1.8.0
    Compiling rustc-demangle v0.1.21
    Compiling os_str_bytes v6.4.1
    Compiling smawk v0.3.1
    Compiling textwrap v0.15.2
    Compiling clap_lex v0.3.0
    Compiling time v0.3.17
    Compiling tempfile v3.3.0
    Compiling aes v0.7.5
    Compiling which v4.3.0
    Compiling supports-color v1.3.1
    Compiling strum v0.24.1
    Compiling pbkdf2 v0.11.0
    Compiling ureq v2.6.1
    Compiling clap_derive v4.0.21
    Compiling dirs v4.0.0
    Compiling directories v4.0.1
    Compiling supports-hyperlinks v1.2.0
    Compiling supports-unicode v1.0.2
    Compiling sha1 v0.10.5
    Compiling serde_urlencoded v0.7.1
    Compiling miette-derive v5.5.0
    Compiling errno v0.2.8
    Compiling remove_dir_all v0.7.0
    Compiling terminal_size v0.1.17
    Compiling xattr v0.2.3
    Compiling dirs-sys-next v0.1.2
    Compiling constant_time_eq v0.1.5
    Compiling ipnet v2.7.0
    Compiling lazy_static v1.4.0
    Compiling byteorder v1.4.3
    Compiling strsim v0.10.0
    Compiling shlex v1.1.0
    Compiling humantime v2.1.0
    Compiling owo-colors v3.5.0
    Compiling mime v0.3.16
    Compiling env_logger v0.10.0
    Compiling embuild v0.31.0
    Compiling miette v5.5.0
    Compiling clap v4.0.32
    Compiling console v0.15.4
    Compiling directories-next v2.0.0
    Compiling tar v0.4.38
    Compiling guess_host_triple v0.1.3
    Compiling update-informer v0.6.0
    Compiling toml v0.5.10
    Compiling bzip2 v0.4.4
    Compiling zstd v0.11.2+zstd.1.5.2
    Compiling zip v0.6.3
    Compiling xz2 v0.1.7
    Compiling tokio-native-tls v0.3.0
    Compiling hyper-tls v0.5.0
    Compiling reqwest v0.11.13
    Compiling espup v0.2.4
    Finished release [optimized] target(s) in 6m 58s
  Installing /home/tomoyan/.cargo/bin/espup
   Installed package `espup v0.2.4` (executable `espup`)

動作確認する😉

$ espup --version

espup 0.5.0

公式: 2. Install Necessary Toolchains - RISC-V and Xtensa targets - The Rust on ESP Book 翻訳

Fedora

$ espup install  

[2023-09-10T07:14:54Z INFO ] 💽  Installing the Espressif Rust ecosystem
[2023-09-10T07:14:54Z INFO ] 💡  Querying GitHub API: 'https://api.github.com/repos/esp-rs/rust-build/releases/latest'
[2023-09-10T07:14:55Z INFO ] 💡  Querying GitHub API: 'https://api.github.com/repos/esp-rs/rust-build/releases'
[2023-09-10T07:14:58Z INFO ] 🔧  Checking Rust installation
[2023-09-10T07:15:05Z INFO ] 🔧  Installing Xtensa Rust 1.72.0.0 toolchain
[2023-09-10T07:15:05Z INFO ] 🔧  Creating directory: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-12.2.0_20230208'
[2023-09-10T07:15:05Z INFO ] 📥  Downloading file '/tmp/.tmpFuWq17/rust.tar.xz' from 'https://github.com/esp-rs/rust-build/releases/download/v1.72.0.0/rust-1.72.0.0-x86_64-unknown-linux-gnu.tar.xz'
[2023-09-10T07:15:05Z INFO ] 🔧  Installing RISC-V targets ('riscv32imc-unknown-none-elf' and 'riscv32imac-unknown-none-elf') for 'nightly' toolchain
[2023-09-10T07:15:05Z INFO ] 📥  Downloading file '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf.tar.xz' from 'https://github.com/espressif/crosstool-NG/releases/download/esp-12.2.0_20230208/xtensa-esp32s3-elf-12.2.0_20230208-x86_64-linux-gnu.tar.xz'
[2023-09-10T07:15:05Z INFO ] 🔧  Creating directory: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf/esp-12.2.0_20230208'
[2023-09-10T07:15:05Z INFO ] 📥  Downloading file '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf.tar.xz' from 'https://github.com/espressif/crosstool-NG/releases/download/esp-12.2.0_20230208/xtensa-esp32-elf-12.2.0_20230208-x86_64-linux-gnu.tar.xz'
[2023-09-10T07:15:05Z INFO ] 🔧  Installing Xtensa elf Clang
[2023-09-10T07:15:05Z INFO ] 🔧  Creating directory: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-16.0.0-20230516'
[2023-09-10T07:15:05Z INFO ] 📥  Downloading file '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-16.0.0-20230516/idf_tool_xtensa_elf_clang.tar.xz' from 'https://github.com/espressif/llvm-project/releases/download/esp-16.0.0-20230516/libs_llvm-esp-16.0.0-20230516-linux-amd64.tar.xz'
[2023-09-10T07:15:05Z INFO ] 🔧  Creating directory: '/home/tomoyan/.rustup/toolchains/esp/riscv32-esp-elf/esp-12.2.0_20230208'
[2023-09-10T07:15:05Z INFO ] 📥  Downloading file '/home/tomoyan/.rustup/toolchains/esp/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf.tar.xz' from 'https://github.com/espressif/crosstool-NG/releases/download/esp-12.2.0_20230208/riscv32-esp-elf-12.2.0_20230208-x86_64-linux-gnu.tar.xz'
[2023-09-10T07:15:05Z INFO ] 🔧  Creating directory: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s2-elf/esp-12.2.0_20230208'
[2023-09-10T07:15:05Z INFO ] 📥  Downloading file '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf.tar.xz' from 'https://github.com/espressif/crosstool-NG/releases/download/esp-12.2.0_20230208/xtensa-esp32s2-elf-12.2.0_20230208-x86_64-linux-gnu.tar.xz'
[2023-09-10T07:17:03Z INFO ] 🔧  Uncompressing tar.xz file to '/home/tomoyan/.rustup/toolchains/esp/riscv32-esp-elf/esp-12.2.0_20230208'
[2023-09-10T07:17:49Z INFO ] 🔧  Uncompressing tar.xz file to '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s2-elf/esp-12.2.0_20230208'
[2023-09-10T07:18:14Z INFO ] 🔧  Uncompressing tar.xz file to '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-16.0.0-20230516'
[2023-09-10T07:18:36Z INFO ] 🔧  Uncompressing tar.xz file to '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf/esp-12.2.0_20230208'
[2023-09-10T07:18:46Z INFO ] 🔧  Uncompressing tar.xz file to '/tmp/.tmpFuWq17'
[2023-09-10T07:18:50Z INFO ] 🔧  Uncompressing tar.xz file to '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-12.2.0_20230208'
[2023-09-10T07:19:02Z INFO ] 🔧  Installing 'rust' component for Xtensa Rust toolchain
[2023-09-10T07:19:08Z INFO ] 📥  Downloading file '/tmp/.tmpQmbWpF/rust-src.tar.xz' from 'https://github.com/esp-rs/rust-build/releases/download/v1.72.0.0/rust-src-1.72.0.0.tar.xz'
[2023-09-10T07:19:11Z INFO ] 🔧  Uncompressing tar.xz file to '/tmp/.tmpQmbWpF'
[2023-09-10T07:19:11Z INFO ] 🔧  Installing 'rust-src' component for Xtensa Rust toolchain
[2023-09-10T07:20:08Z INFO ] 🔧  Creating export file
[2023-09-10T07:20:08Z WARN ] 💡  Please, set up the environment variables by running: '. /home/tomoyan/export-esp.sh'
[2023-09-10T07:20:08Z WARN ] ⚠️   This step must be done every time you open a new terminal.
[2023-09-10T07:20:08Z INFO ] ✅  Installation successfully completed!

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

[2023-12-01T08:17:42Z WARN ] ⚠️   A new version of espup ('v0.9.0') is available.
[2023-12-01T08:17:42Z INFO ] 💽  Installing the Espressif Rust ecosystem
[2023-12-01T08:17:42Z INFO ] 🔧  Checking Rust installation
[2023-12-01T08:17:43Z INFO ] 🔧  Installing RISC-V targets ('riscv32imc-unknown-none-elf' and 'riscv32imac-unknown-none-elf') for 'nightly' toolchain
[2023-12-01T08:17:43Z WARN ] ⚠️   Previous installation of GCC exists in: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s2-elf/esp-12.2.0_20230208'. Reusing this installation.
[2023-12-01T08:17:43Z WARN ] ⚠️   Previous installation of GCC exists in: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-12.2.0_20230208'. Reusing this installation.
[2023-12-01T08:17:43Z WARN ] ⚠️   Previous installation of GCC exists in: '/home/tomoyan/.rustup/toolchains/esp/riscv32-esp-elf/esp-12.2.0_20230208'. Reusing this installation.
[2023-12-01T08:17:43Z WARN ] ⚠️   Previous installation of LLVM exists in: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-15.0.0-20221201'. Reusing this installation.
[2023-12-01T08:17:43Z WARN ] ⚠️   Previous installation of GCC exists in: '/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf/esp-12.2.0_20230208'. Reusing this installation.
[2023-12-01T08:17:43Z INFO ] 🔧  Uninstalling Xtensa Rust toolchain
[2023-12-01T08:17:43Z INFO ] 🔧  Installing Xtensa Rust 1.67.0.0 toolchain
[2023-12-01T08:17:43Z INFO ] 📥  Downloading file '/tmp/.tmp55nX1q/rust.tar.xz' from 'https://github.com/esp-rs/rust-build/releases/download/v1.67.0.0/rust-1.67.0.0-x86_64-unknown-linux-gnu.tar.xz'
[2023-12-01T08:18:54Z INFO ] 🔧  Uncompressing tar.xz file to '/tmp/.tmp55nX1q'
[2023-12-01T08:19:12Z INFO ] 🔧  Installing 'rust' component for Xtensa Rust toolchain
[2023-12-01T08:19:18Z INFO ] 📥  Downloading file '/tmp/.tmpBjaNCL/rust-src.tar.xz' from 'https://github.com/esp-rs/rust-build/releases/download/v1.67.0.0/rust-src-1.67.0.0.tar.xz'
[2023-12-01T08:19:21Z INFO ] 🔧  Uncompressing tar.xz file to '/tmp/.tmpBjaNCL'
[2023-12-01T08:19:21Z INFO ] 🔧  Installing 'rust-src' component for Xtensa Rust toolchain
[2023-12-01T08:20:24Z INFO ] 🔧  Creating export file
[2023-12-01T08:20:24Z WARN ] 💡  Please, set up the environment variables by running: '. /home/tomoyan/export-esp.sh'
[2023-12-01T08:20:24Z WARN ] ⚠️   This step must be done every time you open a new terminal.
[2023-12-01T08:20:24Z INFO ] ✅  Installation successfully completed!

ツールチェーンは esp でインストールされている🤔

$ rustup toolchain list

stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu
1.65-x86_64-unknown-linux-gnu (default)
esp

esp ツールチェーンのコンパイラバージョンを確認する😉

$ rustup run esp rustc -V

rustc 1.67.0-nightly (725e31c21 2023-01-25)

Fedora

$ cat ~/export-esp.sh

export PATH="/home/tomoyan/.rustup/toolchains/esp/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin:$PATH"
export PATH="/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf/bin:$PATH"
export LIBCLANG_PATH="/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-16.0.0-20230516/esp-clang/lib"
export PATH="/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin:$PATH"
export PATH="/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin:$PATH"

$ . ~/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 Development Requirements - The Rust on ESP Book 翻訳

Fedora

$ python -VV

Python 3.11.6 (main, Oct  3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)]

$ git version

git version 2.41.0

$ cargo install ldproxy

    Updating crates.io index
  Downloaded ldproxy v0.3.3
  Downloaded 1 crate (10.3 KB) in 1.87s
     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のインストール

$ cargo install cargo-generate

    Updating crates.io index
  Downloaded cargo-generate v0.20.0
  Downloaded 1 crate (98.0 KB) in 0.74s
  Installing cargo-generate v0.20.0
    Updating crates.io index
  Downloaded ahash v0.8.11
  Downloaded faster-hex v0.9.0
  Downloaded deranged v0.3.11
  Downloaded env_filter v0.1.0
  Downloaded cc v1.0.96
  Downloaded auth-git2 v0.5.4
  Downloaded env_logger v0.11.3
  Downloaded fs-err v2.11.0
  Downloaded gix-actor v0.31.1
  Downloaded gix-lock v13.1.1
  Downloaded getrandom v0.2.14
  Downloaded hashbrown v0.14.5
  Downloaded gix-validate v0.8.4
  Downloaded gix-config-value v0.14.6
  Downloaded gix-glob v0.16.2
  Downloaded gix-fs v0.10.2
  Downloaded gix-config v0.36.1
  Downloaded gix-utils v0.1.12
  Downloaded gix-hash v0.14.2
  Downloaded gix-date v0.8.5
  Downloaded gix-tempfile v13.1.1
  Downloaded gix-object v0.42.1
  Downloaded gix-trace v0.1.9
  Downloaded gix-sec v0.10.6
  Downloaded git2 v0.18.3
  Downloaded gix-ref v0.43.0
  Downloaded gix-path v0.10.7
  Downloaded gix-features v0.38.1
  Downloaded pest_meta v2.7.10
  Downloaded num_threads v0.1.7
  Downloaded normpath v1.2.0
  Downloaded thin-vec v0.2.13
  Downloaded pest_generator v2.7.10
  Downloaded num-conv v0.1.0
  Downloaded jobserver v0.1.31
  Downloaded pest_derive v2.7.10
  Downloaded openssl-sys v0.9.102
  Downloaded serde_derive v1.0.200
  Downloaded ignore v0.4.22
  Downloaded time v0.3.36
  Downloaded time-macros v0.2.18
  Downloaded rhai_codegen v2.1.0
  Downloaded prodash v28.0.0
  Downloaded pest v2.7.10
  Downloaded zerocopy v0.7.32
  Downloaded rhai v1.17.1
  Downloaded libgit2-sys v0.16.2+1.7.2
  Downloaded libz-sys v1.1.16
  Downloaded 48 crates (7.9 MB) in 3.97s (largest was `libz-sys` at 4.0 MB)
   Compiling proc-macro2 v1.0.81
   Compiling libc v0.2.154
   Compiling unicode-ident v1.0.12
   Compiling thiserror v1.0.59
   Compiling memchr v2.7.2
   Compiling once_cell v1.19.0
   Compiling quote v1.0.36
   Compiling autocfg v1.2.0
   Compiling syn v2.0.60
   Compiling aho-corasick v1.1.3
   Compiling regex-syntax v0.8.3
   Compiling cfg-if v1.0.0
   Compiling tinyvec_macros v0.1.1
   Compiling tinyvec v1.6.0
   Compiling jobserver v0.1.31
   Compiling cc v1.0.96
   Compiling regex-automata v0.4.6
   Compiling unicode-normalization v0.1.23
   Compiling pkg-config v0.3.30
   Compiling bitflags v2.5.0
   Compiling thiserror-impl v1.0.59
   Compiling fastrand v2.1.0
   Compiling serde v1.0.200
   Compiling vcpkg v0.2.15
   Compiling serde_derive v1.0.200
   Compiling bstr v1.9.1
   Compiling gix-trace v0.1.9
   Compiling same-file v1.0.6
   Compiling powerfmt v0.2.0
   Compiling num-conv v0.1.0
   Compiling time-core v0.1.2
   Compiling time-macros v0.2.18
   Compiling deranged v0.3.11
   Compiling walkdir v2.5.0
   Compiling gix-utils v0.1.12
   Compiling faster-hex v0.9.0
   Compiling itoa v1.0.11
   Compiling num_threads v0.1.7
   Compiling time v0.3.36
   Compiling gix-hash v0.14.2
   Compiling libz-sys v1.1.16
   Compiling openssl-sys v0.9.102
   Compiling rustix v0.38.34
   Compiling sha1_smol v1.0.0
   Compiling smallvec v1.13.2
   Compiling prodash v28.0.0
   Compiling gix-features v0.38.1
   Compiling lock_api v0.4.12
   Compiling version_check v0.9.4
   Compiling linux-raw-sys v0.4.13
   Compiling crunchy v0.2.2
   Compiling parking_lot_core v0.9.10
   Compiling ucd-trie v0.1.6
   Compiling pest v2.7.10
   Compiling regex v1.10.4
   Compiling libssh2-sys v0.3.0
   Compiling getrandom v0.2.14
   Compiling num-traits v0.2.18
   Compiling winnow v0.6.7
   Compiling static_assertions v1.1.0
   Compiling tiny-keccak v2.0.2
   Compiling percent-encoding v2.3.1
   Compiling log v0.4.21
   Compiling scopeguard v1.2.0
   Compiling pest_meta v2.7.10
   Compiling tempfile v3.10.1
   Compiling lazy_static v1.4.0
   Compiling home v0.5.9
   Compiling crossbeam-utils v0.8.19
   Compiling gix-path v0.10.7
   Compiling parking_lot v0.12.2
   Compiling pest_generator v2.7.10
   Compiling gix-fs v0.10.2
   Compiling gix-date v0.8.5
   Compiling libgit2-sys v0.16.2+1.7.2
   Compiling anstyle v1.0.6
   Compiling either v1.11.0
   Compiling unicode-bidi v0.3.15
   Compiling itertools v0.10.5
   Compiling idna v0.5.0
   Compiling gix-actor v0.31.1
   Compiling gix-tempfile v13.1.1
   Compiling pest_derive v2.7.10
   Compiling const-random-macro v0.1.16
   Compiling form_urlencoded v1.2.1
   Compiling kstring v2.0.0
   Compiling rand_core v0.6.4
   Compiling smartstring v1.0.1
   Compiling ahash v0.8.11
   Compiling gix-validate v0.8.4
   Compiling liquid-derive v0.26.4
   Compiling hashbrown v0.14.5
   Compiling unicode-width v0.1.12
   Compiling ppv-lite86 v0.2.17
   Compiling doc-comment v0.3.3
   Compiling option-ext v0.2.0
   Compiling anymap2 v0.13.0
   Compiling portable-atomic v1.6.0
   Compiling equivalent v1.0.1
   Compiling utf8parse v0.2.1
   Compiling bitflags v1.3.2
   Compiling nix v0.26.4
   Compiling anstyle-parse v0.2.3
   Compiling indexmap v2.2.6
   Compiling liquid-core v0.26.4
   Compiling dirs-sys v0.4.1
   Compiling rand_chacha v0.3.1
   Compiling console v0.15.8
   Compiling gix-object v0.42.1
   Compiling crossbeam-epoch v0.9.18
   Compiling const-random v0.1.18
   Compiling url v2.5.0
   Compiling gix-lock v13.1.1
   Compiling toml_datetime v0.6.5
   Compiling serde_spanned v0.6.5
   Compiling cvt v0.1.2
   Compiling memmap2 v0.9.4
   Compiling fs-err v2.11.0
   Compiling zerocopy v0.7.32
   Compiling unicode-segmentation v1.11.0
   Compiling anstyle-query v1.0.2
   Compiling openssl-probe v0.1.5
   Compiling paste v1.0.14
   Compiling anyhow v1.0.82
   Compiling heck v0.5.0
   Compiling clap_lex v0.7.0
   Compiling names v0.14.0
   Compiling semver v1.0.22
   Compiling colorchoice v1.0.0
   Compiling anstream v0.6.13
   Compiling clap_builder v4.5.2
   Compiling clap_derive v4.5.4
   Compiling liquid-lib v0.26.4
   Compiling gix-ref v0.43.0
   Compiling fs_at v0.1.10
   Compiling toml_edit v0.22.12
   Compiling crossbeam-deque v0.8.5
   Compiling rand v0.8.5
   Compiling dirs v5.0.1
   Compiling gix-config-value v0.14.6
   Compiling gix-glob v0.16.2
   Compiling globset v0.4.14
   Compiling env_filter v0.1.0
   Compiling gix-sec v0.10.6
   Compiling rhai_codegen v2.1.0
   Compiling path-dedot v3.1.1
   Compiling terminal-prompt v0.2.3
   Compiling shell-words v1.1.0
   Compiling zeroize v1.7.0
   Compiling number_prefix v0.4.0
   Compiling normpath v1.2.0
   Compiling humantime v2.1.0
   Compiling unicode-bom v2.0.3
   Compiling thin-vec v0.2.13
   Compiling env_logger v0.11.3
   Compiling rhai v1.17.1
   Compiling gix-config v0.36.1
   Compiling remove_dir_all v0.8.2
   Compiling indicatif v0.17.8
   Compiling dialoguer v0.11.0
   Compiling path-absolutize v3.1.1
   Compiling ignore v0.4.22
   Compiling toml v0.8.12
   Compiling liquid v0.26.4
   Compiling clap v4.5.4
   Compiling sanitize-filename v0.5.0
   Compiling git2 v0.18.3
   Compiling auth-git2 v0.5.4
   Compiling cargo-generate v0.20.0
    Finished release [optimized] target(s) in 6m 03s
   Replacing /home/tomoyan/.cargo/bin/cargo-generate
    Replaced package `cargo-generate v0.18.5` with `cargo-generate v0.20.0` (executable `cargo-generate`)

動作確認

$ cargo generate -V

cargo generate-generate 0.20.0

プロジェクトの作成

  • esp-template - no_std テンプレート
  • esp-idf-template - std テンプレート

「お気に入り `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:

予めテンプレートを 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 repositoryDone! 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 repositoryDone! New project created /home/tomoyan/my_projects/haruo_std_esp32

公式: GitHub - cargo-bins/cargo-binstall: Binary installation for rust projects 翻訳

$ 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.xtqH6KKqFP
+ 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=05f90e651dd151df76e1b5c050cfb117ff47cbb6 ts=2023-11-18T11:23:35.531Z run=6913588356
 WARN The package cargo-binstall v1.4.6 (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 13.141395279s
+ CARGO_HOME=/home/tomoyan/.cargo
+ [[ :/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin:/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin:/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-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-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin:/home/tomoyan/.rustup/toolchains/esp/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf/bin:/home/tomoyan/.rustup/toolchains/esp/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin:/home/tomoyan/.cargo/bin: == *\:\/\h\o\m\e\/\t\o\m\o\y\a\n\/\.\c\a\r\g\o\/\b\i\n\:* ]]

動作確認🤔

$ cargo binstall -V

1.4.6

公式: 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
  Installing espflash v2.1.0
    Updating crates.io index
   Compiling proc-macro2 v1.0.70
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.150
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.1.0
   Compiling bitflags v2.4.1
   Compiling lock_api v0.4.11
   Compiling scopeguard v1.2.0
   Compiling quote v1.0.33
   Compiling syn v2.0.39
   Compiling cc v1.0.83
   Compiling rustix v0.38.25
   Compiling serde v1.0.193
   Compiling linux-raw-sys v0.4.11
   Compiling memchr v2.6.4
   Compiling syn v1.0.109
   Compiling crc32fast v1.3.2
   Compiling semver v1.0.20
   Compiling smallvec v1.11.2
   Compiling byteorder v1.5.0
   Compiling heck v0.4.1
   Compiling adler v1.0.2
   Compiling miniz_oxide v0.7.1
   Compiling serde_derive v1.0.193
   Compiling ring v0.17.6
   Compiling spin v0.9.8
   Compiling thiserror-core v1.0.50
   Compiling rustversion v1.0.14
   Compiling thiserror-core-impl v1.0.50
   Compiling flate2 v1.0.28
   Compiling stable_deref_trait v1.2.0
   Compiling typenum v1.17.0
   Compiling static_assertions v1.1.0
   Compiling version_check v0.9.4
   Compiling log v0.4.20
   Compiling generic-array v0.14.7
   Compiling twox-hash v1.6.3
   Compiling getrandom v0.2.11
   Compiling cpp_demangle v0.4.3
   Compiling parking_lot_core v0.9.9
   Compiling tinyvec_macros v0.1.1
   Compiling hashbrown v0.14.3
   Compiling untrusted v0.9.0
   Compiling strsim v0.10.0
   Compiling equivalent v1.0.1
   Compiling fnv v1.0.7
   Compiling ident_case v1.0.1
   Compiling unicode-width v0.1.11
   Compiling darling_core v0.14.4
   Compiling indexmap v2.1.0
   Compiling tinyvec v1.6.0
   Compiling ruzstd v0.4.0
   Compiling is-terminal v0.4.9
   Compiling pkg-config v0.3.27
   Compiling ryu v1.0.15
   Compiling utf8parse v0.2.1
   Compiling itoa v1.0.9
   Compiling radium v0.7.0
   Compiling winnow v0.5.19
   Compiling toml_datetime v0.6.5
   Compiling anstyle-parse v0.2.2
   Compiling libudev-sys v0.1.4
   Compiling darling_macro v0.14.4
   Compiling object v0.32.1
   Compiling rustc_version v0.4.0
   Compiling toml_edit v0.19.15
   Compiling unicode-normalization v0.1.22
   Compiling gimli v0.28.1
   Compiling aho-corasick v1.1.2
   Compiling backtrace v0.3.69
   Compiling memmap2 v0.5.10
   Compiling num-traits v0.2.17
   Compiling signal-hook v0.3.17
   Compiling tap v1.0.1
   Compiling colorchoice v1.0.0
   Compiling percent-encoding v2.3.1
   Compiling serde_json v1.0.108
   Compiling rustls v0.21.9
   Compiling rustc-demangle v0.1.23
   Compiling anstyle v1.0.4
   Compiling thiserror v1.0.50
   Compiling once_cell v1.18.0
   Compiling fallible-iterator v0.3.0
   Compiling regex-syntax v0.8.2
   Compiling anstyle-query v1.0.0
   Compiling unicode-bidi v0.3.13
   Compiling idna v0.5.0
   Compiling regex-automata v0.4.3
   Compiling anstream v0.6.4
   Compiling addr2line v0.21.0
   Compiling proc-macro-crate v1.3.1
   Compiling form_urlencoded v1.2.1
   Compiling wyz v0.5.1
   Compiling parking_lot v0.12.1
   Compiling heapless v0.7.16
   Compiling darling v0.14.4
   Compiling sct v0.7.1
   Compiling rustls-webpki v0.101.7
   Compiling thiserror-impl v1.0.50
   Compiling terminal_size v0.3.0
   Compiling signal-hook-registry v1.4.1
   Compiling binrw_derive v0.12.0
   Compiling bitflags v1.3.2
   Compiling portable-atomic v1.5.1
   Compiling funty v2.0.0
   Compiling option-ext v0.2.0
   Compiling lazy_static v1.4.0
   Compiling clap_lex v0.6.0
   Compiling clap_builder v4.4.9
   Compiling console v0.15.7
   Compiling dirs-sys v0.4.1
   Compiling bitvec v1.0.1
   Compiling deku_derive v0.16.0
   Compiling url v2.5.0
   Compiling regex v1.10.2
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling serde_spanned v0.6.4
   Compiling strum_macros v0.25.3
   Compiling strum_macros v0.24.3
   Compiling mio v0.8.9
   Compiling bytemuck_derive v1.5.0
   Compiling clap_derive v4.4.7
   Compiling hash32 v0.2.1
   Compiling csv-core v0.1.11
   Compiling is_ci v1.1.1
   Compiling base64 v0.21.5
   Compiling owo-colors v3.5.0
   Compiling fastrand v2.0.1
   Compiling smawk v0.3.2
   Compiling either v1.9.0
   Compiling binrw v0.12.0
   Compiling unicode-linebreak v0.1.5
   Compiling webpki-roots v0.25.3
   Compiling ureq v2.9.1
   Compiling clap v4.4.10
   Compiling textwrap v0.15.2
   Compiling toml_edit v0.21.0
   Compiling tempfile v3.8.1
   Compiling supports-color v2.1.0
   Compiling bytemuck v1.14.0
   Compiling csv v1.3.0
   Compiling strum v0.24.1
   Compiling strum v0.25.0
   Compiling signal-hook-mio v0.2.3
   Compiling digest v0.10.7
   Compiling parse_int v0.6.0
   Compiling backtrace-ext v0.2.1
   Compiling deku v0.16.0
   Compiling libudev v0.3.0
   Compiling directories v5.0.1
   Compiling nix v0.26.4
   Compiling crossterm v0.27.0
   Compiling supports-hyperlinks v2.1.0
   Compiling supports-unicode v2.0.0
   Compiling serde_plain v1.0.2
   Compiling miette-derive v5.10.0
   Compiling nix v0.27.1
   Compiling terminal_size v0.1.17
   Compiling zeroize v1.7.0
   Compiling zero v0.1.3
   Compiling termcolor v1.4.0
   Compiling shell-words v1.1.0
   Compiling array-init v2.1.0
   Compiling cpufeatures v0.2.11
   Compiling md5 v0.7.0
   Compiling humantime v2.1.0
   Compiling number_prefix v0.4.0
   Compiling indicatif v0.17.7
   Compiling miette v5.10.0
   Compiling env_logger v0.10.1
   Compiling esp-idf-part v0.4.1
   Compiling sha2 v0.10.8
   Compiling dialoguer v0.10.4
   Compiling ctrlc v3.4.1
   Compiling xmas-elf v0.9.1
   Compiling serialport v4.2.2
   Compiling comfy-table v7.1.0
   Compiling update-informer v1.1.0
   Compiling crossterm v0.25.0
   Compiling toml v0.8.8
   Compiling clap_complete v4.4.4
   Compiling hex v0.4.3
   Compiling slip-codec v0.3.4
   Compiling espflash v2.1.0
    Finished release [optimized] target(s) in 6m 47s
  Installing /home/tomoyan/.cargo/bin/espflash
   Installed package `espflash v2.1.0` (executable `espflash`)

動作確認🤔

$ espflash -V

espflash 2.1.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

EPS32-WROOM-32

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 11月 30 12:16 usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 -> ../../ttyUSB0

/dev/serial/by-path:
合計 0
lrwxrwxrwx 1 root root 13 11月 30 12:16 pci-0000:00:14.0-usb-0:1:1.0-port0 -> ../../ttyUSB0

公式: espflash/espflash/README.md at main · esp-rs/espflash · GitHub 翻訳
シリアルコンソールに接続する前に、ポートの権限を設定

/dev/ttyUSB0dialout グループで読み書きできる🤔

$ ls -l /dev/ttyUSB0

crw-rw---- 1 root dialout 188, 0 11月 30 12:16 /dev/ttyUSB0

現在のユーザー $USERdialout グループに所属させる🤔

$ 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)

公式: Running the Code - Understanding esp-template - The Rust on ESP Book 翻訳
上記までの手順でフラッシュへ書き込む準備ができているので、cargo run コマンドでビルドからフラッシュ書き込みができる😉

$ cargo run

    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `espflash flash --monitor target/xtensa-esp32-none-elf/debug/haruo-nostd-esp32`
[2023-12-01T02:08:51Z INFO ] Serial port: '/dev/ttyUSB0'
[2023-12-01T02:08:51Z INFO ] Connecting...
[2023-12-01T02:08:52Z INFO ] Unable to connect, retrying with extra delay...
[2023-12-01T02:08:53Z INFO ] Using flash stub
Chip type:         esp32 (revision v1.0)
Crystal frequency: 40MHz
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:    181,472/4,128,768 bytes, 4.40%
[00:00:01] [========================================]      17/17      0x1000                                  [00:00:00] [========================================]       1/1       0x8000                                  [00:00:06] [========================================]      70/70      0x10000                                 [2023-12-01T02:09:02Z 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
0x3fff0030 - _stack_region_top
    at ??:??
load:0x40078000,len:15576
0x40078000 - ets_delay_us
    at ??:??
load:0x40080400,len:4
0x40080400 - _init_end
    at ??:??
ho 8 tail 4 room 4
load:0x40080404,len:3876
0x40080404 - _init_end
    at ??:??
entry 0x4008064c
0x4008064c - esp_hal_common::interrupt::xtensa::vectored::handle_interrupts
    at /home/tomoyan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-hal-common-0.13.1/src/interrupt/xtensa.rs:389
I (30) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (30) 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=06664h ( 26212) map
I (115) esp_image: segment 1: paddr=0001668c vaddr=3ffb0000 size=00004h (     4) load
I (115) esp_image: segment 2: paddr=00016698 vaddr=40080000 size=01988h (  6536) load
I (125) esp_image: segment 3: paddr=00018028 vaddr=00000000 size=07ff0h ( 32752) 
I (143) esp_image: segment 4: paddr=00020020 vaddr=400d0020 size=1c498h (115864) map
I (185) boot: Loaded app from partition at offset 0x10000
I (186) boot: Disabling RNG early entropy source...
Haruo world!
Loop...
Loop...
Loop...
Loop...
Loop...
Loop...
Loop...
Loop...
Loop...
Loop...

  • rust/rust_on_esp_install.1714951760.txt.gz
  • 最終更新: 2024/05/06 08:29
  • by ともやん