@@ -71,8 +71,10 @@ def install_tool(TOOL):
71
71
sys .stderr .write ("Error: Couldn't execute 'idf_tools.py install'\n " )
72
72
else :
73
73
tl_path = "file://" + join (TOOLS_PATH_DEFAULT , "tools" , TOOL )
74
- if not os . path . exists ( join ( TOOLS_PATH_DEFAULT , "tools" , TOOL , "package.json" )) :
74
+ try :
75
75
shutil .copyfile (TOOL_PACKAGE_PATH , join (TOOLS_PATH_DEFAULT , "tools" , TOOL , "package.json" ))
76
+ except FileNotFoundError as e :
77
+ sys .stderr .write (f"Error copying tool package file: { e } \n " )
76
78
self .packages .pop (TOOL , None )
77
79
if os .path .exists (TOOL_PATH ) and os .path .isdir (TOOL_PATH ):
78
80
try :
@@ -108,6 +110,51 @@ def install_tool(TOOL):
108
110
if mcu == "esp32c2" :
109
111
self .packages ["framework-arduino-c2-skeleton-lib" ]["optional" ] = False
110
112
113
+ mcu_toolchain_mapping = {
114
+ # Xtensa based and FSM toolchain
115
+ ("esp32" , "esp32s2" , "esp32s3" ): {
116
+ "toolchains" : ["toolchain-xtensa-esp-elf" ],
117
+ "ulp_toolchain" : ["toolchain-esp32ulp" ] + (["toolchain-riscv32-esp" ] if mcu != "esp32" else []),
118
+ "debug_tools" : ["tool-xtensa-esp-elf-gdb" ]
119
+ },
120
+ # RISC-V based toolchain
121
+ ("esp32c2" , "esp32c3" , "esp32c5" , "esp32c6" , "esp32h2" , "esp32p4" ): {
122
+ "toolchains" : ["toolchain-riscv32-esp" ],
123
+ "ulp_toolchain" : None ,
124
+ "debug_tools" : ["tool-riscv32-esp-elf-gdb" ]
125
+ }
126
+ }
127
+
128
+ # Iterate through MCU mappings
129
+ for supported_mcus , toolchain_data in mcu_toolchain_mapping .items ():
130
+ if mcu in supported_mcus :
131
+ # Set mandatory toolchains
132
+ for toolchain in toolchain_data ["toolchains" ]:
133
+ self .packages [toolchain ]["optional" ] = False
134
+
135
+ # Set ULP toolchain if applicable
136
+ ulp_toolchain = toolchain_data .get ("ulp_toolchain" )
137
+ if ulp_toolchain and os .path .isdir ("ulp" ):
138
+ for toolchain in ulp_toolchain :
139
+ self .packages [toolchain ]["optional" ] = False
140
+ # Install debug tools if conditions match
141
+ if (variables .get ("build_type" ) or "debug" in "" .join (targets )) or variables .get ("upload_protocol" ):
142
+ for debug_tool in toolchain_data ["debug_tools" ]:
143
+ self .packages [debug_tool ]["optional" ] = False
144
+ install_tool ("tool-openocd-esp32" )
145
+ break # Exit loop once MCU is matched
146
+
147
+ # Common packages for IDF and mixed Arduino+IDF projects
148
+ COMMON_IDF_PACKAGES = [
149
+ "tool-cmake" ,
150
+ "tool-ninja" ,
151
+ "tool-scons" ,
152
+ "tool-esp-rom-elfs"
153
+ ]
154
+ if "espidf" in frameworks :
155
+ for package in COMMON_IDF_PACKAGES :
156
+ self .packages [package ]["optional" ] = False
157
+
111
158
# Enable check tools only when "check_tool" is active
112
159
for p in self .packages :
113
160
if p in ("tool-cppcheck" , "tool-clangtidy" , "tool-pvs-studio" ):
@@ -122,9 +169,6 @@ def install_tool(TOOL):
122
169
else :
123
170
self .packages ["tool-mkspiffs" ]["optional" ] = False
124
171
125
- if os .path .isdir ("ulp" ):
126
- self .packages ["toolchain-esp32ulp" ]["optional" ] = False
127
-
128
172
if "downloadfs" in targets :
129
173
filesystem = variables .get ("board_build.filesystem" , "littlefs" )
130
174
if filesystem == "littlefs" :
@@ -137,35 +181,6 @@ def install_tool(TOOL):
137
181
else :
138
182
del self .packages ["tool-dfuutil-arduino" ]
139
183
140
- # install GDB and OpenOCD when debug mode or upload_protocol is set
141
- if (variables .get ("build_type" ) or "debug" in "" .join (targets )) or variables .get ("upload_protocol" ):
142
- for gdb_package in ("tool-xtensa-esp-elf-gdb" , "tool-riscv32-esp-elf-gdb" ):
143
- self .packages [gdb_package ]["optional" ] = False
144
- install_tool ("tool-openocd-esp32" )
145
-
146
- # Common packages for IDF and mixed Arduino+IDF projects
147
- if "espidf" in frameworks :
148
- self .packages ["toolchain-esp32ulp" ]["optional" ] = False
149
- for p in self .packages :
150
- if p in (
151
- "tool-cmake" ,
152
- "tool-ninja" ,
153
- "tool-scons" ,
154
- "tool-esp-rom-elfs" ,
155
- ):
156
- self .packages [p ]["optional" ] = False
157
-
158
- if mcu in ("esp32" , "esp32s2" , "esp32s3" ):
159
- self .packages ["toolchain-xtensa-esp-elf" ]["optional" ] = False
160
- else :
161
- self .packages .pop ("toolchain-xtensa-esp-elf" , None )
162
-
163
- if mcu in ("esp32s2" , "esp32s3" , "esp32c2" , "esp32c3" , "esp32c5" , "esp32c6" , "esp32h2" , "esp32p4" ):
164
- if mcu in ("esp32c2" , "esp32c3" , "esp32c5" , "esp32c6" , "esp32h2" , "esp32p4" ):
165
- self .packages .pop ("toolchain-esp32ulp" , None )
166
- # RISC-V based toolchain for ESP32C3, ESP32C6 ESP32S2, ESP32S3 ULP
167
- self .packages ["toolchain-riscv32-esp" ]["optional" ] = False
168
-
169
184
return super ().configure_default_packages (variables , targets )
170
185
171
186
def get_boards (self , id_ = None ):
0 commit comments