esp-rs / esp-idf-template

A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework.
414 stars 50 forks source link

Can not build the init project #189

Closed freew01f closed 7 months ago

freew01f commented 7 months ago

I am new in this field I installed the env for rust and generate a init project when i build it I got those err

rustup show
Default host: aarch64-apple-darwin
rustup home:  /Users/freewolf/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin
nightly-aarch64-apple-darwin
esp (default)

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
riscv32imac-unknown-none-elf
riscv32imafc-unknown-none-elf
riscv32imc-unknown-none-elf

active toolchain
----------------

nightly-aarch64-apple-darwin (overridden by '/Users/freewolf/Documents/Study/esp32/test/rust-toolchain.toml')
rustc 1.78.0-nightly (397937d81 2024-02-22)

espup --version
espup 0.11.0

idf.py --version
ESP-IDF v5.2-37-g93ea06fe3e-dirty

cargo generate esp-rs/esp-idf-template cargo

⚠️   Favorite `esp-rs/esp-idf-template` not found in config, using it as a git repository: https://github.com/esp-rs/esp-idf-template.git
🤷   Project Name: test
🔧   Destination: /Users/freewolf/Documents/Study/esp32/test ...
🔧   project-name: test ...
🔧   Generating template ...
✔ 🤷   Which MCU to target? · esp32c3
✔ 🤷   Configure advanced template options? · true
✔ 🤷   Enable STD support? · true
✔ 🤷   Configure project to use Dev Containers (VS Code and GitHub Codespaces)? · false
✔ 🤷   Configure project to support Wokwi simulation with Wokwi VS Code extension? · false
✔ 🤷   Add CI files for GitHub Action? · false
✔ 🤷   ESP-IDF version (master = UNSTABLE) · master
🔧   Moving generated files into: `/Users/freewolf/Documents/Study/esp32/test`...
🔧   Initializing a fresh Git repository
✨   Done! New project created /Users/freewolf/Documents/Study/esp32/test
freewolf@bogon esp32 % cd test                                     
freewolf@bogon test % ls
Cargo.toml      build.rs        rust-toolchain.toml sdkconfig.defaults  src
freewolf@bogon test % cargo build
    Updating crates.io index
  Downloaded darling_core v0.20.7
  Downloaded darling_macro v0.20.7
  Downloaded darling v0.20.7
  Downloaded esp-idf-svc v0.48.1
  Downloaded esp-idf-sys v0.34.1
  Downloaded esp-idf-hal v0.43.1
  Downloaded embedded-svc v0.27.1
  Downloaded 7 crates (552.5 KB) in 1.51s
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.153
   Compiling memchr v2.7.1
   Compiling cfg-if v1.0.0
   Compiling serde v1.0.197
   Compiling crossbeam-utils v0.8.19
   Compiling regex-syntax v0.8.2
   Compiling rustix v0.38.31
   Compiling glob v0.3.1
   Compiling aho-corasick v1.1.2
   Compiling bitflags v1.3.2
   Compiling syn v1.0.109
   Compiling clang-sys v1.7.0
   Compiling quote v1.0.35
   Compiling regex-automata v0.4.5
   Compiling syn v2.0.50
   Compiling rustversion v1.0.14
   Compiling bitflags v2.4.2
   Compiling log v0.4.20
   Compiling crossbeam-epoch v0.9.18
   Compiling errno v0.3.8
   Compiling bstr v1.9.0
   Compiling same-file v1.0.6
   Compiling thiserror v1.0.57
   Compiling minimal-lexical v0.2.1
   Compiling serde_json v1.0.114
   Compiling globset v0.4.14
   Compiling nom v7.1.3
   Compiling walkdir v2.4.0
   Compiling crossbeam-deque v0.8.5
   Compiling nix v0.26.4
   Compiling libloading v0.8.1
   Compiling cvt v0.1.2
   Compiling heck v0.4.1
   Compiling bindgen v0.63.0
   Compiling anyhow v1.0.80
   Compiling either v1.10.0
   Compiling itoa v1.0.10
   Compiling home v0.5.9
   Compiling lazy_static v1.4.0
   Compiling ryu v1.0.17
   Compiling which v4.4.2
   Compiling cexpr v0.6.0
   Compiling fs_at v0.1.10
   Compiling ignore v0.4.22
   Compiling regex v1.10.3
   Compiling cc v1.0.86
   Compiling normpath v1.2.0
   Compiling rustc-hash v1.1.0
   Compiling lazycell v1.3.0
   Compiling shlex v1.3.0
   Compiling peeking_take_while v0.1.2
   Compiling fastrand v2.0.1
   Compiling cmake v0.1.50
   Compiling remove_dir_all v0.8.2
   Compiling tempfile v3.10.0
   Compiling globwalk v0.8.1
   Compiling filetime v0.2.23
   Compiling semver v1.0.22
   Compiling camino v1.1.6
   Compiling ident_case v1.0.1
   Compiling fnv v1.0.7
   Compiling autocfg v1.1.0
   Compiling darling_core v0.20.7
   Compiling nb v1.1.0
