esp-rs / rust-build

Installation tools and workflows for deploying/building Rust fork esp-rs/rust with Xtensa and RISC-V support
MIT License
248 stars 35 forks source link

Unable to build `rust-esp32-std-demo` using Docker and cargo #30

Closed akselbor closed 2 years ago

akselbor commented 2 years ago

Hello!

I seem unable to build rust-esp32-std-demo using the Docker image espressif/idf-rust-examples:latest (image ID 562dd6cc6e54) using cargo. The issue seems to be related to PlatformIO. Builds using idf.py build work fine.

The host machine is an Intel-Mac running macOS Big Sur v11.2.3.

Suggestions?

Relevant logs:

docker run -it espressif/idf-rust-examples
Detecting the Python interpreter
Checking "python" ...
Python 3.8.10
"python" has been detected
Adding ESP-IDF tools to PATH...
Not using an unsupported version of tool xtensa-esp32-elf found in PATH: esp-2021r1-8.4.0.
Using Python interpreter in /opt/esp/python_env/idf5.0_py3.8_env/bin/python
Checking if Python packages are up to date...
Python requirements from /opt/esp/idf/requirements.txt are satisfied.
Added the following directories to PATH:
  /opt/esp/idf/components/esptool_py/esptool
  /opt/esp/idf/components/espcoredump
  /opt/esp/idf/components/partition_table
  /opt/esp/idf/components/app_update
  /opt/esp/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin
  /opt/esp/tools/xtensa-esp32s2-elf/esp-2021r2-8.4.0/xtensa-esp32s2-elf/bin
  /opt/esp/tools/xtensa-esp32s3-elf/esp-2021r2-8.4.0/xtensa-esp32s3-elf/bin
  /opt/esp/tools/riscv32-esp-elf/esp-2021r2-8.4.0/riscv32-esp-elf/bin
  /opt/esp/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin
  /opt/esp/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin
  /opt/esp/tools/cmake/3.20.3/bin
  /opt/esp/tools/openocd-esp32/v0.10.0-esp32-20211111/openocd-esp32/bin
  /opt/esp/python_env/idf5.0_py3.8_env/bin
  /opt/esp/idf/tools
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

  idf.py build

==============================================================================
=           Docker image with ESP-IDF, Rust compiler and examples            =
=              https://github.com/espressif/rust-esp32-example               =
==============================================================================

Available examples:

* "cargo-first" approach
  `` ``` ``sh
    cd /opt/rust-esp32-std-demo
    cargo +esp build --release
    espflash /dev/ttyUSB0 target/xtensa-esp32-espidf/release/rust-esp32-std-demo
    cargo pio espidf monitor -e release /dev/ttyUSB0
  `` ``` ``

* "idf.py-first" approach - integration via CMake files
  `` ``` ``sh
    cd /opt/rust-esp32-example
    idf.py build
  `` ``` ``
