PIO stopped working and cannot complie

Hi,

My PIO in Clion worked flawlessly until it started producting the following error:

Build number: 1.3.252 (waiting for upload before next increment)
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/az-delivery-devkit-v4.html
PLATFORM: Espressif 32 (6.4.0+sha.516520f) (git+https://github.com/platformio/platform-espressif32.git#master) > Espressif ESP32 Dev Kit C V4
HARDWARE: ESP32 240MHz, 8MB RAM, 16MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, 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)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.0.0+sha.6f7a1ca (git+https://github.com/espressif/arduino-esp32.git#master) 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-openocd-esp32 @ 2.1100.20220706 (11.0) 
 - toolchain-xtensa-esp32 @ 12.2.0+20230208
KeyError: 'framework-arduinoespressif32-libs':
  File "/opt/homebrew/Cellar/platformio/6.1.11_1/libexec/lib/python3.11/site-packages/platformio/builder/main.py", line 173:
    env.SConscript("$BUILD_SCRIPT")
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/Users/petertomich/.platformio/platforms/espressif32@src-c9ee9fd137fb075309142d83ce51f0bc/builder/main.py", line 346:
    target_elf = env.BuildProgram()
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Util/envs.py", line 242:
    return self.method(*nargs, **kwargs)
  File "/opt/homebrew/Cellar/platformio/6.1.11_1/libexec/lib/python3.11/site-packages/platformio/builder/tools/piobuild.py", line 61:
    env.ProcessProgramDeps()
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Util/envs.py", line 242:
    return self.method(*nargs, **kwargs)
  File "/opt/homebrew/Cellar/platformio/6.1.11_1/libexec/lib/python3.11/site-packages/platformio/builder/tools/piobuild.py", line 121:
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Util/envs.py", line 242:
    return self.method(*nargs, **kwargs)
  File "/opt/homebrew/Cellar/platformio/6.1.11_1/libexec/lib/python3.11/site-packages/platformio/builder/tools/piobuild.py", line 342:
    SConscript(env.GetFrameworkScript(name), exports="env")
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 662:
    return method(*args, **kw)
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/Users/petertomich/.platformio/platforms/espressif32@src-c9ee9fd137fb075309142d83ce51f0bc/builder/frameworks/arduino.py", line 41:
    SConscript(
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 662:
    return method(*args, **kw)
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/Users/petertomich/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/Users/petertomich/.platformio/packages/framework-arduinoespressif32/tools/platformio-build.py", line 40:
    FRAMEWORK_LIBS_DIR = platform.get_package_dir("framework-arduinoespressif32-libs")
  File "/opt/homebrew/Cellar/platformio/6.1.11_1/libexec/lib/python3.11/site-packages/platformio/platform/_packages.py", line 32:
    pkg = self.get_package(name)
  File "/opt/homebrew/Cellar/platformio/6.1.11_1/libexec/lib/python3.11/site-packages/platformio/platform/_packages.py", line 29:
    return self.pm.get_package(spec or self.get_package_spec(name))
  File "/opt/homebrew/Cellar/platformio/6.1.11_1/libexec/lib/python3.11/site-packages/platformio/platform/_packages.py", line 21:
    owner=self.packages[name].get("owner"),

Now what is interesting is that I had it working for a bit but then I discovered that my config had 3 espressif32 frameworks. When I removed all but left the latest release 6.4, the issue came back again. I have cleaned up my python interpreters but the issue seems to be with packaged one. My pio.ini references are as follows:

platform = https://github.com/platformio/platform-espressif32.git#master
platform_packages = platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#master

So currently I am stuck as I cannot even initiate PIO environment without throwing this error.

Many thanks for your prompt help

Pointing to both #master for Platform and Arduino core is an extremely unstable environment. And now it broke.

The Arduino core did some major refactoring in regards to where the precompiled libraries (aka ESP-IDF) comes from and the Arduino-ESP32 builder script references a framework-arduinoespressif32-libs package which does not even exist yet, nor is it referenced as a included package in mainline platform-espressif32.

https://registry.platformio.org/search?q=framework-arduinoespressif32-libs

So, they broke compilation with PlatformIO’s mainline platform-espressif32.

I’d recommend reverting to a stable version. This is as simple as

  1. Set platform = espressif32 in your platformio.ini
  2. Remove all platform_packages instructions in your platformio.ini
  3. Close CLion
  4. Delete all folders /Users/petertomich/.platformio/platforms/espressif32* and /Users/petertomich/.platformio/packages/framework-arduinoespressif32*
  5. Restart CLion and press “Build” once to trigger the redownload (of stable versions).

If you absolutely must have a specific commit of the platform and the Arduino-ESP32 core (that is not a 3.0.0 preview version), you should pin that by commit. Setting it to bleeding-edge master is just asking for trouble.

; example
platform = https://github.com/platformio/platform-espressif32.git#f6ec3926f9f660ee9abada8540ffe1e205da4bbf
platform_packages = 
   platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#44da992b774f76777bb2e931dd76cfcf12b9fe70

Many thanks…it worked. so for my education, can you please explain what platform_packages variable brings to the table considering that it works by setting a platform only?

A given platform version will want to have some version of a package, such as framework-arduinoespressif32 , as dictated by either its platform.json or platform.py code. With a platform_packages directive, it is still possible to overrule that version to be something else.

Many thanks. Really appreciate your prompt help.

There is now a pull request up with a patch to allow setup of frameworkarduinoespressif32-libs, i.e. that will fix the KeyError. Support Arduino ESP32 alpha v3.0.0 based on ESP-IDF v5.1 by sgryphon · Pull Request #1281 · platformio/platform-espressif32 · GitHub

However, there are a bunch of breaking changes in alpha 3.0.0, so your code might not even compile with the new package … but this will at least allow you to get to that step.

Many thanks. Really appreciate your followup.