Venv problem with ESP32 toolchain

Hello,

I have some problems building the code for anything with an ESP with the current master.

I’m using a fresh install of Ubuntu on wsl 2. I followed the steps from here: Setting up the Build Environment (Linux/Ubuntu) — Dev documentation
Everything worked as expected, I was also able to build the code for the SkyViper.

Then I proceeded with the instructions for ESP32 from here: ardupilot/libraries/AP_HAL_ESP32/README.md at master · ArduPilot/ardupilot · GitHub
The first problem was when I executed ./install.sh. This resulted in:

This script was called from a virtual environment, can not create a virtual environment again

So I used deactivate to leave the venv-ardupilot and rerun the command which worked and I could proceed further. During configure it was missing some python packages, which I installed. But then it failed with ninja: error: loading ‘build.ninja’

After restarting the wsl, I now get the error message: Could not find the program [‘xtensa-esp32-elf-ar’]

My guess is that something with the virtual environments is wrong, because I managed to build the ESP code a few months back without problems, but that time I didn’t see the venv-ardupilot…

Any clue what I could have done wrong? Thank you!

Okay, I think I’ve figured it out. One must leave the (venv-ardupilot) before calling ./waf configure, ./waf configure --board=esp32empty and install the missing python libraries.

Since I don’t think that this is intended, this is the error message I get if I run the commands in (venv-ardupilot): (Please note that this test was not performed on latest master but on this branch GitHub - srmainwaring/ardupilot at wips/wip-esp32-stampfly+bmm150, since I want to flash the stampfly)

Error message with venv-ardupilot

(venv-ardupilot) valentin@DESKTOP-6NIIMMJ:~/ardupilot$ ./waf copter
Waf: Entering directory `/home/valentin/ardupilot/build/esp32s3m5stampfly’
Embedding file defaults.parm:libraries/AP_HAL_ESP32/hwdef/esp32s3m5stampfly/defaults.parm
[1/4] delete sdkconfig generated from libraries/AP_HAL_ESP32/targets/esp32s3/esp-idf/sdkconfig.defaults
[2/4] CMake Configure esp-idf
– The C compiler identification is GNU 13.2.0
– The CXX compiler identification is GNU 13.2.0
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: /home/valentin/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc - 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: /home/valentin/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/xtensa-esp32s3-elf-g++ - skipped
– Detecting CXX compile features
– Detecting CXX compile features - done
– Found Git: /usr/bin/git (found version “2.43.0”)
– Checking Python dependencies…
Python requirements are satisfied.
Constraint file: /home/valentin/.espressif/espidf.constraints.v5.3.txt
Requirement files:

  • /home/valentin/ardupilot/modules/esp_idf/tools/requirements/requirements.core.txt
    Python being checked: /home/valentin/.espressif/python_env/idf5.3_py3.12_env/bin/python
    – Project sdkconfig file /home/valentin/ardupilot/build/esp32s3m5stampfly/esp-idf_build/sdkconfig
    – Configuring incomplete, errors occurred!
    /home/valentin/venv-ardupilot/bin/python: No module named kconfgen
    CMake Error at /home/valentin/ardupilot/modules/esp_idf/tools/cmake/kconfig.cmake:209 (message):
    Failed to run kconfgen
    (python;-m;kconfgen;–list-separator=semicolon;–kconfig;/home/valentin/ardupilot/modules/esp_idf/Kconfig;–sdkconfig-rename;/home/valentin/ardupilot/modules/esp_idf/sdkconfig.rename;–config;/home/valentin/ardupilot/build/esp32s3m5stampfly/esp-idf_build/sdkconfig;–defaults;/home/valentin/ardupilot/libraries/AP_HAL_ESP32/targets/esp32s3/esp-idf/sdkconfig.defaults;–env-file;/home/valentin/ardupilot/build/esp32s3m5stampfly/esp-idf_build/config.env).
    Error 1
    Call Stack (most recent call first):
    /home/valentin/ardupilot/modules/esp_idf/tools/cmake/build.cmake:623 (__kconfig_generate_config)
    CMakeLists.txt:11 (idf_build_process)

@Vabe - as you’ve noted, when building for esp32 do not activate another venv before sourcing the esp-idf environment, as that activates it’s own virtual environment as sets up the necessary variables to locate the esp32 toolchain.

The ardupilot venv is for stm32 and sitl builds - we should perhaps make that clearer.

1 Like