ESPHome compiler failure when I switch to esp-idf

Not sure when this stopped working. I am currently on 2023.12.3 I want to create a bluetooth proxy ESP32 device. When it is initually adopted it uses the arduino framework, which the bluetooth proxy notes reccomend is changed to esp-idf.
This is the only change I make but it no longer compiles, output below.
Hardware is Raspberry Pi 4 running 11.2

Yaml file below :

esphome:
name: esphome-web-dfd104
friendly_name: ESPHome Web dfd104

esp32:
board: esp32dev
framework:
type: esp-idf

Enable logging

logger:

Enable Home Assistant API

api:
encryption:
key: “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”

ota:

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Esphome-Web-Dfd104”
password: “XXXXXXXXXXXX”

captive_portal:

INFO ESPHome 2023.11.6
INFO Reading configuration /config/esphome/esphome-web-dfd104.yaml…
INFO Generating C++ source…
INFO Compiling app…
Processing esphome-web-dfd104 (board: esp32dev; framework: espidf; platform: platformio/[email protected])

Removing unused dependencies…
Library Manager: Removing AsyncTCP-esphome @ 2.0.1
INFO Removing AsyncTCP-esphome @ 2.0.1
Library Manager: [email protected] has been removed!
INFO [email protected] has been removed!
Library Manager: Removing ESPAsyncWebServer-esphome @ 3.1.0
INFO Removing ESPAsyncWebServer-esphome @ 3.1.0
Library Manager: Removing dependencies…
INFO Removing dependencies…
Library Manager: [email protected] has been removed!
INFO [email protected] has been removed!
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • framework-espidf @ 3.40405.230623 (4.4.5)
  • tool-cmake @ 3.16.9
  • tool-ninja @ 1.10.2
  • toolchain-esp32ulp @ 2.35.0-20220830
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
    Reading CMake configuration…
    – Found Git: /usr/bin/git (found version “2.39.2”)
    – The C compiler identification is GNU 8.4.0
    – The CXX compiler identification is GNU 8.4.0
    – The ASM compiler identification is GNU
    – Found assembler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc – broken
    – Configuring incomplete, errors occurred!
    See also “/data/build/esphome-web-dfd104/.pioenvs/esphome-web-dfd104/CMakeFiles/CMakeOutput.log”.
    See also “/data/build/esphome-web-dfd104/.pioenvs/esphome-web-dfd104/CMakeFiles/CMakeError.log”.

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
CMake Error at /data/cache/platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler

"/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /data/build/esphome-web-dfd104/.pioenvs/esphome-web-dfd104/CMakeFiles/CMakeTmp

Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_647d4 && [1/2] Building C object CMakeFiles/cmTC_647d4.dir/testCCompiler.c.obj
[2/2] Linking C executable cmTC_647d4
FAILED: cmTC_647d4 
: && /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc -mlongcalls -Wno-frame-address   CMakeFiles/cmTC_647d4.dir/testCCompiler.c.obj  -o cmTC_647d4   && :
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: error loading plugin: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: cannot open shared object file: No such file or directory
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
/data/cache/platformio/packages/[email protected]/tools/cmake/project.cmake:298 (__project)
CMakeLists.txt:3 (project)

========================== [FAILED] Took 9.80 seconds ==========================

Make sure that you do “clean build files”, usually it helps. Arduino leftovers can cause these errors. If/when i change arduino/esp-idf system i always do that.

Hi Pavel, I tried that but unfortunately no difference :frowning:

Steve

Don’t remember the specific why (if I had performance issues, it was recommended, that framework doesn’t support it or it wouldn’t compile), but I explicitly have captive portal removed on any device also acting as a BT Proxy.

Oh…i missed that…yep, esp-idf doesn’t support captive portal.

