esp-rs / esp-idf-template

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

use of undeclared crate or module `esp_idf_svc` #148

Closed javoerro closed 8 months ago

javoerro commented 11 months ago

Compile fails with the error: use of undeclared crate or module esp_idf_svc

Steps to reproduce the behavior:

  1. followed prerequisites of https://github.com/esp-rs/esp-idf-template
  2. generated project with "cargo generate --vcs none --git https://github.com/esp-rs/esp-idf-template cmake"
  3. open created folder with vscode
  4. use esp-idf vscode extension to change target to esp32s3
  5. use esp-idf vscode extension to build (hit the build button) or idf.py build (failed in both cases)

-Windows 10, vscode, espup 0.4.1 -Excerpt from the build log:

[557/891] Performing build step for 'project_rust_sayhello'
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling compiler_builtins v0.1.92
   Compiling memchr v2.5.0
   Compiling winapi v0.3.9
   Compiling core v0.0.0 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\core)
   Compiling quote v1.0.32
   Compiling windows_x86_64_msvc v0.48.0
   Compiling syn v2.0.28
   Compiling serde v1.0.183
   Compiling cfg-if v1.0.0
   Compiling windows-targets v0.48.1
   Compiling libc v0.2.147
   Compiling windows-sys v0.48.0
   Compiling serde_derive v1.0.183
   Compiling aho-corasick v1.0.2
   Compiling rustc-std-workspace-core v1.99.0 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\rustc-std-workspace-core)
   Compiling once_cell v1.18.0
   Compiling regex-syntax v0.7.4
   Compiling alloc v0.0.0 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\alloc)
   Compiling regex-automata v0.3.6
   Compiling libc v0.2.143
   Compiling windows_x86_64_msvc v0.42.2
   Compiling syn v1.0.109
   Compiling glob v0.3.1
   Compiling clang-sys v1.6.1
   Compiling regex v1.9.3
   Compiling winapi-util v0.1.5
   Compiling lazy_static v1.4.0
   Compiling rustversion v1.0.14
   Compiling cc v1.0.77
   Compiling log v0.4.19
   Compiling stable_deref_trait v1.2.0
   Compiling as-slice v0.2.1
   Compiling same-file v1.0.6
   Compiling bstr v1.6.0
   Compiling unwind v0.0.0 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\unwind)
   Compiling serde_json v1.0.104
   Compiling fnv v1.0.7
   Compiling thiserror v1.0.44
   Compiling minimal-lexical v0.2.1
   Compiling globset v0.4.13
   Compiling nom v7.1.3
   Compiling windows-targets v0.42.2
   Compiling walkdir v2.3.3
   Compiling aligned v0.4.1
   Compiling rustc-std-workspace-alloc v1.99.0 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\rustc-std-workspace-alloc)
   Compiling thread_local v1.1.7
   Compiling thiserror-impl v1.0.44
   Compiling cvt v0.1.2
   Compiling libloading v0.7.4
   Compiling itoa v1.0.9
   Compiling heck v0.4.1
   Compiling ryu v1.0.15
   Compiling either v1.9.0
   Compiling bindgen v0.63.0
   Compiling anyhow v1.0.72
   Compiling bitflags v1.3.2
   Compiling which v4.4.0
   Compiling strum_macros v0.24.3
   Compiling fs_at v0.1.8
   Compiling ignore v0.4.20
   Compiling cexpr v0.6.0
   Compiling windows-sys v0.45.0
   Compiling normpath v1.1.1
   Compiling fastrand v2.0.0
   Compiling cc v1.0.82
   Compiling shlex v1.1.0
   Compiling rustc-hash v1.1.0
   Compiling semver v1.0.18
   Compiling std v0.0.0 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\std)
   Compiling lazycell v1.3.0
   Compiling camino v1.1.6
   Compiling peeking_take_while v0.1.2
   Compiling remove_dir_all v0.8.2
   Compiling cmake v0.1.50
   Compiling tempfile v3.7.1
   Compiling strum v0.24.1
   Compiling globwalk v0.8.1
   Compiling std_detect v0.1.5 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\stdarch\crates\std_detect)
   Compiling hashbrown v0.13.1
   Compiling panic_abort v0.0.0 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\panic_abort)
   Compiling rustc-demangle v0.1.21
   Compiling home v0.5.5
   Compiling filetime v0.2.22
   Compiling autocfg v1.1.0
   Compiling num-traits v0.2.16
   Compiling embuild v0.31.2
   Compiling cargo-platform v0.1.3
   Compiling cargo_metadata v0.15.4
   Compiling proc_macro v0.0.0 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\proc_macro)
   Compiling panic_unwind v0.0.0 (C:\Users\jerrobidart\.rustup\toolchains\esp\lib\rustlib\src\rust\library\panic_unwind)
   Compiling envy v0.4.2
   Compiling esp-idf-sys v0.33.1
   Compiling unicode-xid v0.2.4
   Compiling const_format_proc_macros v0.2.31
   Compiling chrono v0.4.26
   Compiling const_format v0.2.31
   Compiling rust-sayhello v0.1.0 (C:\Users\jerrobidart\Escritorio\sayhello\components\rust-sayhello)
   Compiling build-time v0.1.3
