ESP32 (framework-espidf 4.2.1) - linker script generation failed


I’m unable to build a simple blink example using the latest ESP32-IDF version. I get the same errors with the development version of platform =

Any suggestions as how to fix it? Thanks.

PlatformIO Core: 5.1.1
Platform IDE 2.3.2
macOS: 11.4 and 10.14.6

Package framework-espidf
Type: framework
Requirements: ~3.40201.0
Installed: Yes
Version: 3.40201.210513
Original version: 4.2.1
Description: Espressif IoT Development Framework. Official development framework for ESP32 chip


Processing esp32dev (platform: espressif32; board: esp32dev; framework: espidf)
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (3.2.1+sha.4cb0633) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: 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)
 - framework-espidf 3.40201.210513 (4.2.1) 
 - tool-cmake 3.16.4 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - tool-ninja 1.9.0 
 - toolchain-esp32ulp 1.22851.191205 (2.28.51) 
 - toolchain-xtensa32 2.80400.210211 (8.4.0)
Reading CMake configuration...
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/esp32dev/src/main.o
Compiling .pio/build/esp32dev/bootloader/bootloader_support/src/bootloader_common.o
Archiving .pio/build/esp32dev/bootloader/esp-idf/spi_flash/libspi_flash.a
Indexing .pio/build/esp32dev/bootloader/esp-idf/spi_flash/libspi_flash.a
linker script generation failed for /<user>/.platformio/packages/framework-espidf/components/esp32/ld/
ERROR: failed to parse /<user>/.platformio/packages/framework-espidf/components/esp_event/linker.lf
Expected end of text, found 'i'  (at char 0), (line:1, col:1)
Compiling .pio/build/esp32dev/bootloader/bootloader_support/src/bootloader_flash.o
*** [.pio/build/esp32dev/esp32.project.ld] Error 1
================================================ [FAILED] Took 15.01 seconds ================================================
The terminal process "platformio 'run'" terminated with exit code: 1.

ESP-IDF has a couple of quirks. First, it does not like it when the path to the project contains spaces, or a folder in the chain above it is a git repo. But one of thing at a time. Try to get a fresh ESP-IDF installation first by removing the /<user>/.platformio/packages/framework-espidf/ folder and retry.

Thanks. The ESP32 framework-arduinoespressif32 build work fine and I had not built a framework-espidf build for quite some time.

Anyway, I did a fresh re-install of ESP-IDF after removing the ESP-IDF specific folders from .platformio/packages/ . I get the same error as before.

linker script generation failed for /Users/quark11/.platformio/packages/framework-espidf/components/esp32/ld/
ERROR: failed to parse /Users/quark11/.platformio/packages/framework-espidf/components/esp_event/linker.lf
Expected end of text, found 'i'  (at char 0), (line:1, col:1)
*** [.pio/build/esp32dev/esp32.project.ld] Error 1

On another macOS that has never had PlatformIO, I installed PlatformIO and ESP-IDF. The same ESP-IDF blink example built fine. So, there must be some other environment related conflict (Python?) that may be causing the build failure on my development Mac.

It’s odd that the ESP32 framework-arduinoespressif32 build works fine but not the framework-espidf builds.

Any suggestions what I should check next?

There is an interesting thread at Linker Error: failed to parse ESP-IDF/components/esp_event/linker.lf (VSC-237) · Issue #32 · espressif/vscode-esp-idf-extension · GitHub for this.

First, try to remove the .pio (hidden) folder of the project and rebuild to get a clean build.

If that does not help one can try the suggestions in the comment below that. Execute, in a CLI, the command pio system info to find out what your Python Executable path is. (e.g., c:\users\max\appdata\local\programs\python\python38\python.exe for me).

Then use that path and execute the two commands

<python path here> -m pip uninstall pyparsing
<python path here> -m pip install pyparsing==2.2.0

and try cleaning & rebuilding the project.

If that does still now work try

pip uninstall pyparsing
pip install pyparsing==2.2.0

in your normal system’s shell (the comment hints at an incompatibility between those enviornments)

1 Like

Thanks again.
I did review the same thread yesterday but the removing the .pio (hidden) folder of the project and rebuilding it didn’t work.

I’ll try the other suggestions.


  1. Used pio system info to check Python Executable path used by PlatformIO,

    Python Executable /Users/quark11/.platformio/penv/bin/python

  2. Changed to above Python Executable path and ran

    python -m pip uninstall pyparsing

    Found existing installation: pyparsing 2.4.7

  3. I uninstalled pyparsing 2.4.7 & installed pyparsing==2.2.0, then performed a clean rebuild of the project.

All seems to be fine now. Thank you.

Glad that it worked out. I investigated some further and opened issue ESP-IDF compilation fails on Mac due to pyparsing version · Issue #561 · platformio/platform-espressif32 · GitHub for this, since this shouldn’t be happening in the first place.

Thank you for the follow up and opening the issue with the platform-espressif32 dev team.

Under macOS 10.14.6 (Mojave), I noticed that with framework-espidf 4.3, the same ESP32 build broke again.

I had to repeat the above procedure again, i.e. uninstall pyparsing & install pyparsing==2.2.0.

With the framework-espidf 4.3 under macOS 11.5.1 (Big Sur) and macOS 10.13.6 (High Sierra) & pyparsing 2.3.1, the ESP32 builds were fine.

Both macOS 11.5.1 and macOS 10.13.6 have python 3.9, whereas macOS 10.14.6 has python 3.8. On the latter, I’ll check to see if I can run the later version of pyparsing by upgrading to python 3.9.

Upgraded macOS 10.14.6 to the latest Python 3.9.6 and pyparsing 2.4.7. Build with framework-espidf 4.3 worked fine.

Question: How do I upgrade PlatformIO Python environment in .platformio/penv/bin to Python 3.9?

What does pio system info's “Python Executable” path return? What happens when you execute that executable with --version? You can try and replace the executables at that path, I don’t know of any other method to change PlatformIO’s python version, since it’s managed by itself in that isolated pyenv.

Thanks maxgehardt.

PIO was using the local Python 3.8.x in .platformio/penv/bin. After replacing the folder .platform/penv from another macOS that had PIO local Python 3.9.x, relaunch of PIO forced it to re-install PlatformOI IDE core.

pio system info now displays Python 3.9.2-final.0, like the PlatformIO on two of the other Macs. All works fine.

1 Like

I have this very issue, and by forcing pyparsing = 2.2.0 the problem is fixed, but right now i do by an horrible hack as pio run will try to update the library to the cached 3.4.0 every time!
i tried to override this behavior adding
platform_packages = pyparsing 2.2.0
to but this does not seems to be correct as it say pyparsing is not found.

Any help?

Specifying python packages like that cannot be done. The builder script determines what packages it installs. I was under the impression that installing the correct version once is sufficient. If it tries to reinstall it, it will source the version from C:\Users\<user>\.platformio\platforms\espressif32\builder\ Edit these lines of the file

Change the version string for pyparsing to e.g. ==2.2.0.

1 Like