ESPHome install to board fails with CMake error

Hi All -

I’m having issues flashing my first ESP32 using ESPHome via Home Assistant. Each time I attempt to install the auto-generated YAML, ESPHome gives me a build error. I am pretty early in the process here, so must be doing something wrong.

This is an ESP-WROOM-32 with ESPHome 2023.2.4 and HAOS 2023.2.5

These are the steps I followed, and I apologize for the fuzziness in some of the earlier steps:

  1. I went to ESPHome Bluetooth Proxy and installed the firmware there.
  2. Fairly sure after that, I was able to initially add the board via the ESPHome Add On in Home Assistant, without any errors.
  3. I attempted to add to the config, and ended up with a build error, which I’ll include at the end of this post

I tried quite a bit after this, including pointing to an older version of esp-idf as suggested in this thread. That got me a little further, but I ended up with a different build error.

I also tried stripping down the YAML to barebones, with the same result. Eventually I used the Bluetooth Proxy site to reinstall that firmware as a new starting point, and was never able to get back to what I recalled from step 2 above.

Here is the YAML I’m using

substitutions:
  name: esp32-bluetooth-proxy
  friendly_name: Bedroom BTLE
packages:
  esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/esp32-generic.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
api:
  encryption:
    key: <I removed this to share>
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

And here is the error I ultimately get:

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/esp32-bluetooth-proxy-1db558/.pioenvs/esp32-bluetooth-proxy-1db558/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_96c05 && [1/2] Building C object CMakeFiles/cmTC_96c05.dir/testCCompiler.c.obj
    [2/2] Linking C executable cmTC_96c05
    FAILED: cmTC_96c05 
    : && /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc -mlongcalls -Wno-frame-address   CMakeFiles/cmTC_96c05.dir/testCCompiler.c.obj  -o cmTC_96c05   && :
    /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/framework-espidf/tools/cmake/project.cmake:296 (__project)
  CMakeLists.txt:3 (project)

Any suggestions would be greatly appreciated. I can’t seem to get beyond this.

Hello, do you try using the “Clean Build Files” options under the 3 dots in the device in ESPHome Dashboard? I have to use this option for my esp-idf devices every time I compile them.

I’m running into the same issue, cleaning build files did not work.

esphome CMake Error at /data/cache/platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60

Same here with ESPHome 2023.11.6:

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/esp-bluetooth-proxy/.pioenvs/esp-bluetooth-proxy/CMakeFiles/CMakeOutput.log".
See also "/data/build/esp-bluetooth-proxy/.pioenvs/esp-bluetooth-proxy/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/esp-bluetooth-proxy/.pioenvs/esp-bluetooth-proxy/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_a5bcf && [1/2] Building C object CMakeFiles/cmTC_a5bcf.dir/testCCompiler.c.obj
    [2/2] Linking C executable cmTC_a5bcf
    FAILED: cmTC_a5bcf 
    : && /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc -mlongcalls -Wno-frame-address   CMakeFiles/cmTC_a5bcf.dir/testCCompiler.c.obj  -o cmTC_a5bcf   && :
    /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/framework-espidf/tools/cmake/project.cmake:298 (__project)
  CMakeLists.txt:3 (project)

EDIT:

Was able to compile with workaround to define Arduino framework (found here):

esp32:
  board: esp32dev
  framework:
    type: arduino

Going to Arduino framework fixed it for me too. However, I’ve read that this was not the advised framework for Bluetooth Proxy due to stability/latency? (Sorry, can’t find the source of that at the moment).

This might be helpful for others too using ESP32-S3: esp-idf framework problem? · Issue #4945 · esphome/issues · GitHub