Skip to content

Commit 927a718

Browse files
authored
Fix IDF managed component compile
1 parent 66b8969 commit 927a718

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

builder/frameworks/espidf.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,13 @@
4040
DefaultEnvironment,
4141
)
4242

43-
from platformio import fs, __version__
43+
from platformio import fs
4444
from platformio.compat import IS_WINDOWS
4545
from platformio.proc import exec_command
4646
from platformio.builder.tools.piolib import ProjectAsLibBuilder
4747
from platformio.project.config import ProjectConfig
4848
from platformio.package.version import get_original_version, pepver_to_semver
4949

50-
# Added to avoid conflicts between installed Python packages from
51-
# the IDF virtual environment and PlatformIO Core
52-
# Note: This workaround can be safely deleted when PlatformIO 6.1.7 is released
53-
if os.environ.get("PYTHONPATH"):
54-
del os.environ["PYTHONPATH"]
5550

5651
env = DefaultEnvironment()
5752
env.SConscript("_embed_files.py", exports="env")
@@ -1839,12 +1834,21 @@ def get_python_exe():
18391834
LIBSOURCE_DIRS=[os.path.join(ARDUINO_FRAMEWORK_DIR, "libraries")]
18401835
)
18411836

1837+
# Set ESP-IDF version environment variables (needed for proper Kconfig processing)
1838+
framework_version = get_framework_version()
1839+
major_version = framework_version.split('.')[0] + '.' + framework_version.split('.')[1]
1840+
os.environ["ESP_IDF_VERSION"] = major_version
1841+
1842+
# Configure CMake arguments with ESP-IDF version
18421843
extra_cmake_args = [
18431844
"-DIDF_TARGET=" + idf_variant,
18441845
"-DPYTHON_DEPS_CHECKED=1",
18451846
"-DEXTRA_COMPONENT_DIRS:PATH=" + ";".join(extra_components),
18461847
"-DPYTHON=" + get_python_exe(),
18471848
"-DSDKCONFIG=" + SDKCONFIG_PATH,
1849+
f"-DESP_IDF_VERSION={major_version}",
1850+
f"-DESP_IDF_VERSION_MAJOR={framework_version.split('.')[0]}",
1851+
f"-DESP_IDF_VERSION_MINOR={framework_version.split('.')[1]}",
18481852
]
18491853

18501854
# This will add the linker flag for the map file

examples/espidf-blink/platformio.ini

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ framework = espidf
1313
board = esp32dev
1414
monitor_speed = 115200
1515
build_flags =
16-
; https://docs.espressif.com/projects/esp-idf/en/latest/get-started/get-started-wrover-kit.html#rgb-led
1716
-D CONFIG_BLINK_GPIO=2
1817
-D CONFIG_BLINK_LED_GPIO=2
1918
-D CONFIG_BLINK_PERIOD=1000
20-
-D SHOW_METRICS
2119

2220
[env:esp32-c2-devkitm-1]
2321
platform = espressif32
@@ -28,7 +26,6 @@ build_flags =
2826
-D CONFIG_BLINK_GPIO=8
2927
-D CONFIG_BLINK_LED_GPIO=8
3028
-D CONFIG_BLINK_PERIOD=1000
31-
-D SHOW_METRICS
3229

3330
[env:esp32-c6-devkitc-1]
3431
platform = espressif32
@@ -39,4 +36,13 @@ build_flags =
3936
-D CONFIG_BLINK_GPIO=2
4037
-D CONFIG_BLINK_LED_GPIO=2
4138
-D CONFIG_BLINK_PERIOD=1000
42-
-D SHOW_METRICS
39+
40+
[env:esp32-p4]
41+
platform = espressif32
42+
framework = espidf
43+
board = esp32-p4
44+
monitor_speed = 115200
45+
build_flags =
46+
-D CONFIG_BLINK_GPIO=2
47+
-D CONFIG_BLINK_LED_GPIO=2
48+
-D CONFIG_BLINK_PERIOD=1000

0 commit comments

Comments
 (0)