PlatformIO Community

Compile error KeyError : 'toolchain-xtensa32'

I try to build example code and getting still the same error. I tried to reinstall VS Code and PlatformIO as well. 2 months ago everything worked!

platformio.ini:

[env]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200

extra_scripts = 
	pre:/$PROJECT_LIBDEPS_DIR/$PIOENV/ulptool-pio/pre_extra_script_ulptool.py
	post:/$PROJECT_LIBDEPS_DIR/$PIOENV/ulptool-pio/post_extra_script_ulptool.py

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
lib_deps = 
	dawidchyrzynski/home-assistant-integration@^1.3.0
	likeablob/ulptool-pio@^0.1.0

Build:

> Executing task in folder ulp-counter: platformio run --environment esp32dev <

Processing esp32dev (board: esp32dev; platform: espressif32; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (4.4.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, 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.20003.0 (2.0.3) 
 - tool-esptoolpy @ 1.30300.0 (3.3.0) 
 - toolchain-esp32ulp @ 1.22851.191205 (2.28.51) 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ulptool-pio @ 0.1.0+sha.7c5dd85
Building in release mode
cb([".pio/build/esp32dev/firmware.elf"], [".pio/build/esp32dev/src/ulp_counter.cpp.o"])
Running ulptool
*** [.pio/build/esp32dev/firmware.elf] KeyError : 'toolchain-xtensa32'
Traceback (most recent call last):
  File "/home/pavel/.platformio/packages/tool-scons/scons-local-4.3.0/SCons/Action.py", line 1279, in execute
    result = self.execfunction(target=target, source=rsources, env=env)
  File "/home/pavel/Dokumenty/PlatformIO/Projects/ulp-counter/.pio/libdeps/esp32dev/ulptool-pio/post_extra_script_ulptool.py", line 59, in cb
    run_ulptool()
  File "/home/pavel/Dokumenty/PlatformIO/Projects/ulp-counter/.pio/libdeps/esp32dev/ulptool-pio/post_extra_script_ulptool.py", line 24, in run_ulptool
    toolchain_xtensa_dir = platform.get_package_dir("toolchain-xtensa32")
  File "/home/pavel/.platformio/penv/lib/python3.8/site-packages/platformio/platform/_packages.py", line 32, in get_package_dir
    pkg = self.get_package(name)
  File "/home/pavel/.platformio/penv/lib/python3.8/site-packages/platformio/platform/_packages.py", line 29, in get_package
    return self.pm.get_package(spec or self.get_package_spec(name))
  File "/home/pavel/.platformio/penv/lib/python3.8/site-packages/platformio/platform/_packages.py", line 21, in get_package_spec
    owner=self.packages[name].get("owner"),
KeyError: 'toolchain-xtensa32'
=========================================================== [FAILED] Took 1.63 seconds ======

Can you try and remove all folders within /home/pavel/.platformio/packages and build the project again to get a clean redownload?

It looks like the platform’s manifest is broken. Please remove the .platformio/platforms folder and build the project again.

I removed all content from:
.platformio/packages
.platformio/platforms

Then tried to rebuild 2 different projects - same error appeared.

Set platform = espressif32@3.5.0 in the platformio.ini's [env] section. Does it change anything?

Thank you very much. It works!

Well wait- that’s a bad sign for the current platform.

When you set platform = espressif32@4.3.0, does it still work? Only with @4.4.0 not?

Do you remove the .pio folder of the project every time to get a clean rebuild?

Oh actually that is okay. Looking at the backtraces

The call toolchain_xtensa_dir = platform.get_package_dir("toolchain-xtensa32") is in the ULP script, that extra component you added. So that is not yet compatible with the most recent version. I think the toolchain is called toolchain-xtensa32-esp32 now.

But then it’s probably okay that you stay at 3.5.0 with that particular project, upgrading the ESP-IDF version may not be compatinble with your project, and the ULP project definitely at least needs that fix.

Problem is already known at the source.

Yes, I do clean rebuild.
platform = espressif32@4.3.0 does not work.

This is my ticket is no reply and I need at least some workaround - so i created this topic.