Today I tried building voice assistant with esp-idf framework (new esphome device - first build) and got similar error:

Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_d6639 && [1/2] Building C object CMakeFiles/cmTC_d6639.dir/testCCompiler.c.obj
    [2/2] Linking C executable cmTC_d6639
    FAILED: cmTC_d6639 
    : && /data/cache/platformio/packages/[email protected]+2021r2-patch5/bin/xtensa-esp32-elf-gcc -mlongcalls -Wno-frame-address   CMakeFiles/cmTC_d6639.dir/testCCompiler.c.obj  -o cmTC_d6639   && :
    /data/cache/platformio/packages/[email protected]+2021r2-patch5/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/cache/platformio/packages/[email protected]+2021r2-patch5/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: error loading plugin: /data/cache/platformio/packages/[email protected]+2021r2-patch5/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: cannot open shared object file: No such file or directory
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

Hi, I have removed the captive portal but the symptoms are the same. TBH I dont think it gets as far as that anyway as it reports The C compiler
“/data/cache/platformio/packages/[email protected]+2021r2-patch5/bin/xtensa-esp32-elf-gcc”
is not able to compile a simple test program.

Hi All, i am having the same issue, running home assistant OS on a Tinker board… has anyone found a solution?

from google, i see some historic messages about it being an ARM related issue, but i cant find a solution…

Is there a way to remove esphome and re-install it on a Raspberry Pi maybe ? There is no option in the Integration to do so.

I’m having the same issues with esp-idf when compiling for Bluetooth Proxy. Need to switch the framework to arduino (but this gives low performance)

I’m trying to create a Voice Assistant using the code from here but get teh same error when trying to compile.

INFO ESPHome 2023.12.9
INFO Reading configuration /config/esphome/mi_flora_server_1.yaml...
WARNING 'miflora_server_1': Using the '_' (underscore) character in the hostname is discouraged as it can cause problems with some DHCP and local name services. For more information, see https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name
Failed config

voice_assistant: [source <unicode string>:113]
  id: va
  microphone: mic_i2s
  use_wake_word: True
  noise_suppression_level: 4
  auto_gain: 31dBFS
  volume_multiplier: 8.0
  
  This option requires component esp_adf.
  vad_threshold: 3
  on_client_connected: 
    - lambda: id(init_in_progress) = false;
    - if: 
        condition: 
          switch.is_on: use_wake_word
        then: 
          - voice_assistant.start_continuous: {}
          - lambda: id(voice_assistant_phase) = 1;
        else: 
          - lambda: id(voice_assistant_phase) = 12;
  on_client_disconnected: 
    - lambda: id(voice_assistant_phase) = 10;
    - voice_assistant.stop
  on_error: 
    - if: 
        condition: 
          lambda: return !id(init_in_progress);
        then: 
          - lambda: id(voice_assistant_phase) = 11;
          - delay: 1s
          - if: 
              condition: 
                switch.is_on: use_wake_word
              then: 
                - lambda: id(voice_assistant_phase) = 1;
              else: 
                - lambda: id(voice_assistant_phase) = 12;

I don’t understant why it won’t work given that my code is straight from the example. The error asks for ‘esp-adf’ but that’s not a valid option for the framework.

I don’t have captive portal and I also tried without bluetooth proxy code but no joy.

Did you guys get it sorted?

Did anyone find a fix for this? I’m trying to build a BT Proxy on an M5 Atom Lite and having the same issue with esp-idf

found you can remove the esphome in the “Add-Ons” section of Settings, but its didnt help to uninstall and re-install :frowning:

No fix, just a workaround to download the yaml file to my mac and compile it there. Compiling for esp32 on ARM just seems to be broken.

yep, I found I had missed a critical bit of code that is required to get Voice Assistant working with the esp-idf.

You need to have:

esp_adf:    
external_components:
  - source: github://pr#5230
    components:
      - esp_adf
    refresh: 0s

…which I had somehow missed when copying the code across to an existing ESP device.

oh, and do a “clean build files” for the device in the ESPhome dashboard.

I switched my Raspberry Pi up to the 64bit version of HASSOS and all works great again !