PlatformIO Community

Could not initialize project for framework Espressif

Win10 10.0.19043
VS Code 1.62.3
PIO Core 5.2.3
PIO Home 3.4.0
Espressif 32 3.4.0
—framework-arduinoespressif32 3.10006.210326 (1.0.6)
—framework-espidf 3.40301.0 (4.3.1)

I am having trouble importing example projects and even creating a new project.
I have started fresh with PIO:
Uninstalled PIO plugin from VSCode and closed
Deleted C:\Users\David.platformio
Deleted C:\Users\David.vscode\extensions\platformio.platformio-ide-2.4.0
Opened VSCode and installed PIO Extension.

I can create a new project if the target framework is Arduino, but not Espressif IOT Development Framework.

Steps to replicate:
In VSCode, go to PIO Home. Select Projects->Create New Project.
Name: Foo
Board: Adafruit ESP32 Feather
Framework: Espressif IOT Development Framework

After a long time I get this error:

PIO Project Init Failed

Also the “Report a problem” button doesn’t appear to work.

Same issue: Can not initialize Project for Espressif IoT Dev framework
Possibly related post: Cant create project with doit esp32 devkit v1 with esp-idf framework

I have seen in other posts this issue may be related to a missing Git commit, but I’m not using Git. I did find that this folder exists:
C:\Users\David\OneDrive\Documents\PlatformIO\Projects\IDFTEST.pio\build\featheresp32\CMakeFiles\git-data
If I delete it, PIO recreates it as soon as I switch the PIO project environment to that project.

I can manually open the failed project, and it will compile but fail with CMake error “file failed to open for reading (No such file or directory):”.