error[E0433]: failed to resolve: use of undeclared crate or module `esp_idf_svc`
  --> src\lib.rs:11:5
   |
11 |     esp_idf_svc::log::EspLogger::initialize_default();
   |     ^^^^^^^^^^^ use of undeclared crate or module `esp_idf_svc`
   |
help: there is a crate or module with a similar name
   |
11 |     esp_idf_sys::log::EspLogger::initialize_default();
   |     ~~~~~~~~~~~

For more information about this error, try `rustc --explain E0433`.
error: could not compile `rust-sayhello` (lib) due to previous error
[618/891] Performing build step for 'project_rust_sayhello'Batch file failed at line 3 with errorcode 101
[686/891] Performing configure step for 'bootloader'-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.33.0.windows.2")
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/VSCode/espressif/tools/xtensa-esp32s3-elf/esp-2022r1-11.2.0/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/VSCode/espressif/tools/xtensa-esp32s3-elf/esp-2022r1-11.2.0/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/VSCode/espressif/tools/xtensa-esp32s3-elf/esp-2022r1-11.2.0/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32s3
-- Project sdkconfig file C:/Users/jerrobidart/Escritorio/sayhello/sdkconfig
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Adding linker script C:/espressif/esp-idf-v5.0/esp-idf/components/soc/esp32s3/ld/esp32s3.peripherals.ld
-- App "bootloader" version: v5.0-494-g490216a2ac-dirty
-- Adding linker script C:/espressif/esp-idf-v5.0/esp-idf/components/esp_rom/esp32s3/ld/esp32s3.rom.ld
-- Adding linker script C:/espressif/esp-idf-v5.0/esp-idf/components/esp_rom/esp32s3/ld/esp32s3.rom.api.ld
-- Adding linker script C:/espressif/esp-idf-v5.0/esp-idf/components/esp_rom/esp32s3/ld/esp32s3.rom.libgcc.ld
-- Adding linker script C:/espressif/esp-idf-v5.0/esp-idf/components/esp_rom/esp32s3/ld/esp32s3.rom.newlib.ld
-- Adding linker script C:/espressif/esp-idf-v5.0/esp-idf/components/bootloader/subproject/main/ld/esp32s3/bootloader.ld-- Adding linker script C:/espressif/esp-idf-v5.0/esp-idf/components/bootloader/subproject/main/ld/esp32s3/bootloader.rom.ld
-- Components: bootloader bootloader_support efuse esp_app_format esp_common esp_hw_support esp_rom esp_system esptool_py freertos hal log main micro-ecc newlib partition_table soc spi_flash xtensa
-- Component paths: C:/espressif/esp-idf-v5.0/esp-idf/components/bootloader C:/espressif/esp-idf-v5.0/esp-idf/components/bootloader_support C:/espressif/esp-idf-v5.0/esp-idf/components/efuse C:/espressif/esp-idf-v5.0/esp-idf/components/esp_app_format C:/espressif/esp-idf-v5.0/esp-idf/components/esp_common C:/espressif/esp-idf-v5.0/esp-idf/components/esp_hw_support C:/espressif/esp-idf-v5.0/esp-idf/components/esp_rom C:/espressif/esp-idf-v5.0/esp-idf/components/esp_system C:/espressif/esp-idf-v5.0/esp-idf/components/esptool_py C:/espressif/esp-idf-v5.0/esp-idf/components/freertos C:/espressif/esp-idf-v5.0/esp-idf/components/hal C:/espressif/esp-idf-v5.0/esp-idf/components/log C:/espressif/esp-idf-v5.0/esp-idf/components/bootloader/subproject/main C:/espressif/esp-idf-v5.0/esp-idf/components/bootloader/subproject/components/micro-ecc C:/espressif/esp-idf-v5.0/esp-idf/components/newlib C:/espressif/esp-idf-v5.0/esp-idf/components/partition_table C:/espressif/esp-idf-v5.0/esp-idf/components/soc C:/espressif/esp-idf-v5.0/esp-idf/components/spi_flash C:/espressif/esp-idf-v5.0/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/jerrobidart/Escritorio/sayhello/build/bootloader
[105/106] Generating binary image from built executableesptool.py v4.5.1
Creating esp32s3 image...
Merged 1 ELF section
Successfully created esp32s3 image.
Generated C:/Users/jerrobidart/Escritorio/sayhello/build/bootloader/bootloader.bin
[106/106] cmd.exe /C "cd /D C:\Users\jerrobidart\Escritori...idart/Escritorio/sayhello/build/bootloader/bootloader.bin"Bootloader binary size 0x5160 bytes. 0x2ea0 bytes (36%) free.
[879/891] Linking C static library esp-idf\wifi_provisioning\libwifi_provisioning.aFAILED: esp-idf/rust-sayhello/stamp/project_rust_sayhello-build esp-idf/rust-sayhello/target/xtensa-esp32s3-espidf/release/librust_sayhello.a C:/Users/jerrobidart/Escritorio/sayhello/build/esp-idf/rust-sayhello/stamp/project_rust_sayhello-build C:/Users/jerrobidart/Escritorio/sayhello/build/esp-idf/rust-sayhello/target/xtensa-esp32s3-espidf/release/librust_sayhello.a
esp-idf\rust-sayhello\CMakeFiles\project_rust_sayhello-build-b72e389.bat 5826fd4fc8631ec4
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the c:\users\jerrobidart\escritorio\sayhello\build\log\idf_py_stderr_output_15484 and c:\users\jerrobidart\escritorio\sayhello\build\log\idf_py_stdout_output_15484

