Using specific version of esp-idf and arduino-esp32 causes in a include error

Hi,

I need to configure my PlatformIO to use the esp-idf version 3.3.5 and arduino-esp32 with the commit ID 4120975 from 27.03.2021, but my configuration isn´t valid.

-- Configuring incomplete, errors occurred!
See also ".pio/build/debug/CMakeFiles/CMakeOutput.log".

CMake Error at CMakeLists.txt:3 (include):
  include could not find load file:

    C:\...\.platformio\packages\framework-espidf/tools/cmake/project.cmake

My configuration looks like this:

[env]
board = esp32dev

platform = espressif32
framework = arduino, espidf

platform_packages =
framework-espidf@https://github.com/espressif/esp-idf.git#03810c4a065a1ecdd24a803b2c9dc4e834c7dab5
framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#4120975

I have checked the framework directory and the directory is empty:

image

Why isn´t PlatformIO downloading the complete repository?

PlatformIO has logic to detect where the package information file (package.json) is located, and assumes everything else in the folder in irrelevant, and only extracts everything from the root point where the package.json is. Hence you see only thus subfolder view.

Sadly per available packages there’s only ESP-IDF 3.3.2 as the closest match, and probably not that commit specific commit for Arduino-ESP32.

So, you’ll need to fork both ESP-IDF and Arduino-ESP32 (best to create a branch based on the original commit you want) and put a package.json file of the needed format in the root folder of each branch. That file can e.g. be derived from the current versions of those, see here and the one in the current esp-idf package version.

Hi @maxgerhardt,

thank you for your explanation. I have downloaded the esp-idf version 3.3.5 from Github and extract it into the folder framework-espidf@3.3.5 in the packages directory of my PlatformIO installation. I also have created a file with the name package.json in the new directory and use the following content:

{
  "name": "framework-espidf",
  "version": "3.3.5",
  "description": "Espressif IoT Development Framework. Official development framework for ESP32 chip",
  "keywords": [
    "framework",
    "esp32",
    "espressif"
  ],
  "homepage": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32/",
  "license": "Apache-2.0",
  "repository": {
    "type": "git",
    "url": "https://github.com/espressif/esp-idf"
  }
}

I have changed the platformio.ini file in the next step (I only replace the espidf to test it):

platform = espressif32
framework = arduino, espidf

platform_packages =
    framework-espidf@3.3.5
    framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#idf-release/v4.0

But I got the following error message:

Tool Manager: Installing platformio/framework-espidf @ 3.3.5
Error: Could not find the package with 'platformio/framework-espidf @ 3.3.5' requirements for your system 'windows_amd64'

I think PlatformIO isn´t using the local version of the changed repository. How can I fix this?

I don’t think PlatformIO can find the package that way – it will still look in the package repository for that version and fail. if you want to reference a local directory, use the file:// pseudo-protocol.

platform_packages =
    framework-espidf@file://C:\Users\user\Desktop\special-espidf\
    framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#idf-release/v4.0

However, the second line would also be invalid, since there is no idf-release/v4.0 branch in the arduino-esp32 repo anymore, see Branches · espressif/arduino-esp32 · GitHub and espidf-arduino-blink example uncompilable because of missing branch · Issue #524 · platformio/platform-espressif32 · GitHub, so you must refer to an existing branch or commit here.

Hi,

okay I have changed the framework to

platform = espressif32
framework = arduino, espidf

platform_packages =
    framework-espidf@file://C:\.platformio\packages\framework-espidf_3.3.5
    framework-arduinoespressif32

and I clean the build environment but PlatformIO outputs an error:

CMake Error at .pio/build/debug/__pio_env/CMakeLists.txt:3 (idf_component_register):
  Unknown CMake command "idf_component_register".
Call Stack (most recent call first):
  C:/.platformio/packages/framework-espidf_3.3.5/tools/cmake/scripts/expand_requirements.cmake:107 (include)
  C:/.platformio/packages/framework-espidf_3.3.5/tools/cmake/scripts/expand_requirements.cmake:217 (expand_component_requirements)

When using platform version currently installed in the system, that is probably very new, it won’t work because it’s expecting an esp-idf version 4 thing. The previous 3.x build system was fundamentally different compared to the one for 4.x where CMake is used directly.

I’m also currently messing around with this and a few platform = espressif32@<version> valies, e.g. 1.11.2 as this was the last version to use an ESP-IDF v3.x version, and see if I get somewhere.

Hi,

I have changed the platform to platform = espressif32@1.11.2 and the error is gone. Now I have some compilation errors. I try to fix them and check if it is working then.

I’ve spent some time on this but this leads down a very deep rabbit hole with include paths not found, and then some KConfig files not being found. My guess is that the builder code (platform-espressif32/espidf.py at v1.11.2 · platformio/platform-espressif32 · GitHub) doesn’t properly know about the components in specifically ESP-IDF v.3.3.5), e.g. nimble which gives a lot of problems. The builder script for ESP-IDF v3.x versions in the platform was always specially tailored to the exact ESP-IDF version used, and this one doesn’t quite seem to work. Starting from when PlatformIO supported ESP-IDF 4.x and calling directly into CMake, this was greatly improved.

I’ve managed to dig down to

[env:esp32dev]
platform = espressif32@1.11.2
#platform = espressif32@1.12.0
board = esp32dev
framework = espidf
platform_packages = 
   framework-espidf@https://github.com/maxgerhardt/esp-idf.git#v3.3.5-pio 
build_flags = 
   -DCONFIG_IDF_FIRMWARE_CHIP_ID=0x0000
   -I$PROJECT_PACKAGES_DIR/framework-espidf/components/lwip/include/apps/sntp/
   -I$PROJECT_PACKAGES_DIR/framework-espidf/components/nimble/nimble/porting/nimble/include/
   -I$PROJECT_PACKAGES_DIR/framework-espidf/components/nimble/nimble/nimble/include/
   -I$PROJECT_PACKAGES_DIR/framework-espidf/components/nimble/port/include/
   -I$PROJECT_PACKAGES_DIR/framework-espidf/components/nimble/nimble/porting/npl/freertos/include/
   -I$PROJECT_PACKAGES_DIR/framework-espidf/components/nimble/nimble/nimble/host/include/
   -I$PROJECT_PACKAGES_DIR/framework-espidf/components/nimble/esp-hci/include/
   -I$PROJECT_PACKAGES_DIR/framework-espidf/components/nimble/nimble/ext/tinycrypt/include/

but this doesn’t seem to be sensible.

I’d actually recommend to use native ESP-IDF tools for this task, not PlatformIO.

On a sidenote, maybe you’re making this way more complicated than it needs to be.

If you do not need a specially configured ESP-IDF version, but rather just the arduino-esp32 version using its normal preconfigured ESP-IDF 3.3.5 base, just as it appears in https://github.com/espressif/arduino-esp32/tree/idf-release/v3.3, you should just do a project with

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
platform_packages =
   framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#idf-release/v3.3

this works without problems for me.

Hi,

yes, I think the solution to the problems are more complicated than I think. I have to discuss it and maybe we can change the version to a version that PlatformIO is supporting. Anyway thank you for the help :slight_smile:

Hello,
I have same issue, I am trying to configure my platform to use the esp-idf version 3.3.5 and arduino-esp32 but unfortunately a can not able to done it.
please help me out with your best suggestions.