ESP32 HybridCompile: separate checkouts sharing ~/.platformio link each other's IDF libs

Open
#12,502 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp

Research direction

Start by reading extra_scripts/esp32_pre.py, especially drop_stale_sdkconfig_defaults(), and trace where the IDF library cache key and sdkconfig.defaults marker are created. Reproduce the shared PlatformIO core scenario with the two environments named in the issue. Done means each project detects when the shared libraries were built for a different configuration and recompiles them; verify the resulting firmware contains the expected PSRAM mode.

Written by the indexing model from the issue text.

Description

Summary

ESP32 envs with custom_sdkconfig compile the Arduino IDF libs into the global ~/.platformio/packages/framework-arduinoespressif32-libs/<mcu>/. Whether to recompile them is decided by a hash stored in the project-local sdkconfig.defaults (line 1, # TASMOTA__<hash>). When two project directories share one PlatformIO core dir (git worktrees, multiple clones, a persistent CI cache), a build in one directory rewrites the global libs, but the other directory's marker still matches. That directory's next build reuses the libs, which are now configured for another board.

The image builds without error and does not boot. In the case below a quad-PSRAM board linked octal-PSRAM libs and boot-looped:

E (415) octal_psram: PSRAM chip is not connected, or wrong PSRAM line mode
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

The backtrace ends in psramInit() → esp_timer_impl_get_time().

Reproduce

  1. Directory A: pio run -e t-deck-pro (quad PSRAM). It boots.
  2. Directory B, sharing ~/.platformio: pio run -e t5s3_epaper_inkhud (octal PSRAM). This recompiles the global libs for octal.
  3. Directory A: rebuild t-deck-pro after any source change. No IDF-libs recompile happens. The image contains octal_psram and not quad_psram (strings firmware.bin | grep -c octal_psram), and it boot-loops.

Deleting .pio/build/t-deck-pro does not help. Deleting A's sdkconfig.defaults does.

Cause

#11112 added the PSRAM fingerprint to the hash, and #11834 drops sdkconfig.defaults when the libs are older than it (an interrupted compile). Both compare against a marker held in one project, while the libs they guard are shared. drop_stale_sdkconfig_defaults() in extra_scripts/esp32_pre.py returns early when libs/<chip_variant>/sdkconfig is at least as new as sdkconfig.defaults, which is exactly the case when another project recompiled the libs.

Possible fix

Record what the libs were built for alongside the libs: after a completed compile, write the cache-key hash next to libs/<chip_variant>/sdkconfig. Then compare that hash, not timestamps, with the project's sdkconfig.defaults, and drop the marker on any mismatch. That covers both directions: an aborted compile (#11834) and a compile by another project.

Workaround

Delete the project's sdkconfig.defaults before building after any other ESP32 build that used a different PSRAM configuration in another directory. Before flashing, confirm the image has the expected quad_psram or octal_psram string.

Platform: pioarduino espressif32 55.3.311 (meshtastic fork).

Dominant language
C++
Stars
8.4k
Forks
2.8k
Avg merge
3d 14h
Merged PRs (30d)
119

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from meshtastic/firmware

All issues in meshtastic/firmware

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.