------------------Full error message of failed project creation--------------------
PIO Core Call Error: “The current working directory C:\Users\David\OneDrive\Documents\PlatformIO\Projects\Foo will be used for the project.\r\n\r\nThe next files/directories have been created in C:\Users\David\OneDrive\Documents\PlatformIO\Projects\Foo\r\ninclude - Put project header files here\r\nlib - Put here project specific (private) libraries\r\nsrc - Put project source files here\r\nplatformio.ini - Project Configuration File\r\n\n\nError: Processing pico32 (platform: espressif32; board: pico32; framework: espidf)\r\n--------------------------------------------------------------------------------\r\nVerbose mode can be enabled via -v, --verbose option\r\nCONFIGURATION: https://docs.platformio.org/page/boards/espressif32/pico32.html\r\nPLATFORM: Espressif 32 (3.4.0) > ESP32 Pico Kit\r\nHARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash\r\nDEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)\r\nPACKAGES: \r\n - framework-espidf 3.40301.0 (4.3.1) \r\n - tool-cmake 3.16.4 \r\n - tool-esptoolpy 1.30100.210531 (3.1.0) \r\n - tool-idf 1.0.1 \r\n - tool-mconf 1.4060000.20190628 (406.0.0) \r\n - tool-ninja 1.9.0 \r\n - toolchain-esp32ulp 1.22851.191205 (2.28.51) \r\n - toolchain-riscv32-esp 8.4.0+2021r1 \r\n - toolchain-xtensa-esp32 8.4.0+2021r1 \r\n - toolchain-xtensa-esp32s2 8.4.0+2021r1\r\nReading CMake configuration…\r\n-- Found Git: C:/Program Files/Git/cmd/git.exe (found version “2.24.0.windows.2”) \r\n-- The C compiler identification is GNU 8.4.0\r\n-- The CXX compiler identification is GNU 8.4.0\r\n-- The ASM compiler identification is GNU\r\n-- Found assembler: C:/Users/David/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc.exe\r\n-- Check for working C compiler: C:/Users/David/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc.exe\r\n-- Check for working C compiler: C:/Users/David/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc.exe – works\r\n-- Detecting C compiler ABI info\r\n-- Detecting C compiler ABI info - done\r\n-- Detecting C compile features\r\n-- Detecting C compile features - done\r\n-- Check for working CXX compiler: C:/Users/David/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-g++.exe\r\n-- Check for working CXX compiler: C:/Users/David/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-g++.exe – works\r\n-- Detecting CXX compiler ABI info\r\n-- Detecting CXX compiler ABI info - done\r\n-- Detecting CXX compile features\r\n-- Detecting CXX compile features - done\r\n-- Project is not inside a git repository, or git repository has no commits; will not use ‘git describe’ to determine PROJECT_VER.\r\n-- Building ESP-IDF components for target esp32\r\n-- Project sdkconfig file C:/Users/David/OneDrive/Documents/PlatformIO/Projects/Foo/sdkconfig.pico32\r\n-- Found PythonInterp: C:/Users/David/.platformio/penv/Scripts/python.exe (found version “3.9.8”) \r\n-- Could NOT find Perl (missing: PERL_EXECUTABLE) \r\n-- App “Foo” version: 1\r\n-- Adding linker script C:/Users/David/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.ld\r\n-- Adding linker script C:/Users/David/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.api.ld\r\n-- Adding linker script C:/Users/David/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld\r\n-- Adding linker script C:/Users/David/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld\r\n-- Adding linker script C:/Users/David/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld\r\n-- Adding linker script C:/Users/David/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld\r\n-- Adding linker script C:/Users/David/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.newlib-time.ld\r\n-- Adding linker script C:/Users/David/OneDrive/Documents/PlatformIO/Projects/Foo/.pio/build/pico32/esp-idf/esp32/esp32_out.ld\r\n-- Adding linker script C:/Users/David/.platformio/packages/framework-espidf/components/esp32/ld/esp32.project.ld.in\r\n-- Adding linker script C:/Users/David/.platformio/packages/framework-espidf/components/esp32/ld/esp32.peripherals.ld\r\n-- Components: __pio_env app_trace app_update asio bootloader bootloader_support bt cbor cmock coap console cxx driver efuse esp-tls esp32 esp_adc_cal esp_common esp_eth esp_event esp_gdbstub esp_hid esp_http_client esp_http_server esp_https_ota esp_https_server esp_hw_support esp_ipc esp_local_ctrl esp_netif esp_pm esp_ringbuf esp_rom esp_serial_slave_link esp_system esp_timer esp_websocket_client esp_wifi espcoredump esptool_py expat fatfs freemodbus freertos hal heap idf_test jsmn json libsodium log lwip mbedtls mdns mqtt newlib nghttp nvs_flash openssl partition_table perfmon protobuf-c protocomm pthread sdmmc soc spi_flash spiffs src tcp_transport tcpip_adapter tinyusb ulp unity vfs wear_levelling wifi_provisioning wpa_supplicant xtensa\r\n-- Component paths: C:/Users/David/OneDrive/Documents/PlatformIO/Projects/Foo/.pio/build/pico32/__pio_env C:/Users/David/.platformio/packages/framework-espidf/components/app_trace C:/Users/David/.platformio/packages/framework-espidf/components/app_update C:/Users/David/.platformio/packages/framework-espidf/components/asio C:/Users/David/.platformio/packages/framework-espidf/components/bootloader C:/Users/David/.platformio/packages/framework-espidf/components/bootloader_support C:/Users/David/.platformio/packages/framework-espidf/components/bt C:/Users/David/.platformio/packages/framework-espidf/components/cbor C:/Users/David/.platformio/packages/framework-espidf/components/cmock C:/Users/David/.platformio/packages/framework-espidf/components/coap C:/Users/David/.platformio/packages/framework-espidf/components/console C:/Users/David/.platformio/packages/framework-espidf/components/cxx C:/Users/David/.platformio/packages/framework-espidf/components/driver C:/Users/David/.platformio/packages/framework-espidf/components/efuse C:/Users/David/.platformio/packages/framework-espidf/components/esp-tls C:/Users/David/.platformio/packages/framework-espidf/components/esp32 C:/Users/David/.platformio/packages/framework-espidf/components/esp_adc_cal C:/Users/David/.platformio/packages/framework-espidf/components/esp_common C:/Users/David/.platformio/packages/framework-espidf/components/esp_eth C:/Users/David/.platformio/packages/framework-espidf/components/esp_event C:/Users/David/.platformio/packages/framework-espidf/components/esp_gdbstub C:/Users/David/.platformio/packages/framework-espidf/components/esp_hid C:/Users/David/.platformio/packages/framework-espidf/components/esp_http_client C:/Users/David/.platformio/packages/framework-espidf/components/esp_http_server C:/Users/David/.platformio/packages/framework-espidf/components/esp_https_ota C:/Users/David/.platformio/packages/framework-espidf/components/esp_https_server C:/Users/David/.platformio/packages/framework-espidf/components/esp_hw_support C:/Users/David/.platformio/packages/framework-espidf/components/esp_ipc C:/Users/David/.platformio/packages/framework-espidf/components/esp_local_ctrl C:/Users/David/.platformio/packages/framework-espidf/components/esp_netif C:/Users/David/.platformio/packages/framework-espidf/components/esp_pm C:/Users/David/.platformio/packages/framework-espidf/components/esp_ringbuf C:/Users/David/.platformio/packages/framework-espidf/components/esp_rom C:/Users/David/.platformio/packages/framework-espidf/components/esp_serial_slave_link C:/Users/David/.platformio/packages/framework-espidf/components/esp_system C:/Users/David/.platformio/packages/framework-espidf/components/esp_timer C:/Users/David/.platformio/packages/framework-espidf/components/esp_websocket_client C:/Users/David/.platformio/packages/framework-espidf/components/esp_wifi C:/Users/David/.platformio/packages/framework-espidf/components/espcoredump C:/Users/David/.platformio/packages/framework-espidf/components/esptool_py C:/Users/David/.platformio/packages/framework-espidf/components/expat C:/Users/David/.platformio/packages/framework-espidf/components/fatfs C:/Users/David/.platformio/packages/framework-espidf/components/freemodbus C:/Users/David/.platformio/packages/framework-espidf/components/freertos C:/Users/David/.platformio/packages/framework-espidf/components/hal C:/Users/David/.platformio/packages/framework-espidf/components/heap C:/Users/David/.platformio/packages/framework-espidf/components/idf_test C:/Users/David/.platformio/packages/framework-espidf/components/jsmn C:/Users/David/.platformio/packages/framework-espidf/components/json C:/Users/David/.platformio/packages/framework-espidf/components/libsodium C:/Users/David/.platformio/packages/framework-espidf/components/log C:/Users/David/.platformio/packages/framework-espidf/components/lwip C:/Users/David/.platformio/packages/framework-espidf/components/mbedtls C:/Users/David/.platformio/packages/framework-espidf/components/mdns C:/Users/David/.platformio/packages/framework-espidf/components/mqtt C:/Users/David/.platformio/packages/framework-espidf/components/newlib C:/Users/David/.platformio/packages/framework-espidf/components/nghttp C:/Users/David/.platformio/packages/framework-espidf/components/nvs_flash C:/Users/David/.platformio/packages/framework-espidf/components/openssl C:/Users/David/.platformio/packages/framework-espidf/components/partition_table C:/Users/David/.platformio/packages/framework-espidf/components/perfmon C:/Users/David/.platformio/packages/framework-espidf/components/protobuf-c C:/Users/David/.platformio/packages/framework-espidf/components/protocomm C:/Users/David/.platformio/packages/framework-espidf/components/pthread C:/Users/David/.platformio/packages/framework-espidf/components/sdmmc C:/Users/David/.platformio/packages/framework-espidf/components/soc C:/Users/David/.platformio/packages/framework-espidf/components/spi_flash C:/Users/David/.platformio/packages/framework-espidf/components/spiffs C:/Users/David/OneDrive/Documents/PlatformIO/Projects/Foo/src C:/Users/David/.platformio/packages/framework-espidf/components/tcp_transport C:/Users/David/.platformio/packages/framework-espidf/components/tcpip_adapter C:/Users/David/.platformio/packages/framework-espidf/components/tinyusb C:/Users/David/.platformio/packages/framework-espidf/components/ulp C:/Users/David/.platformio/packages/framework-espidf/components/unity C:/Users/David/.platformio/packages/framework-espidf/components/vfs C:/Users/David/.platformio/packages/framework-espidf/components/wear_levelling C:/Users/David/.platformio/packages/framework-espidf/components/wifi_provisioning C:/Users/David/.platformio/packages/framework-espidf/components/wpa_supplicant C:/Users/David/.platformio/packages/framework-espidf/components/xtensa\r\n-- Configuring incomplete, errors occurred!\r\nSee also “C:/Users/David/OneDrive/Documents/PlatformIO/Projects/Foo/.pio/build/pico32/CMakeFiles/CMakeOutput.log”.\r\n\r\nCMake Error at .pio/build/pico32/CMakeFiles/git-data/grabRef.cmake:48 (file):\r\n file failed to open for reading (No such file or directory):\r\n\r\n C:/Users/David/OneDrive/Documents/PlatformIO/Projects/Foo/.pio/build/pico32/CMakeFiles/git-data/head-ref\r\nCall Stack (most recent call first):\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/third_party/GetGitRevisionDescription.cmake:80 (include)\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/third_party/GetGitRevisionDescription.cmake:90 (get_git_head_revision)\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/build.cmake:67 (git_describe)\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/build.cmake:165 (__build_get_idf_git_revision)\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/idf.cmake:50 (__build_init)\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/project.cmake:7 (include)\r\n CMakeLists.txt:2 (include)\r\n\r\n\r\nCMake Error at .pio/build/pico32/CMakeFiles/git-data/grabRef.cmake:48 (file):\r\n file failed to open for reading (No such file or directory):\r\n\r\n C:/Users/David/OneDrive/Documents/PlatformIO/Projects/Foo/.pio/build/pico32/CMakeFiles/git-data/head-ref\r\nCall Stack (most recent call first):\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/third_party/GetGitRevisionDescription.cmake:80 (include)\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/third_party/GetGitRevisionDescription.cmake:90 (get_git_head_revision)\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/project.cmake:52 (git_describe)\r\n C:/Users/David/.platformio/packages/framework-espidf/tools/cmake/project.cmake:395 (__project_get_revision)\r\n CMakeLists.txt:3 (project)\r\n\r\n\r\n\r\n========================= [FAILED] Took 10.23 seconds =========================”

