@@ -115,9 +115,6 @@ def _get_installed_standard_pip_packages():
115115
116116install_standard_python_deps ()
117117
118- # Allow changes in folders of managed components
119- os .environ ["IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS" ] = "1"
120-
121118platform = env .PioPlatform ()
122119config = env .GetProjectConfig ()
123120board = env .BoardConfig ()
@@ -130,6 +127,9 @@ def _get_installed_standard_pip_packages():
130127flag_custom_component_add = False
131128flag_custom_component_remove = False
132129
130+ # Allow changes in folders of managed components
131+ os .environ ["IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS" ] = "1"
132+
133133IDF5 = (
134134 platform .get_package_version ("framework-espidf" )
135135 .split ("." )[1 ]
@@ -1537,11 +1537,10 @@ def _get_installed_pip_packages(python_exe_path):
15371537 # https://github.com/platformio/platformio-core/issues/4614
15381538 "urllib3" : "<2" ,
15391539 # https://github.com/platformio/platform-espressif32/issues/635
1540- "cryptography" : "~=41.0.1" ,
1541- "future" : ">=0.18.3" ,
1540+ "cryptography" : "~=44.0.0" ,
15421541 "pyparsing" : ">=3.1.0,<4" ,
15431542 "idf-component-manager" : "~=2.0.1" ,
1544- "esp-idf-kconfig" : "> =2.5.0"
1543+ "esp-idf-kconfig" : "~ =2.5.0"
15451544 }
15461545
15471546 if sys_platform .system () == "Darwin" and "arm" in sys_platform .machine ().lower ():
@@ -1591,11 +1590,37 @@ def get_idf_venv_dir():
15911590
15921591def ensure_python_venv_available ():
15931592
1593+ def _get_idf_venv_python_version ():
1594+ try :
1595+ version = subprocess .check_output (
1596+ [
1597+ get_python_exe (),
1598+ "-c" ,
1599+ "import sys;print('{0}.{1}.{2}-{3}.{4}'.format(*list(sys.version_info)))"
1600+ ], text = True
1601+ )
1602+ return version .strip ()
1603+ except subprocess .CalledProcessError as e :
1604+ print ("Failed to extract Python version from IDF virtual env!" )
1605+ return None
1606+
15941607 def _is_venv_outdated (venv_data_file ):
15951608 try :
15961609 with open (venv_data_file , "r" , encoding = "utf8" ) as fp :
15971610 venv_data = json .load (fp )
15981611 if venv_data .get ("version" , "" ) != IDF_ENV_VERSION :
1612+ print (
1613+ "Warning! IDF virtual environment version changed!"
1614+ )
1615+ return True
1616+ if (
1617+ venv_data .get ("python_version" , "" )
1618+ != _get_idf_venv_python_version ()
1619+ ):
1620+ print (
1621+ "Warning! Python version in the IDF virtual environment"
1622+ " differs from the current Python!"
1623+ )
15991624 return True
16001625 return False
16011626 except :
@@ -1610,7 +1635,7 @@ def _create_venv(venv_dir):
16101635
16111636 if os .path .isdir (venv_dir ):
16121637 try :
1613- print ("Removing an oudated IDF virtual environment" )
1638+ print ("Removing an outdated IDF virtual environment" )
16141639 shutil .rmtree (venv_dir )
16151640 except OSError :
16161641 print (
@@ -1635,8 +1660,12 @@ def _create_venv(venv_dir):
16351660 venv_data_file = os .path .join (venv_dir , "pio-idf-venv.json" )
16361661 if not os .path .isfile (venv_data_file ) or _is_venv_outdated (venv_data_file ):
16371662 _create_venv (venv_dir )
1663+ install_python_deps ()
16381664 with open (venv_data_file , "w" , encoding = "utf8" ) as fp :
1639- venv_info = {"version" : IDF_ENV_VERSION }
1665+ venv_info = {
1666+ "version" : IDF_ENV_VERSION ,
1667+ "python_version" : _get_idf_venv_python_version ()
1668+ }
16401669 json .dump (venv_info , fp , indent = 2 )
16411670
16421671
@@ -1655,11 +1684,10 @@ def get_python_exe():
16551684
16561685
16571686#
1658- # ESP-IDF requires Python packages with specific versions in a virtual environment
1687+ # Ensure Python environment contains everything required for IDF
16591688#
16601689
16611690ensure_python_venv_available ()
1662- install_python_deps ()
16631691
16641692# ESP-IDF package doesn't contain .git folder, instead package version is specified
16651693# in a special file "version.h" in the root folder of the package
@@ -1865,7 +1893,15 @@ def get_python_exe():
18651893# Extra flags which need to be explicitly specified in LINKFLAGS section because SCons
18661894# cannot merge them correctly
18671895extra_flags = filter_args (
1868- link_args ["LINKFLAGS" ], ["-T" , "-u" , "-Wl,--start-group" , "-Wl,--end-group" ]
1896+ link_args ["LINKFLAGS" ],
1897+ [
1898+ "-T" ,
1899+ "-u" ,
1900+ "-Wl,--start-group" ,
1901+ "-Wl,--end-group" ,
1902+ "-Wl,--whole-archive" ,
1903+ "-Wl,--no-whole-archive" ,
1904+ ],
18691905)
18701906link_args ["LINKFLAGS" ] = sorted (list (set (link_args ["LINKFLAGS" ]) - set (extra_flags )))
18711907
@@ -1942,7 +1978,7 @@ def _skip_prj_source_files(node):
19421978 (
19431979 board .get (
19441980 "upload.bootloader_offset" ,
1945- "0x1000" if mcu in ["esp32" , "esp32s2" ] else ("0x2000" if mcu in ["esp32p4" , "esp32c5 " ] else "0x0" ),
1981+ "0x1000" if mcu in ["esp32" , "esp32s2" ] else ("0x2000" if mcu in ["esp32c5" , "esp32p4 " ] else "0x0" ),
19461982 ),
19471983 os .path .join ("$BUILD_DIR" , "bootloader.bin" ),
19481984 ),
@@ -2127,7 +2163,7 @@ def idf_lib_copy(source, target, env):
21272163 print ("*** Original Arduino \" idf_component.yml\" couldnt be restored ***" )
21282164 env .AddPostAction ("checkprogsize" , idf_lib_copy )
21292165
2130- if "espidf" in env .subst ( "$ PIOFRAMEWORK" ) and (flag_custom_component_add == True or flag_custom_component_remove == True ):
2166+ if "espidf" in env .get ( " PIOFRAMEWORK" ) and (flag_custom_component_add == True or flag_custom_component_remove == True ):
21312167 def idf_custom_component (source , target , env ):
21322168 try :
21332169 shutil .copy (join (ARDUINO_FRAMEWORK_DIR ,"idf_component.yml.orig" ),join (ARDUINO_FRAMEWORK_DIR ,"idf_component.yml" ))
@@ -2197,7 +2233,7 @@ def _parse_size(value):
21972233partitions_csv = env .subst ("$PARTITIONS_TABLE_CSV" )
21982234result = []
21992235next_offset = 0
2200- bound = int ( board . get ( "upload.offset_address" , "0x10000" ), 16 ) # default 0x10000
2236+ bound = 0x10000
22012237with open (partitions_csv ) as fp :
22022238 for line in fp .readlines ():
22032239 line = line .strip ()
0 commit comments