Huh, I was just about to write how PlatformIO in general has this capability of using an ESP-IDF base project and adding Arduino-ESP32 on top of it as a (ESP-IDF) component, but that this isn’t working at the moment because of non updated packages (Support for IDF 4.4 release · Issue #710 · platformio/platform-espressif32 · GitHub), but just 17 hours ago that was actually fixed, looking at platform-espressif32/examples/espidf-arduino-blink at develop · platformio/platform-espressif32 · GitHub.
With this fixed you can use the standard ESP-IDF 4.4.1 package and the Arduino-ESP32 package to truly build the firmware from the ground up.
Can you download the above repository but use as the platformio.ini
[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git
framework = arduino, espidf
board = esp32dev
build_flags =
-D CONFIG_BLINK_GPIO=2
monitor_speed = 115200
(this needs the bleeding-edge version of platform-espressif32 to work).
Once you can build it with the default packages, you can again use platform_packages to change framework-arduinoespressif32 and framework-espidf at will, while adding any components you like.
Well technically GitHub - espressif/esp-rainmaker: ESP RainMaker Agent for firmware development isn’t ESP-IDF, it’s a component for ESP-IDF, so you would add that into the components folder of the PlatformIO project like the example would and reference it in the CMakeLists.txt.
Another note would that, when you want to modify Arduino-ESP32 with changed ESP-IDF settings without building ESP-IDF on every build, you have to use GitHub - espressif/esp32-arduino-lib-builder to regenerate those static libraries that Arduino-ESP32 is using. When using the framework = arduino, espidf combination, those libraries are ignored.