esp-idf-sys icon indicating copy to clipboard operation
esp-idf-sys copied to clipboard

Using esp-idf-sys without downloading anything

Open TheNeikos opened this issue 1 year ago • 4 comments

I am a nixos user and would like to use esp-idf-sys. However, it insists on downloading things while building (imo a bad idea, it is very unexpected), which I cannot do.

I am using the ESP32-C3 and do not want to use the xtensa toolchain, and instead just use the normal cargo compiler targeting riscv. Currently, this is not possible, as it requires either 'native' or 'pio'. Neither of which I want to use.

Is there any way I can still use your project?

Things that would be required for my usecase:

  • No downloads during builds
  • List of required build tools (like Clang/cmake) that need to be in $PATH.

Thanks!

Edit

Looking more into it, it seems that the project is expecting a git repository. This seems unecessary when 'fromenv' is supplied? I expect the crate to assume that all the necessary tools/files are accessible in the PATH or in the env variables as if an $ESP_IDF/export.* was called.

In my case for example, I can install ESP_IDF into my environment, but that does not come with any git information. (After all, why is that important? I am using fromenv after all.)

TheNeikos avatar Sep 12 '22 09:09 TheNeikos

Yes, this is possible, and its what I use daily :). esp-idf is a hard dependency on esp-idf-sys so the options are have it downloaded already or download it, the latter being the default for ease of use.

If you download esp-idf manually, run the tool install script once, then all you have to do is source the idf environment (steps 3-5 from here). Once the environment is sourced, esp-idf-sys will use those sources to build esp-idf, instead of downloading it.

fromenv shouldn't really be needed, as the build script will detect the environment and switch anyway, but it may be needed to find the environment tools.

MabezDev avatar Sep 12 '22 12:09 MabezDev

Sadly this still errors, albeit with a different error:

❯ cargo check
   Compiling esp-idf-sys v0.31.5
error: failed to run custom build command for `esp-idf-sys v0.31.5`

