Skip to content

Commit b60bfc8

Browse files
authored
refactor toolchain enable
1 parent a0064d3 commit b60bfc8

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

platform.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
sys.stderr.write("Error: Couldn't execute 'idf_tools.py install'\n")
5050
else:
5151
shutil.copytree(join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-packages"), join(IDF_TOOLS_PATH_DEFAULT, "tools"), symlinks=False, ignore=None, ignore_dangling_symlinks=False, dirs_exist_ok=True)
52-
for p in ("tool-mklittlefs", "tool-mkfatfs", "tool-mkspiffs", "tool-dfuutil", "tool-openocd", "tool-cmake", "tool-ninja", "tool-cppcheck", "tool-clangtidy", "tool-pvs-studio", "tc-xt-esp32", "tc-xt-esp32s2", "tc-xt-esp32s3", "tc-ulp", "tc-rv32", "tl-xt-gdb", "tl-rv-gdb", "contrib-piohome", "contrib-pioremote"):
52+
for p in ("tool-mklittlefs", "tool-mkfatfs", "tool-mkspiffs", "tool-dfuutil", "tool-openocd", "tool-cmake", "tool-ninja", "tool-cppcheck", "tool-clangtidy", "tool-pvs-studio", "tc-xt-esp32", "tc-xt-esp32s2", "tc-xt-esp32s3", "tc-ulp", "tc-rv32", "tl-xt-gdb", "tl-rv-gdb", "contrib-piohome", "contrib-pioremote"):
5353
tl_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", p)
5454
pm.install(tl_path)
5555

@@ -72,8 +72,10 @@ def configure_default_packages(self, variables, targets):
7272
self.packages["riscv32-esp-elf-gdb"]["optional"] = True
7373
self.packages["xtensa-esp-elf-gdb"]["optional"] = True
7474

75-
# Enable check tools only when "check_tool" is enabled
7675
if tl_flag:
76+
# Install tool is not needed anymore
77+
del self.packages["tl-install"]
78+
# Enable check tools only when "check_tool" is enabled
7779
for p in self.packages:
7880
if p in ("tool-cppcheck", "tool-clangtidy", "tool-pvs-studio"):
7981
self.packages[p]["optional"] = False if str(variables.get("check_tool")).strip("['']") in p else True
@@ -82,6 +84,12 @@ def configure_default_packages(self, variables, targets):
8284
self.packages["framework-arduinoespressif32"]["optional"] = False
8385
self.packages["framework-arduinoespressif32-libs"]["optional"] = False
8486

87+
# packages for IDF and mixed Arduino+IDF projects
88+
if tl_flag and "espidf" in frameworks:
89+
for p in self.packages:
90+
if p in ("tool-scons", "tool-cmake", "tool-ninja"):
91+
self.packages[p]["optional"] = False
92+
8593
if "".join(targets) in ("upload", "buildfs", "uploadfs"):
8694
filesystem = variables.get("board_build.filesystem", "littlefs")
8795
if filesystem == "littlefs":
@@ -125,23 +133,28 @@ def configure_default_packages(self, variables, targets):
125133
else:
126134
del self.packages["tool-dfuutil"]
127135

128-
# Enable needed toolchains
129-
for available_mcu in ("esp32", "esp32s2", "esp32s3"):
130-
if available_mcu == mcu and tl_flag:
136+
# Enable needed toolchain for MCU
137+
if tl_flag and mcu in ("esp32", "esp32s2", "esp32s3"):
138+
for available_mcu in ("esp32", "esp32s2", "esp32s3"):
131139
tc_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tc-xt-%s" % mcu)
132140
self.packages["toolchain-xtensa-%s" % mcu]["optional"] = False
133141
self.packages["toolchain-xtensa-%s" % mcu]["version"] = tc_path
134-
if available_mcu == "esp32":
135-
del self.packages["toolchain-riscv32-esp"]
136-
# Enable riscv and ULP toolchains
137-
if mcu in ("esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c6", "esp32h2"):
138-
if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"):
139-
del self.packages["toolchain-esp32ulp"]
140-
# RISC-V based toolchain for ESP32C3, ESP32C6 ESP32S2, ESP32S3 ULP
142+
else:
141143
if tl_flag:
142144
tc_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tc-rv32")
143145
self.packages["toolchain-riscv32-esp"]["optional"] = False
144146
self.packages["toolchain-riscv32-esp"]["version"] = tc_path
147+
148+
# Enable FSM ULP toolchain for ESP32, ESP32S2, ESP32S3 when IDF is selected
149+
if tl_flag and "espidf" in frameworks and mcu in ("esp32", "esp32s2", "esp32s3"):
150+
tc_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tc-ulp")
151+
self.packages["toolchain-esp32ulp"]["optional"] = False
152+
self.packages["toolchain-esp32ulp"]["version"] = tc_path
153+
# Enable RISC-V ULP toolchain for ESP32C6, ESP32S2, ESP32S3 when IDF is selected
154+
if tl_flag and "espidf" in frameworks and mcu in ("esp32s2", "esp32s3", "esp32c6"):
155+
tc_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tc-rv32")
156+
self.packages["toolchain-riscv32-esp"]["optional"] = False
157+
self.packages["toolchain-riscv32-esp"]["version"] = tc_path
145158

146159
return super().configure_default_packages(variables, targets)
147160

0 commit comments

Comments
 (0)