root@918e12cae58c:/opt# cd rust-esp32-std-demo
root@918e12cae58c:/opt/rust-esp32-std-demo# export set RUST_BACKTRACE=1 && cargo +esp build --release
warning: unused config key `unstable.configurable-env` in `/opt/rust-esp32-std-demo/.cargo/config.toml`
warning: unused config key `unstable.extra-link-arg` in `/opt/rust-esp32-std-demo/.cargo/config.toml`
   Compiling compiler_builtins v0.1.49
   Compiling core v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/core)
   Compiling libc v0.2.103
   Compiling cc v1.0.69
   Compiling std v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/std)
   Compiling libc v0.2.109
   Compiling memchr v2.4.1
   Compiling proc-macro2 v1.0.33
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.82
   Compiling cfg-if v1.0.0
   Compiling cc v1.0.72
   Compiling log v0.4.14
   Compiling autocfg v1.0.1
   Compiling serde_derive v1.0.130
   Compiling serde v1.0.130
   Compiling fnv v1.0.7
   Compiling once_cell v1.8.0
   Compiling ryu v1.0.6
   Compiling spin v0.5.2
   Compiling untrusted v0.7.1
   Compiling regex-syntax v0.6.25
   Compiling serde_json v1.0.72
   Compiling version_check v0.9.3
   Compiling anyhow v1.0.51
   Compiling tinyvec_macros v0.1.0
   Compiling glob v0.3.0
   Compiling crossbeam-utils v0.8.5
   Compiling matches v0.1.9
   Compiling lazy_static v1.4.0
   Compiling adler v1.0.2
   Compiling ppv-lite86 v0.2.15
   Compiling gimli v0.26.1
   Compiling unicode-width v0.1.9
   Compiling bitflags v1.3.2
   Compiling percent-encoding v2.1.0
   Compiling same-file v1.0.6
   Compiling unicode-bidi v0.3.7
   Compiling ansi_term v0.12.1
   Compiling vec_map v0.8.2
   Compiling termcolor v1.1.2
   Compiling rustc-demangle v0.1.21
   Compiling bindgen v0.57.0
   Compiling humantime v2.1.0
   Compiling strsim v0.8.0
   Compiling shlex v0.1.1
   Compiling itoa v0.4.8
   Compiling peeking_take_while v0.1.2
   Compiling lazycell v1.3.0
   Compiling zero v0.1.2
   Compiling either v1.6.1
   Compiling chunked_transfer v1.4.0
   Compiling base64 v0.13.0
   Compiling rustc-hash v1.1.0
   Compiling remove_dir_all v0.5.3
   Compiling unicode-segmentation v1.8.0
   Compiling shlex v1.1.0
   Compiling futures-core v0.3.18
   Compiling strsim v0.10.0
   Compiling ident_case v1.0.1
   Compiling az v1.2.0
   Compiling async-trait v0.1.51
   Compiling paste v1.0.6
   Compiling heapless v0.7.8
   Compiling unwind v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/unwind)
   Compiling libloading v0.7.2
   Compiling cmake v0.1.46
   Compiling backtrace v0.3.63
   Compiling ring v0.16.20
   Compiling miniz_oxide v0.4.4
   Compiling num-traits v0.2.14
   Compiling thread_local v1.1.3
   Compiling rustc-std-workspace-core v1.99.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling nom v5.1.2
   Compiling tinyvec v1.5.1
   Compiling clang-sys v1.3.0
   Compiling textwrap v0.11.0
   Compiling form_urlencoded v1.0.1
   Compiling walkdir v2.3.2
   Compiling addr2line v0.17.0
   Compiling xmas-elf v0.8.0
   Compiling heck v0.3.3
   Compiling unicode-normalization v0.1.19
   Compiling getrandom v0.2.3 (https://github.com/esp-rs-compat/getrandom.git#b8cb133e)
   Compiling atty v0.2.14
   Compiling dirs-sys v0.3.6
   Compiling which v3.1.1
   Compiling which v4.2.2
   Compiling remove_dir_all v0.7.0
   Compiling aho-corasick v0.7.18
   Compiling bstr v0.2.17
   Compiling object v0.27.1
   Compiling quote v1.0.10
   Compiling alloc v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/alloc)
   Compiling cfg-if v0.1.10
   Compiling rand_core v0.6.3
   Compiling clap v2.34.0
   Compiling dirs v4.0.0
   Compiling idna v0.2.3
   Compiling regex v1.5.4
   Compiling rustc-std-workspace-alloc v1.99.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
   Compiling panic_abort v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_abort)
   Compiling webpki v0.22.0
   Compiling sct v0.7.0
   Compiling cexpr v0.4.0
   Compiling rand_chacha v0.3.1
   Compiling url v2.2.2
   Compiling globset v0.4.8
   Compiling env_logger v0.8.4
   Compiling darling_core v0.13.0
   Compiling panic_unwind v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_unwind)
   Compiling std_detect v0.1.5 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
   Compiling hashbrown v0.11.0
   Compiling webpki-roots v0.22.1
   Compiling rustls v0.20.2
   Compiling rand v0.8.4
   Compiling ignore v0.4.18
   Compiling strum_macros v0.21.1
   Compiling thiserror-impl v1.0.30
   Compiling derivative v2.2.0
   Compiling ureq v2.3.1
   Compiling darling_macro v0.13.0
   Compiling tempfile v3.2.0
   Compiling globwalk v0.8.1
   Compiling strum v0.21.0
   Compiling thiserror v1.0.30
   Compiling proc_macro v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/proc_macro)
   Compiling darling v0.13.0
   Compiling nb v1.0.0
   Compiling void v1.0.2
   Compiling cache-padded v1.1.1
   Compiling waker-fn v1.1.0
   Compiling byteorder v1.4.3
   Compiling parking v2.0.0
   Compiling futures-io v0.3.18
   Compiling pin-project-lite v0.2.7
   Compiling fastrand v1.5.0
   Compiling event-listener v2.5.1
   Compiling display-interface v0.4.1
   Compiling async-task v4.0.3
   Compiling base64 v0.12.3
   Compiling slab v0.4.5
   Compiling atomic-waker v1.0.0
   Compiling mutex-trait v0.2.0
   Compiling byte-slice-cast v0.3.5
   Compiling cty v0.2.2
   Compiling stable_deref_trait v1.2.0
   Compiling micromath v1.1.1
   Compiling toml v0.5.8
   Compiling enumset_derive v0.5.5
   Compiling socket2 v0.4.2 (https://github.com/esp-rs-compat/socket2#7217ebe8)
   Compiling nb v0.1.3
   Compiling concurrent-queue v1.2.2
   Compiling hash32 v0.2.1
   Compiling no-std-net v0.5.0
   Compiling futures-lite v1.12.0
   Compiling async-lock v2.4.0
   Compiling http-auth-basic v0.1.3
   Compiling embedded-graphics-core v0.3.3
   Compiling cstr_core v0.2.4
   Compiling float-cmp v0.8.0
   Compiling cargo_toml v0.9.2
   Compiling proc-macro-crate v1.1.0
   Compiling enumset v1.0.8
   Compiling polling v2.1.0 (https://github.com/esp-rs-compat/polling#260dded7)
   Compiling embedded-hal v0.2.6
   Compiling async-channel v1.6.1
   Compiling async-executor v1.4.1
   Compiling embedded-graphics v0.7.1
   Compiling embuild v0.25.4
   Compiling num_enum_derive v0.5.4
   Compiling async-io v1.6.0
   Compiling display-interface-i2c v0.4.0
   Compiling display-interface-spi v0.4.1
   Compiling ili9341 v0.5.0 (https://github.com/yuri91/ili9341-rs#8aeefc4a)
   Compiling blocking v1.1.0
   Compiling st7789 v0.6.1
   Compiling num_enum v0.5.4
   Compiling ssd1306 v0.7.0
   Compiling esp-idf-sys v0.27.0
   Compiling esp-idf-hal v0.27.0
   Compiling esp-idf-svc v0.32.3
   Compiling rust-esp32-std-demo v0.20.6 (/opt/rust-esp32-std-demo)
   Compiling async-fs v1.5.0
   Compiling async-net v1.6.1
   Compiling embedded-svc v0.15.3
   Compiling smol v1.2.5 (https://github.com/esp-rs-compat/smol#b9a770e7)
error: failed to run custom build command for `esp-idf-sys v0.27.0`

Caused by:
  process didn't exit successfully: `/opt/rust-esp32-std-demo/target/release/build/esp-idf-sys-4c914487a370c77f/build-script-build` (exit status: 1)
  --- stdout
  Installer version: 1.0.2
  Platform: Linux-5.10.47-linuxkit-x86_64-with-glibc2.29
  Python version: 3.8.10 (default, Sep 28 2021, 16:10:42) 
  [GCC 9.3.0]
  Python path: /opt/esp/python_env/idf5.0_py3.8_env/bin/python3
  Creating a virtual environment at /root/.platformio/penv
  Updating Python package manager (PIP) in a virtual environment
  PIP has been successfully updated!
  Virtual environment has been successfully created!
  Installing PlatformIO Core
  Collecting platformio
    Downloading platformio-5.2.4.tar.gz (219 kB)
    Preparing metadata (setup.py): started
    Preparing metadata (setup.py): finished with status 'done'
  Collecting bottle==0.12.*
    Using cached bottle-0.12.19-py3-none-any.whl (89 kB)
  Collecting click!=8.0.2,<9,>=8
    Using cached click-8.0.3-py3-none-any.whl (97 kB)
  Collecting colorama
    Using cached colorama-0.4.4-py2.py3-none-any.whl (16 kB)
  Collecting marshmallow<4,>=2
    Using cached marshmallow-3.14.1-py3-none-any.whl (47 kB)
  Collecting pyelftools<1,>=0.27
    Using cached pyelftools-0.27-py2.py3-none-any.whl (151 kB)
  Collecting pyserial==3.*
    Using cached pyserial-3.5-py2.py3-none-any.whl (90 kB)
  Collecting requests==2.*
    Using cached requests-2.26.0-py2.py3-none-any.whl (62 kB)
  Collecting semantic_version==2.8.*
    Using cached semantic_version-2.8.5-py2.py3-none-any.whl (15 kB)
  Collecting tabulate==0.8.*
    Using cached tabulate-0.8.9-py3-none-any.whl (25 kB)
  Collecting zeroconf==0.37.*
    Downloading zeroconf-0.37.0-py3-none-any.whl (105 kB)
  Collecting aiofiles==0.8.*
    Downloading aiofiles-0.8.0-py3-none-any.whl (13 kB)
  Collecting ajsonrpc==1.*
    Using cached ajsonrpc-1.2.0-py3-none-any.whl (22 kB)
  Collecting starlette==0.17.*
    Using cached starlette-0.17.1-py3-none-any.whl (58 kB)
  Collecting uvicorn==0.16.*
    Downloading uvicorn-0.16.0-py3-none-any.whl (54 kB)
  Collecting wsproto==1.0.*
    Using cached wsproto-1.0.0-py3-none-any.whl (24 kB)
  Collecting charset-normalizer~=2.0.0
    Using cached charset_normalizer-2.0.9-py3-none-any.whl (39 kB)
  Collecting urllib3<1.27,>=1.21.1
    Using cached urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
  Collecting certifi>=2017.4.17
    Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
  Collecting idna<4,>=2.5
    Using cached idna-3.3-py3-none-any.whl (61 kB)
  Collecting anyio<4,>=3.0.0
    Using cached anyio-3.4.0-py3-none-any.whl (78 kB)
  Collecting h11>=0.8
    Using cached h11-0.12.0-py3-none-any.whl (54 kB)
  Collecting asgiref>=3.4.0
    Using cached asgiref-3.4.1-py3-none-any.whl (25 kB)
  Collecting ifaddr>=0.1.7
    Using cached ifaddr-0.1.7-py2.py3-none-any.whl (10 kB)
  Collecting sniffio>=1.1
    Using cached sniffio-1.2.0-py3-none-any.whl (10 kB)
  Building wheels for collected packages: platformio
    Building wheel for platformio (setup.py): started
    Building wheel for platformio (setup.py): finished with status 'done'
    Created wheel for platformio: filename=platformio-5.2.4-py3-none-any.whl size=344394 sha256=e08ce5c25916b31c0479140b215d83dc9897e657b1a1122bf75fbc3947cf894d
    Stored in directory: /root/.cache/pip/wheels/c7/5f/eb/2b681c5612c9a8ace53548f7febbd3edd52d6522ebfe2aafcc
  Successfully built platformio
  Installing collected packages: sniffio, idna, urllib3, ifaddr, h11, click, charset-normalizer, certifi, asgiref, anyio, zeroconf, wsproto, uvicorn, tabulate, starlette, semantic-version, requests, pyserial, pyelftools, marshmallow, colorama, bottle, ajsonrpc, aiofiles, platformio
  Successfully installed aiofiles-0.8.0 ajsonrpc-1.2.0 anyio-3.4.0 asgiref-3.4.1 bottle-0.12.19 certifi-2021.10.8 charset-normalizer-2.0.9 click-8.0.3 colorama-0.4.4 h11-0.12.0 idna-3.3 ifaddr-0.1.7 marshmallow-3.14.1 platformio-5.2.4 pyelftools-0.27 pyserial-3.5 requests-2.26.0 semantic-version-2.8.5 sniffio-1.2.0 starlette-0.17.1 tabulate-0.8.9 urllib3-1.26.7 uvicorn-0.16.0 wsproto-1.0.0 zeroconf-0.37.0

  PlatformIO Core has been successfully installed into an isolated environment `/root/.platformio/penv`!

  The full path to `platformio.exe` is `/root/.platformio/penv/bin/platformio`

  If you need an access to `platformio.exe` from other applications, please install Shell Commands
  (add PlatformIO Core binary directory `/root/.platformio/penv/bin` to the system environment PATH variable):

  See https://docs.platformio.org/page/installation.html#install-shell-commands

  Found compatible PlatformIO Core 5.2.4 -> /root/.platformio/penv/bin/platformio

  --- stderr
  Error: Compatible PlatformIO Core not found.
  Reason: PlatformIO Core was installed using another platform `Linux-5.11.0-1021-azure-x86_64-with-glibc2.29`. Your current platform: Linux-5.10.47-linuxkit-x86_64-with-glibc2.29
  Error: invalid type: null, expected a string at line 1 column 9390

  Stack backtrace:
     0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
     1: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
     2: embuild::pio::Pio::json
     3: embuild::pio::Pio::frameworks
     4: embuild::pio::Resolver::resolve_platform_all
     5: embuild::pio::Resolver::resolve
     6: build_script_build::build_driver::build
     7: build_script_build::main
     8: core::ops::function::FnOnce::call_once
     9: std::sys_common::backtrace::__rust_begin_short_backtrace
    10: std::rt::lang_start::{{closure}}
    11: std::rt::lang_start_internal
    12: std::rt::lang_start
    13: main
    14: __libc_start_main
    15: _start
ivmarkov commented 2 years ago

This is fixed in the meantime.

georgik commented 2 years ago

Thank you @ivmarkov . Closing. Feel free to reopen if issue is still present.

ivmarkov commented 2 years ago

@georgik what I meant is that the issue is fixed in esp-idf-sys since some time, but I have no idea if we have updated the docker images since then, sorry for the confusion.

georgik commented 2 years ago

@akselbor The image was updated with 1.58.0.0. Please pull new latest.

Note: I've noticed that --features "native" is not mentioned in the motd file. Nevertheless, CI is passing with the latest version.