-Template parameters

cargo generate --vcs none --git https://github.com/esp-rs/esp-idf-template cmake
project-name: sayhello
Rust toolchain: esp
STD support : true
ivmarkov commented 11 months ago

Can you provide some extra details:

javoerro commented 11 months ago

@ivmarkov your request was added in first post, thank you!

ivmarkov commented 10 months ago

Sorry for the late reply. I'll try to get to it in the next days.weeks. Seems to be a bug in the generated project in that the esp-idf-svc dependency is not explicitly listed in Cargo.toml in some cases.

In the meantime, you can add it manually.

I'm not in a rush to fix it, as anyway in the upcoming versions of esp-idf-svc / esp-idf-hal / esp-idf-sys there is a change that would allow users to only depend on esp-idf-svc as it will re-export the other crates. The templates recently grew way too complex, and are now difficult to maintain - I would like to simplify the options the user can choose from. For one "all HAL", "no HAL" etc. need to go. They only serve very niche use cases, and the purpose of these templates is to bootstrap the user during her initial trials with Rust on ESP IDF. She can always adjust the Cargo.tomlmanually after that.

Maldus512 commented 8 months ago

I'm encountering the same issue on Void Linux with the latest master; the only difference is espup version 0.7.0. Cargo.toml contains esp-idf-svc as an optional dependency.

ivmarkov commented 8 months ago

Should no longer happen with the PR which just got merged. Please reopen if you are still experiencing the issue.