Caused by:
  process didn't exit successfully: `/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/debug/build/esp-idf-sys-cf2a3985b2fa3f8f/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=IDF_PATH
  cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
  cargo:rerun-if-env-changed=ESP_IDF_VERSION
  cargo:rerun-if-env-changed=ESP_IDF_REPOSITORY
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
  cargo:rerun-if-env-changed=MCU
  cargo:rerun-if-changed=/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/sdkconfig.defaults
  CMAKE_PREFIX_PATH_riscv32imc-esp-espidf = None
  CMAKE_PREFIX_PATH_riscv32imc_esp_espidf = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = Some("/nix/store/4g5fidyk19akng9n91cql60ylrjq93s6-gcc-wrapper-10.3.0:/nix/store/95b5bf92ck38jp5lyih5kw9f2glx4gkm-binutils-wrapper-2.35.1:/nix/store/w9c6m0qy0c2hc77nggbcy4hq9dys8fw7-rust-default-1.65.0-nightly-2022-09-04:/nix/store/gsl84cnlwz1nkn5bgkm88m3lz884fgib-espflash-1.6.0:/nix/store/zv9i80xc9j2csz6jcv3appp8vxhjvaa6-ldproxy-0.3.2:/nix/store/mf3vixxfdvs9vn9fzz24hbjq3fq5pgpl-python3.9-pip-21.1.3:/nix/store/8dxxjbiyxwkvh53q5kh6nydla2anacgi-python3-3.9.6:/nix/store/jsx4mm56igrd6pmh7hs3asfrgg4kd1q2-python3.9-virtualenv-20.8.1:/nix/store/s17aj48g92cyz17fmbwn7yqnwk1ybbz2-python3.9-backports-entry-points-selectable-1.1.0:/nix/store/8smrlirz30mg91xpxsdvjirvnzzrahid-python3.9-distlib-0.3.3:/nix/store/y8f3i57ndxlsr2kmy396q0vn0dhz8wvr-python3.9-filelock-3.3.0:/nix/store/arkwlnr8pjbzpf60125yyzfgxywa3f7i-python3.9-platformdirs-2.4.0:/nix/store/7ixnxb28f4sg2c08a1pnp3yxdb0h48cs-python3.9-six-1.16.0:/nix/store/k39dr5rzpz6ifwif7zdnf7kf3w309gp1-cargo-edit-0.8.0:/nix/store/9xz9aga97wc35y5dmlkya8nyiky9014r-esp32c3-toolchain-2021r2-patch3:/nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1:/nix/store/njg99sqcyglfsg2lf1p755r2wivrrsww-esptool-3.2:/nix/store/dgp3mvkfnf6v0bz0qbh94cxqhi1hld4i-python3.9-pyserial-3.5:/nix/store/ryhpb1y18qf4gcy2m5r2d2jbf05w415p-python3.9-pyaes-1.6.1:/nix/store/h14y9gs3m48n74m58bi5p4lkswy7yy2a-python3.9-ecdsa-0.17.0:/nix/store/llgs201w4ma372xb574inmzji1phzr01-python3.9-reedsolo-1.5.4:/nix/store/khf8kwnc2bwhb5vxjmxkx7jpvyc7c6iw-python3.9-bitstring-3.1.9:/nix/store/7imvz43yrh3a22ajqkabz667hq2zrrz4-python3.9-cryptography-3.4.8-dev:/nix/store/7n6fj45g1q6ilckx332j6rwv0q1mbcnj-python3.9-packaging-20.9:/nix/store/40r94pxfjm049w38zs1dn5mw937mgdwf-python3.9-pyparsing-2.4.7:/nix/store/4a198098n5wm7wnn4ni6z46y8bnpfjn7-python3.9-cffi-1.14.6-dev:/nix/store/4flpmcvw0p795bx1s9lnam7kyl7qhviv-python3.9-pycparser-2.20:/nix/store/wf8vlq8gibp76vp816yw0fxjlc5ldphs-python3.9-cffi-1.14.6:/nix/store/09gdhd7z0cjrdd4m9czpjjbnx815hdlb-python3.9-cryptography-3.4.8:/nix/store/zhf7xxp7k1605wirn29kylg1x2bl4pq3-git-2.33.1:/nix/store/8k89kjnnns1j72mfm1i2xsz2dvpy9kpl-wget-1.21.2:/nix/store/4xzvmpwx8lhjgiypdkffl4nzg6pb4lcb-gnumake-4.3:/nix/store/k64ipsghczdyf0pirbvqmjk4idkh6860-flex-2.6.4:/nix/store/2ysk871hamhwb8npzrycpbpdp77dkdws-gnum4-1.4.19:/nix/store/5nhdzkfiv2cin7hlhq88i8zjhgbi82hn-bison-3.7.6:/nix/store/sind0shkjaywcffa5zkypf5411z8w6c5-gperf-3.1:/nix/store/a4fd1rmx1fjx8ashzwaqwvmwpfbm450l-pkg-config-wrapper-0.29.2:/nix/store/sg4gfdp6ahmz8341zh8r3f2s1hylmy47-cmake-3.21.2:/nix/store/vvdy4xg9gd2fgh4rb4i8sy09s08gnr8s-ninja-1.10.2:/nix/store/mscxycfi44z0jwvyz71yv11c3fwbv3nn-ncurses-6.2-abi5-compat-dev:/nix/store/5qjm3h2nynq925ksqw3z31ci3jpf0z75-ncurses-6.2-abi5-compat:/nix/store/p4axvsdpc70w7d9g4kkl3d25swh71fgd-patchelf-0.13")
  CMAKE_riscv32imc-esp-espidf = None
  CMAKE_riscv32imc_esp_espidf = None
  TARGET_CMAKE = None
  CMAKE = None
  running: "cmake" "/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out" "-G" "Ninja" "-DCMAKE_TOOLCHAIN_FILE=/nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/tools/cmake/toolchain-esp32c3.cmake" "-DCMAKE_BUILD_TYPE=" "-DCMAKE_INSTALL_PREFIX=/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out" "-DCMAKE_C_FLAGS= -march=rv32imc -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -mcmodel=medany" "-DCMAKE_CXX_FLAGS= -march=rv32imc -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -mcmodel=medany" "-DCMAKE_ASM_FLAGS=  -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -mcmodel=medany"
  -- Checking Python dependencies...
  Python requirements from /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/requirements.txt are satisfied.
  -- Project sdkconfig file /home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/sdkconfig
  Loading defaults file /home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/gen-sdkconfig.defaults...
  Loading defaults file /home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/sdkconfig.defaults...
  -- App "libespidf" version: 1
  -- Adding linker script /home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/build/esp-idf/esp_system/ld/memory.ld
  -- Adding linker script /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/components/esp_system/ld/esp32c3/sections.ld.in
  -- Adding linker script /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/components/esp_rom/esp32c3/ld/esp32c3.rom.ld
  -- Adding linker script /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/components/esp_rom/esp32c3/ld/esp32c3.rom.api.ld
  -- Adding linker script /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/components/esp_rom/esp32c3/ld/esp32c3.rom.libgcc.ld
  -- Adding linker script /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/components/esp_rom/esp32c3/ld/esp32c3.rom.newlib.ld
  -- Adding linker script /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/components/esp_rom/esp32c3/ld/esp32c3.rom.version.ld
  -- Adding linker script /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/components/esp_rom/esp32c3/ld/esp32c3.rom.newlib-time.ld
  -- Adding linker script /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld
  -- Adding linker script /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/components/soc/esp32c3/ld/esp32c3.peripherals.ld
  -- Configuring incomplete, errors occurred!
  See also "/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/build/CMakeFiles/CMakeOutput.log".
  See also "/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/build/CMakeFiles/CMakeError.log".

  --- stderr
  Using activated esp-idf v4.4.1 environment at '/nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1'
  CMake Error at build/CMakeFiles/git-data/grabRef.cmake:48 (file):
    file failed to open for reading (No such file or directory):

      /home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/build/CMakeFiles/git-data/head-ref
  Call Stack (most recent call first):
    /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/tools/cmake/third_party/GetGitRevisionDescription.cmake:80 (include)
    /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/tools/cmake/third_party/GetGitRevisionDescription.cmake:90 (get_git_head_revision)
    /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/tools/cmake/build.cmake:67 (git_describe)
    /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/tools/cmake/build.cmake:174 (__build_get_idf_git_revision)
    /nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/tools/cmake/idf.cmake:50 (__build_init)
    CMakeLists.txt:3 (include)


  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 1

  build script failed, must exit now', /home/neikos/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.48/src/lib.rs:975:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