error[E0463]: can't find crate for `core`
  |
  = note: the `riscv32imc-esp-espidf` target may not be installed
  = help: consider downloading the target with `rustup target add riscv32imc-esp-espidf`

error[E0463]: can't find crate for `compiler_builtins`

libunwind: malformed __unwind_info at 0x188E83CA8 bad second level page
error[E0463]: can't find crate for `core`
   --> /Users/freewolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nb-1.1.0/src/lib.rs:192:5
    |
192 | use core::fmt;
    |     ^^^^ can't find crate
    |
    = note: the `riscv32imc-esp-espidf` target may not be installed
    = help: consider downloading the target with `rustup target add riscv32imc-esp-espidf`

error: cannot find attribute `derive` in this scope
   --> /Users/freewolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nb-1.1.0/src/lib.rs:201:3
    |
201 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
    |   ^^^^^^

error[E0463]: can't find crate for `core`
   --> /Users/freewolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nb-1.1.0/src/lib.rs:195:27
    |
195 | pub type Result<T, E> = ::core::result::Result<T, Error<E>>;
    |                           ^^^^ can't find crate
    |
    = note: the `riscv32imc-esp-espidf` target may not be installed
    = help: consider downloading the target with `rustup target add riscv32imc-esp-espidf`

error[E0405]: cannot find trait `FnOnce` in this scope
   --> /Users/freewolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nb-1.1.0/src/lib.rs:239:12
    |
239 |         F: FnOnce(E) -> T,
    |            ^^^^^^ not found in this scope

error[E0405]: cannot find trait `From` in this scope
   --> /Users/freewolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nb-1.1.0/src/lib.rs:248:9
    |
248 | impl<E> From<E> for Error<E> {
    |         ^^^^ not found in this scope

libunwind: malformed __unwind_info at 0x188E83CA8 bad second level page
Some errors have detailed explanations: E0405, E0463.
For more information about an error, try `rustc --explain E0405`.
error: could not compile `nb` (lib) due to 7 previous errors
warning: build failed, waiting for other jobs to finish...

rustup target add riscv32imc-esp-espidf
error: toolchain 'nightly-aarch64-apple-darwin' does not contain component 'rust-std' for target 'riscv32imc-esp-espidf'
note: not all platforms have the standard library pre-compiled: https://doc.rust-lang.org/nightly/rustc/platform-support.html
help: consider using `cargo build -Z build-std` instead

cargo build -Z build-std
error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.

how to build it

SergioGasquez commented 7 months ago

Hi, did you manually install esp-idf? Looking at your idf.py --version, looks like you have an activated esp-idf environment. You don't need that, and you also don't need espup installation if you ONLY want to work with RISC-V targets (esp32c3 is RISC-V). I would recommend reading https://esp-rs.github.io/book/installation/index.html. Also, make sure you don't have a v5.2.x environment activated when building the esp-idf-template.