Are you sure you’re not running into the same issue as described in Can not initialize Project for Espressif IoT Dev framework - #12 by kherrmann?

After an even more exhaustive search, I think I found it.

C:\Users\David\OneDrive\Documents\PlatformIO\Projects\IDFTEST.pio\build\featheresp32\CMakeFiles\git-data\ [Recreated on every build]
C:\Users\David\ .git

Removing the .git folder and then doing a clean/build does fix the project. Why would PIO be looking here?!? That git folder has been on my computer for over a year, and should have nothing to do with PIO projects.

I have also verified I can now import PIO projects targeting espidf platform. I tried the “espidf-arduino-blink” example. It imports and compiles.

The issue for this post is:
Why does PIO look for .git folders outside (above) of the project folder, and can that be fixed?

Why does *the ESP-IDF build system look for .git folders outside the project folder, is more likely the question that should be asked, since it occurs in standard ESP-IDF too (https://github.com/espressif/esp-idf/issues/3920).

But to make sure, you can start off by opening an issue in https://github.com/platformio/platform-espressif32/issues/, and if the devs won’t find the issue in https://github.com/platformio/platform-espressif32/blob/develop/builder/frameworks/espidf.py, the problem must lie in the ESP-IDF CMake build system files.

Apologies for the delayed response. Your suggestions are very helpful.
I suspect the issue is with ESP-IDF CMake.
I read through https://github.com/platformio/platform-espressif32/blob/develop/builder/frameworks/espidf.py but nothing stands out. Since my project is compiling again, I will move on for now.