and the content of that file

#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

set(HEAD_HASH)

file(READ "/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/build/CMakeFiles/git-data/HEAD" HEAD_CONTENTS LIMIT 1024)

string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
set(GIT_DIR "/nix/store/cp482m3fyv64rcbl5p7fzzpmigmly0fz-esp-idf-v4.4.1/.git")
# handle git-worktree
if(EXISTS "${GIT_DIR}/commondir")
	file(READ "${GIT_DIR}/commondir" GIT_DIR_NEW LIMIT 1024)
	string(STRIP "${GIT_DIR_NEW}" GIT_DIR_NEW)
	if(NOT IS_ABSOLUTE "${GIT_DIR_NEW}")
		get_filename_component(GIT_DIR_NEW ${GIT_DIR}/${GIT_DIR_NEW} ABSOLUTE)
	endif()
	if(EXISTS "${GIT_DIR_NEW}")
		set(GIT_DIR "${GIT_DIR_NEW}")
	endif()
endif()
if(HEAD_CONTENTS MATCHES "ref")
	# named branch
	string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
	if(EXISTS "${GIT_DIR}/${HEAD_REF}")
		configure_file("${GIT_DIR}/${HEAD_REF}" "/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/build/CMakeFiles/git-data/head-ref" COPYONLY)
	elseif(EXISTS "${GIT_DIR}/logs/${HEAD_REF}")
		configure_file("${GIT_DIR}/logs/${HEAD_REF}" "/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/build/CMakeFiles/git-data/head-ref" COPYONLY)
		set(HEAD_HASH "${HEAD_REF}")
	endif()
else()
	# detached HEAD
	configure_file("${GIT_DIR}/HEAD" "/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/build/CMakeFiles/git-data/head-ref" COPYONLY)
endif()

if(NOT HEAD_HASH)
	file(READ "/home/neikos/projects/embedded/simple_rgb/espressif-trainings/intro/hardware-check/target/riscv32imc-esp-espidf/debug/build/esp-idf-sys-32e02a0960456f2b/out/build/CMakeFiles/git-data/head-ref" HEAD_HASH LIMIT 1024)
	string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()

This doesn't seem to come from esp-idf-sys though :thinking:

TheNeikos avatar Sep 12 '22 20:09 TheNeikos