跳过正文

esp-rs 常见问题

·673 字
Rust Esp32 Rust Esp32
rust-esp32 - 这篇文章属于一个选集。
§ 8: 本文
  1. 在 esp-idf-template 生成的模板项目中执行 cargo build 报错:
  2. https://github.com/esp-rs/esp-idf-template/issues/165
  Using managed esp-idf repository: RemoteSdk { repo_url: None, git_ref: Tag("v5.1.2") }
  Using esp-idf v5.1.2 at '/Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/esp-idf/v5.1.2'
  ERROR: /Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/espidf.constraints.v5.1.txt doesn't exist. Perhaps you've forgotten to run the install scripts. Please check the installation guide for more information.
  CMake Error at /Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/esp-idf/v5.1.2/tools/cmake/build.cmake:363 (message):
    Some Python dependencies must be installed.  Check above message for
    details.
  Call Stack (most recent call first):
    /Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/esp-idf/v5.1.2/tools/cmake/build.cmake:498 (__build_check_python)
    /Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/esp-idf/v5.1.2/tools/cmake/project.cmake:547 (idf_build_process)
    CMakeLists.txt:28 (project)


  thread 'main' panicked at /Users/zhangjun/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

解决办法:

cargo clean && rm -rf .embuild && cargo build
  1. 报错: Missing dependencies for SOCKS support.
  来自 https://github.com/ThrowTheSwitch/Unity
   * branch            7d2bf62b7e6afaf38153041a9d53c21aeeca9a25 -> FETCH_HEAD
  ERROR: Could not install packages due to an OSError: Missing dependencies for SOCKS support.

  WARNING: There was an error checking the latest version of pip.
  Error: Command '['/Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/python_env/idf5.1_py3.12_env/bin/python3', '-m', 'pip', 'install', '--upgrade', 'pip']' returned non-zero exit status 1.
  Traceback (most recent call last):
    File "/Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/esp-idf/v5.1.2/tools/idf_tools.py", line 2687, in <module>
      main(sys.argv[1:])
    File "/Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/esp-idf/v5.1.2/tools/idf_tools.py", line 2679, in main
      action_func(args)
    File "/Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/esp-idf/v5.1.2/tools/idf_tools.py", line 2098, in action_install_python_env
      subprocess.check_call([sys.executable, '-m', 'venv',
    File "/Users/zhangjun/.pyenv/versions/3.12.1/lib/python3.12/subprocess.py", line 413, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/Users/zhangjun/.pyenv/versions/3.12.1/bin/python3', '-m', 'venv', '--clear', '--upgrade-deps', '/Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/python_env/idf5.1_py3.12_env']' returned non-zero exit status 1.
  Error: Could not install esp-idf

  Caused by:
      command 'env -u IDF_PYTHON_ENV_PATH -u MSYSTEM IDF_TOOLS_PATH="/Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif" "python3" "/Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/esp-idf/v5.1.2/tools/idf_tools.py" "--idf-path" "/Users/zhangjun/codes/esp32/esp-demo/.embuild/espressif/esp-idf/v5.1.2" "--non-interactive" "install-python-env"' exited with non-zero status code 1
zj@a:~/codes/esp32/esp-demo$

解决办法: 不使用 socks5 代理, 而是使用 https/http 代理:

# 将下列内容添加到 ~/esp/export.sh 和 ~/esp/export-esp.sh 中
export all_proxy="http://192.168.3.2:1080" ALL_PROXY="http://192.168.3.2:1080"

# 在 ~/.bashrc 中添加如下内容, 用于手动切换:
alias enable_http_proxy='export all_proxy="http://192.168.3.2:1080" ALL_PROXY="http://192.168.3.2:1080"'
alias enable_socks_proxy='export all_proxy="socks5h://192.168.3.2:1080" ALL_PROXY="socks5h://192.168.3.2:1080"'
alias disable_proxy='unset all_proxy ALL_PROXY'
  1. rust-analyzer 报错,不能正常解析和补全。

解决办法:

zj@a:~/codes/esp32/esp-demo2/myesp$ cd

zj@a:~$ rustup component add rust-analyzer
info: downloading component 'rust-analyzer'
info: installing component 'rust-analyzer'

zj@a:~$ ls -l ~/.rustup/toolchains/
esp/                         nightly-x86_64-apple-darwin/

zj@a:~$ ls -l ~/.rustup/toolchains/nightly-x86_64-apple-darwin/bin/
total 95M
-rwxr-xr-x 1 zhangjun  29M  2  8 14:48 cargo*
-rwxr-xr-x 1 zhangjun 1.1M  2  8 14:48 cargo-clippy*
-rwxr-xr-x 1 zhangjun 1.5M  2  8 14:49 cargo-fmt*
-rwxr-xr-x 1 zhangjun  11M  2  8 14:48 clippy-driver*
-rwxr-xr-x 1 zhangjun  36M  2  8 16:57 rust-analyzer*
-rwxr-xr-x 1 zhangjun  980  2  8 14:48 rust-gdb*
-rwxr-xr-x 1 zhangjun 2.2K  2  8 14:49 rust-gdbgui*
-rwxr-xr-x 1 zhangjun 1.1K  2  8 14:48 rust-lldb*
-rwxr-xr-x 1 zhangjun 598K  2  8 14:49 rustc*
-rwxr-xr-x 1 zhangjun  11M  2  8 14:49 rustdoc*
-rwxr-xr-x 1 zhangjun 6.6M  2  8 14:49 rustfmt*

zj@a:~$ ln -sf ~/.rustup/toolchains/nightly-x86_64-apple-darwin/bin/rust-analyzer ~/.rustup/toolchains/esp/bin/rust-analyzer
z
  1. 报错:warning: [email protected]: could not identify the root crate and `ESP_IDF_SYS_ROOT_CRATE` not specified。

    这是因为同时 source 了 export.sh 和 export-esp.sh,当构建纯 Rust std/non_std 应用时,只需要 source export-esp.sh 即可。

       zj@a:~/code/esp32/std$ source ~/esp/esp-idf/v5.2.1/export.sh
       zj@a:~/code/esp32/std$ source ~/esp/export-esp.sh
    
       zj@a:~/code/esp32/std$ cargo build
       warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
       package:   /Users/alizj/code/esp32/std/myesp/Cargo.toml
       workspace: /Users/alizj/code/esp32/std/Cargo.toml
       warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
       package:   /Users/alizj/code/esp32/std/myespv2/Cargo.toml
       workspace: /Users/alizj/code/esp32/std/Cargo.toml
       warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
       package:   /Users/alizj/code/esp32/std/myespv3/Cargo.toml
       workspace: /Users/alizj/code/esp32/std/Cargo.toml
       warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
       package:   /Users/alizj/code/esp32/std/myespv4/Cargo.toml
       workspace: /Users/alizj/code/esp32/std/Cargo.toml
       Compiling esp-idf-sys v0.34.1
       The following warnings were emitted during compilation:
    
       warning: [email protected]: could not identify the root crate and `ESP_IDF_SYS_ROOT_CRATE` not specified
    
       error: failed to run custom build command for `esp-idf-sys v0.34.1`
    
       Caused by:
       process didn't exit successfully: `/Users/alizj/code/esp32/std/target/debug/build/esp-idf-sys-eac13132720836e4/build-script-build` (exit status: 101)
         --- stdout
         cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
         cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
         cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
         cargo:rerun-if-env-changed=MCU
    
rust-esp32 - 这篇文章属于一个选集。
§ 8: 本文

相关文章

Rust 驱动 Audio - 播放和录音
·6323 字
Rust Esp32 Rust Esp32
Rust 驱动 Camera - 采集和播放
·7304 字
Rust Esp32 Rust Esp32
Rust 驱动 LCD - 显示中英文
·818 字
Rust Esp32 Rust Esp32
Rust 驱动 LCD - 显示图片
·4232 字
Rust Esp32 Rust Esp32