esp32/Makefile: Add support for EIM environments. by agatti · Pull Request #19657 · micropython/micropython · GitHub
Skip to content

esp32/Makefile: Add support for EIM environments. - #19657

Open
agatti wants to merge 2 commits into
micropython:masterfrom
agatti:esp32-eim
Open

agatti wants to merge 2 commits into
micropython:masterfrom
agatti:esp32-eim

Conversation

@agatti

@agatti agatti commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR lets the ESP32 port makefile work in environments set up via EIM (Espressif's SDK/toolchain manager) instead of the regular SDK export script.

EIM-activated environment do not place idf.py into the system's PATH, so the Makefile needs to know where to look for it if it cannot be found right away. However, EIM does set up an environment variable that points to the environment root, and therefore picking up idf.py from there is trivial. As a bonus, if the makefile cannot find idf.py, it will report a more sensible error to the user rather than a generic "file not found" message.

The documentation was also updated to mention EIM and the current state of things when using such a tool to manage your ESP-IDF SDKs.

This should close #19390.

Testing

An ESP32 build was initiated successfully with the environment set up by export.fish from a previously set up SDK using the regular git checkout + install.sh method, then from an environment activated via EIM, and finally with no environment set up to see the new error message.

Trade-offs and Alternatives

Currently there is a known issue with EIM preventing building mpy-cross from the same environment it sets up for cross-compilation builds (see espressif/idf-im-ui#1067). However, this PR contains a workaround for this situation.

Generative AI

I did not use generative AI tools when creating this PR.

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

@agatti

agatti commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

The issue with locally-built tools under EIM may have been found, see espressif/idf-im-ui#1067 (comment)

It'd be great if somebody could try this out on macOS after editing the PATH variable to remove the directories mentioned in the comment linked above, as EIM also installs its own version of clang. So I can at least update the documentation mentioning whether EIM can be used to build MicroPython on macOS :)

@agatti
agatti force-pushed the esp32-eim branch 2 times, most recently from 9c3bf6d to d34951a Compare August 31, 2026 11:07
@agatti

agatti commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

I've been told EIM does take over a default LLVM installation to use its own, but that's a Xtensa + RV32 cross compiler only.

So, unless Espressif updates its clang version to also target x86_64 and AArch64, this method is not usable on macOS or on systems where there's no GCC installed (*BSDs, maybe?).

@agatti

agatti commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Thinking a bit more about this, there may be a "cleaner" solution if Espressif can't (or won't) fix things on their end.

If $IDF_TOOLS_PATH is not set, congratulations, things will work as before. Otherwise:

  • Make a copy of $PATH
  • Strip away all entries that start with the value of $IDF_TOOLS_PATH
  • Export the stripped version of $PATH
  • Force a build of mpy-tool
  • Export the original $PATH
  • Build the firmware

then, in theory this should work for Linux, WSL, and macOS.

@agatti

agatti commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

This should make it work under Linux, both using GCC and LLVM to build mpy-cross from an EIM environment. I assume this should also work on WSL, but it is not tested on macOS.

No idea about building this from Windows outside WSL, but hey, maybe they broke that too...

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.59%. Comparing base (8cb7558) to head (f5fa28b).
⚠️ Report is 34 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19657   +/-   ##
=======================================
  Coverage   98.59%   98.59%           
=======================================
  Files         182      182           
  Lines       23335    23335           
  Branches        5        5           
=======================================
  Hits        23006    23006           
  Misses        328      328           
  Partials        1        1           
Flag Coverage Δ
unix-coverage-32bit 98.59% <ø> (ø)
unix-coverage-64bit 98.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@agatti
agatti force-pushed the esp32-eim branch 2 times, most recently from 8df81d6 to c846a59 Compare September 1, 2026 04:42
@projectgus
projectgus self-requested a review September 3, 2026 05:01
This commit lets the ESP32 port makefile work in environments set up via
EIM (Espressif's SDK/toolchain manager) instead of the regular SDK
export script.

EIM-activated environment do not place `idf.py` into the system's PATH,
so the Makefile needs to know where to look for it if it cannot be found
right away.  However, EIM does set up an environment variable that
points to the environment root, and therefore picking up idf.py from
there is trivial.  As a bonus, if the makefile cannot find idf.py, it
will report a more sensible error to the user rather than a generic
"file not found" message.

The documentation was also updated to mention EIM and the current state
of things when using such a tool to manage your ESP-IDF SDKs.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit updates the build infrastructure to undo the local compiler
takeover done by Espressif's EIM tool, allowing the ESP32 port to build
correctly from an EIM-activated environment.

EIM would blindly edit the PATH environment variable to replace any
local LLVM installation with its own bare-metal version, and add all
directories named `bin` from their tools directory.  Three of those
directories have files whose name clashes with local GCC installations.

As we may build `mpy-cross` for the host system as part of the build
process of the ESP32 port, that's unfortunately a workaround we have to
add ourselves.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
@octoprobe-bot

Copy link
Copy Markdown

Octoprobe PR report

Test Tests
passed
Tests
skipped
Tests
xfailed
Tests
failed
format flash 4
run-tests.py 3852 352
run-tests.py --via-mpy --emit native 3812 392
run-tests.py --via-mpy 3855 349
run-perfbench.py 96
run-natmodtests.py 142 22
run-mpremote-tests.sh 42 3 9
run-tests.py --test-dirs=extmod_hardware 54 51 15
run-tests.py --test-dirs=extmod_hardware --emit-native 54 51 15
Total 11907 1224 30 9
Failures

Group: run-mpremote-tests.sh

Test esp32
5c34-
ESP32_C3_DEVKIT
esp32
5d21-
ESP32_DEVKIT
esp32
472b-
ESP32_S3_DEVKIT
esp32
1830-
LOLIN_C3_MINI
test_filesystem.sh pass pass FAIL FAIL FAIL pass
test_eval_exec_run.sh pass pass FAIL FAIL FAIL pass
test_mount.sh pass pass FAIL FAIL FAIL pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make error with idf install from eim

2 participants