Skip to content

Commit ffa3fad

Browse files
fix: show targets based on the esp-idf
1 parent 7023f7d commit ffa3fad

File tree

2 files changed

+98
-26
lines changed

2 files changed

+98
-26
lines changed

bundles/com.espressif.idf.core/src/com/espressif/idf/core/DefaultBoardProvider.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public String getDefaultBoard(String targetName)
5858
{
5959
List<Board> boardsList = this.espConfigParser.getBoardsForTarget(targetName);
6060
String[] boards = boardsList.stream().map(Board::name).toArray(String[]::new);
61+
62+
if (boards.length == 0)
63+
{
64+
return EspTarget.enumOf(targetName).board;
65+
}
66+
6167
return boards[getIndexOfDefaultBoard(targetName, boards)];
6268
}
6369

bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/IDFTargets.java

Lines changed: 92 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
2+
* Copyright 2025 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
33
* Use is subject to license terms.
44
*******************************************************************************/
55

@@ -132,17 +132,17 @@ public String getArchitecture()
132132
{
133133
switch (name)
134134
{
135-
case "esp32":
136-
case "esp32s2":
137-
case "esp32s3":
138-
return "xtensa";
139-
case "esp32c2":
140-
case "esp32c3":
141-
case "esp32c6":
142-
case "esp32h2":
143-
case "esp32p4":
135+
case "esp32": //$NON-NLS-1$
136+
case "esp32s2": //$NON-NLS-1$
137+
case "esp32s3": //$NON-NLS-1$
138+
return "xtensa"; //$NON-NLS-1$
139+
case "esp32c2": //$NON-NLS-1$
140+
case "esp32c3": //$NON-NLS-1$
141+
case "esp32c6": //$NON-NLS-1$
142+
case "esp32h2": //$NON-NLS-1$
143+
case "esp32p4": //$NON-NLS-1$
144144
default:
145-
return "riscv32";
145+
return "riscv32"; //$NON-NLS-1$
146146
}
147147
}
148148

@@ -155,17 +155,17 @@ public String getToolchainId()
155155
{
156156
switch (name)
157157
{
158-
case "esp32":
159-
case "esp32s2":
160-
case "esp32s3":
161-
return "xtensa-" + name + "-elf";
162-
case "esp32c2":
163-
case "esp32c3":
164-
case "esp32c6":
165-
case "esp32h2":
166-
case "esp32p4":
158+
case "esp32": //$NON-NLS-1$
159+
case "esp32s2": //$NON-NLS-1$
160+
case "esp32s3": //$NON-NLS-1$
161+
return "xtensa-" + name + "-elf"; //$NON-NLS-1$ //$NON-NLS-2$
162+
case "esp32c2": //$NON-NLS-1$
163+
case "esp32c3": //$NON-NLS-1$
164+
case "esp32c6": //$NON-NLS-1$
165+
case "esp32h2": //$NON-NLS-1$
166+
case "esp32p4": //$NON-NLS-1$
167167
default:
168-
return "riscv32-esp-elf";
168+
return "riscv32-esp-elf"; //$NON-NLS-1$
169169
}
170170
}
171171

@@ -176,8 +176,15 @@ public String getToolchainId()
176176
*/
177177
public String getCompilerPattern()
178178
{
179-
String toolchainId = getToolchainId();
180-
return toolchainId + "[\\\\/]+bin[\\\\/]+" + toolchainId + "-gcc(?:\\.exe)?$";
179+
String executableName = getExecutableName();
180+
181+
// Support both old and new unified directory structures
182+
String targetSpecificDir = getTargetSpecificDirectoryName();
183+
String unifiedDir = getUnifiedDirectoryName();
184+
185+
// Create pattern that matches either directory structure
186+
return "(?:" + targetSpecificDir + "|" + unifiedDir + ")[\\\\/]+bin[\\\\/]+" + executableName //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
187+
+ "-gcc(?:\\.exe)?$"; //$NON-NLS-1$
181188
}
182189

183190
/**
@@ -187,8 +194,67 @@ public String getCompilerPattern()
187194
*/
188195
public String getDebuggerPattern()
189196
{
190-
String toolchainId = getToolchainId();
191-
return toolchainId + "-gdb(?:\\.exe)?$";
197+
String executableName = getExecutableName();
198+
return executableName + "-gdb(?:\\.exe)?$"; //$NON-NLS-1$
199+
}
200+
201+
/**
202+
* Get the executable name prefix for this target (different from directory structure in ESP-IDF v5.5+)
203+
*
204+
* @return executable name prefix
205+
*/
206+
private String getExecutableName()
207+
{
208+
switch (name)
209+
{
210+
case "esp32": //$NON-NLS-1$
211+
case "esp32s2": //$NON-NLS-1$
212+
case "esp32s3": //$NON-NLS-1$
213+
return "xtensa-" + name + "-elf"; // Target-specific executable names //$NON-NLS-1$ //$NON-NLS-2$
214+
case "esp32c2": //$NON-NLS-1$
215+
case "esp32c3": //$NON-NLS-1$
216+
case "esp32c6": //$NON-NLS-1$
217+
case "esp32h2": //$NON-NLS-1$
218+
case "esp32p4": //$NON-NLS-1$
219+
default:
220+
return "riscv32-esp-elf"; // Unified executable name //$NON-NLS-1$
221+
}
222+
}
223+
224+
private String getTargetSpecificDirectoryName()
225+
{
226+
switch (name)
227+
{
228+
case "esp32": //$NON-NLS-1$
229+
case "esp32s2": //$NON-NLS-1$
230+
case "esp32s3": //$NON-NLS-1$
231+
return "xtensa-" + name + "-elf"; // Target-specific directory names //$NON-NLS-1$ //$NON-NLS-2$
232+
case "esp32c2": //$NON-NLS-1$
233+
case "esp32c3": //$NON-NLS-1$
234+
case "esp32c6": //$NON-NLS-1$
235+
case "esp32h2": //$NON-NLS-1$
236+
case "esp32p4": //$NON-NLS-1$
237+
default:
238+
return "riscv32-esp-elf"; // Same for both old and new //$NON-NLS-1$
239+
}
240+
}
241+
242+
private String getUnifiedDirectoryName()
243+
{
244+
switch (name)
245+
{
246+
case "esp32": //$NON-NLS-1$
247+
case "esp32s2": //$NON-NLS-1$
248+
case "esp32s3": //$NON-NLS-1$
249+
return "xtensa-esp-elf"; // Unified directory name //$NON-NLS-1$
250+
case "esp32c2": //$NON-NLS-1$
251+
case "esp32c3": //$NON-NLS-1$
252+
case "esp32c6": //$NON-NLS-1$
253+
case "esp32h2": //$NON-NLS-1$
254+
case "esp32p4": //$NON-NLS-1$
255+
default:
256+
return "riscv32-esp-elf"; //$NON-NLS-1$
257+
}
192258
}
193259

194260
/**
@@ -198,7 +264,7 @@ public String getDebuggerPattern()
198264
*/
199265
public String getToolchainFileName()
200266
{
201-
return "toolchain-" + name + ".cmake";
267+
return "toolchain-" + name + ".cmake"; //$NON-NLS-1$ //$NON-NLS-2$
202268
}
203269
}
204270
}

0 commit comments

Comments
 (0)