Skip to content

Commit 70e59ca

Browse files
authored
allign with other branches
1 parent a860b09 commit 70e59ca

File tree

1 file changed

+52
-14
lines changed

1 file changed

+52
-14
lines changed

builder/frameworks/espidf.py

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ def _get_installed_standard_pip_packages():
115115

116116
install_standard_python_deps()
117117

118-
# Allow changes in folders of managed components
119-
os.environ["IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS"] = "1"
120-
121118
platform = env.PioPlatform()
122119
config = env.GetProjectConfig()
123120
board = env.BoardConfig()
@@ -130,6 +127,9 @@ def _get_installed_standard_pip_packages():
130127
flag_custom_component_add = False
131128
flag_custom_component_remove = False
132129

130+
# Allow changes in folders of managed components
131+
os.environ["IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS"] = "1"
132+
133133
IDF5 = (
134134
platform.get_package_version("framework-espidf")
135135
.split(".")[1]
@@ -540,6 +540,8 @@ def populate_idf_env_vars(idf_env):
540540
if "IDF_TOOLS_PATH" in idf_env:
541541
del idf_env["IDF_TOOLS_PATH"]
542542

543+
# idf_env["ESP_ROM_ELF_DIR"] = platform.get_package_dir("tool-esp-rom-elfs")
544+
543545

544546
def get_target_config(project_configs, target_index, cmake_api_reply_dir):
545547
target_json = project_configs.get("targets")[target_index].get("jsonFile", "")
@@ -1535,11 +1537,10 @@ def _get_installed_pip_packages(python_exe_path):
15351537
# https://github.com/platformio/platformio-core/issues/4614
15361538
"urllib3": "<2",
15371539
# https://github.com/platformio/platform-espressif32/issues/635
1538-
"cryptography": "~=41.0.1",
1539-
"future": ">=0.18.3",
1540+
"cryptography": "~=44.0.0",
15401541
"pyparsing": ">=3.1.0,<4",
15411542
"idf-component-manager": "~=2.0.1",
1542-
"esp-idf-kconfig": ">=2.5.0"
1543+
"esp-idf-kconfig": "~=2.5.0"
15431544
}
15441545

15451546
if sys_platform.system() == "Darwin" and "arm" in sys_platform.machine().lower():
@@ -1589,11 +1590,37 @@ def get_idf_venv_dir():
15891590

15901591
def ensure_python_venv_available():
15911592

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+
15921607
def _is_venv_outdated(venv_data_file):
15931608
try:
15941609
with open(venv_data_file, "r", encoding="utf8") as fp:
15951610
venv_data = json.load(fp)
15961611
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+
)
15971624
return True
15981625
return False
15991626
except:
@@ -1608,7 +1635,7 @@ def _create_venv(venv_dir):
16081635

16091636
if os.path.isdir(venv_dir):
16101637
try:
1611-
print("Removing an oudated IDF virtual environment")
1638+
print("Removing an outdated IDF virtual environment")
16121639
shutil.rmtree(venv_dir)
16131640
except OSError:
16141641
print(
@@ -1633,8 +1660,12 @@ def _create_venv(venv_dir):
16331660
venv_data_file = os.path.join(venv_dir, "pio-idf-venv.json")
16341661
if not os.path.isfile(venv_data_file) or _is_venv_outdated(venv_data_file):
16351662
_create_venv(venv_dir)
1663+
install_python_deps()
16361664
with open(venv_data_file, "w", encoding="utf8") as fp:
1637-
venv_info = {"version": IDF_ENV_VERSION}
1665+
venv_info = {
1666+
"version": IDF_ENV_VERSION,
1667+
"python_version": _get_idf_venv_python_version()
1668+
}
16381669
json.dump(venv_info, fp, indent=2)
16391670

16401671

@@ -1653,11 +1684,10 @@ def get_python_exe():
16531684

16541685

16551686
#
1656-
# ESP-IDF requires Python packages with specific versions in a virtual environment
1687+
# Ensure Python environment contains everything required for IDF
16571688
#
16581689

16591690
ensure_python_venv_available()
1660-
install_python_deps()
16611691

16621692
# ESP-IDF package doesn't contain .git folder, instead package version is specified
16631693
# in a special file "version.h" in the root folder of the package
@@ -1863,7 +1893,15 @@ def get_python_exe():
18631893
# Extra flags which need to be explicitly specified in LINKFLAGS section because SCons
18641894
# cannot merge them correctly
18651895
extra_flags = filter_args(
1866-
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+
],
18671905
)
18681906
link_args["LINKFLAGS"] = sorted(list(set(link_args["LINKFLAGS"]) - set(extra_flags)))
18691907

@@ -1940,7 +1978,7 @@ def _skip_prj_source_files(node):
19401978
(
19411979
board.get(
19421980
"upload.bootloader_offset",
1943-
"0x1000" if mcu in ["esp32", "esp32s2"] else ("0x2000" if mcu in ["esp32p4"] else "0x0"),
1981+
"0x1000" if mcu in ["esp32", "esp32s2"] else ("0x2000" if mcu in ["esp32c5", "esp32p4"] else "0x0"),
19441982
),
19451983
os.path.join("$BUILD_DIR", "bootloader.bin"),
19461984
),
@@ -2125,7 +2163,7 @@ def idf_lib_copy(source, target, env):
21252163
print("*** Original Arduino \"idf_component.yml\" couldnt be restored ***")
21262164
env.AddPostAction("checkprogsize", idf_lib_copy)
21272165

2128-
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):
21292167
def idf_custom_component(source, target, env):
21302168
try:
21312169
shutil.copy(join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml.orig"),join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml"))
@@ -2195,7 +2233,7 @@ def _parse_size(value):
21952233
partitions_csv = env.subst("$PARTITIONS_TABLE_CSV")
21962234
result = []
21972235
next_offset = 0
2198-
bound = int(board.get("upload.offset_address", "0x10000"), 16) # default 0x10000
2236+
bound = 0x10000
21992237
with open(partitions_csv) as fp:
22002238
for line in fp.readlines():
22012239
line = line.strip()

0 commit comments

Comments
 (0)