Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEP-1297 Consolidate information about the target and board in one place #1027

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
79e8529
feat: revamp the launch target editor page
sigmaaa Jul 29, 2024
a1bcf6a
feat: refactoring code before providing new default values in target
sigmaaa Jul 29, 2024
ba1ba39
feat: clean up redundant parts and dead code
sigmaaa Jul 29, 2024
c83f205
feat: clean up launch configuration and dfu part
sigmaaa Jul 30, 2024
af3cdcb
feat: introducing gdb_client_executable dynamic variable
sigmaaa Jul 30, 2024
8f7c130
feat: update gdb other options layout
sigmaaa Aug 1, 2024
0bec3f2
feat: added info message with an icon and text buttons with reveal bu…
sigmaaa Aug 2, 2024
54fa9e2
feat: moved custom swt to the separate module, updated launch config
sigmaaa Aug 5, 2024
0194d3d
feat: updated custom swt plugin.xml
sigmaaa Aug 5, 2024
78210be
fix: added coderabbit suggestions
sigmaaa Aug 5, 2024
faf55fc
fix: fixed some conflicts after rebase
sigmaaa Aug 21, 2024
9e9d3c2
fix: fixed fefault_argument_prefix
sigmaaa Aug 21, 2024
a477bf4
fix: fixing typo default constant
sigmaaa Aug 21, 2024
bfc5413
fix: added icons to the build bins
sigmaaa Aug 26, 2024
ef0936b
fix: fixing notification that target has been changed
sigmaaa Aug 29, 2024
5be43b3
fix: removing .classpath from the bundles
sigmaaa Aug 30, 2024
4f4923b
feat: introducing serial_port dynamic variable
sigmaaa Aug 30, 2024
45ae17d
fix: fixing jSerialComm exception during init page
sigmaaa Sep 3, 2024
a8ef12a
fix: replaced icons with espressif icons
sigmaaa Sep 3, 2024
3f25432
fix: do not select port if targetPort is empty
sigmaaa Sep 3, 2024
331935e
feat: externalizing jtag related labels
sigmaaa Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions bundles/.settings/org.eclipse.m2e.core.prefs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ Bundle-Vendor = ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD
Bundle-Name = ESP-IDF Core
openocd_bin_path = path to openocd bin folder specified in Espressif -> Global OpenOCD path
openocd_exe = openocd executable file
openocd_scripts = OPENOCD_SCRIPTS represents the value specified in environment variables
openocd_scripts = OPENOCD_SCRIPTS represents the value specified in environment variables
jtag_flash_args = JTAG_FLASH_ARGS dynamically converts ${JTAG_FLASH_ARGS} into a command line with -c and -f options. These options are generated based on the current launch target, configuring settings like flash voltage and specifying configuration files for the JTAG interface and target device.
gdb_client_executable = GDB_CLIENT_EXECUTABLE is a dynamic variable that is replaced during the debug session with the appropriate toolchain path automatically based on the selected target.
serial_port = serial_port is a dynamic variable that is replaced by the serial port specified in the launch target
17 changes: 16 additions & 1 deletion bundles/com.espressif.idf.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,28 @@ config-only component and an interface library is created instead."
</variable>
<variable
description="%openocd_exe"
name="openocd_exe"
name="openocd_executable"
resolver="com.espressif.idf.core.variable.OpenocdVariableResolver">
</variable>
<variable
description="%openocd_scripts"
name="OPENOCD_SCRIPTS"
resolver="com.espressif.idf.core.variable.OpenocdVariableResolver">
</variable>
<variable
description="%jtag_flash_args"
name="JTAG_FLASH_ARGS"
resolver="com.espressif.idf.core.variable.JtagVariableResolver">
</variable>
<variable
description="%gdb_client_executable"
name="GDB_CLIENT_EXECUTABLE"
resolver="com.espressif.idf.core.variable.GdbClientVariableResolver">
</variable>
<variable
description="%serial_port"
name="serial_port"
resolver="com.espressif.idf.core.variable.UartVariableResolver">
</variable>
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;

import com.espressif.idf.core.util.EspConfigParser;
import com.espressif.idf.core.util.StringUtil;

public class DefaultBoardProvider
{
private static final int DEFAULT_BOARD_EMPTY_INDEX = 0;
private static final String ESP32C3_DEFAULT_BOARD = "ESP32-C3 chip (via builtin USB-JTAG)"; //$NON-NLS-1$
private static final String ESP32S3_DEFAULT_BOARD = "ESP32-S3 chip (via builtin USB-JTAG)"; //$NON-NLS-1$
private EspConfigParser espConfigParser;

private enum EspTarget
{
Expand All @@ -34,7 +36,12 @@ public static EspTarget enumOf(String value)
}

}


public DefaultBoardProvider()
{
this.espConfigParser = new EspConfigParser();
}

public int getIndexOfDefaultBoard(String targetName, String[] boardsForTarget)
{
String defaultBoard = EspTarget.enumOf(targetName).board;
Expand All @@ -45,4 +52,11 @@ public int getIndexOfDefaultBoard(String targetName, String[] boardsForTarget)
return index.orElse(DEFAULT_BOARD_EMPTY_INDEX);
}

public String getDefaultBoard(String targetName)
{
var boardConfigMap = this.espConfigParser.getBoardsConfigs(targetName);
var boards = boardConfigMap.keySet().toArray(new String[0]);
return boards[getIndexOfDefaultBoard(targetName, boards)];
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
* Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.core;

/**
* This class defines constants used to access attributes in the launch bar target. These constants are used to uniquely
* identify settings such as the board, flash voltage, serial port, and target within the launch configuration.
*/
public final class LaunchBarTargetConstants
{
public static final String PREFIX = "com.espressif.idf.launch.serial.core"; //$NON-NLS-1$
public static final String BOARD = PREFIX + ".board"; //$NON-NLS-1$
public static final String FLASH_VOLTAGE = PREFIX + ".flash_voltage"; //$NON-NLS-1$
public static final String SERIAL_PORT = PREFIX + ".serialPort"; //$NON-NLS-1$
public static final String TARGET = PREFIX + ".idfTarget"; //$NON-NLS-1$

private LaunchBarTargetConstants()
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import com.espressif.idf.core.IDFCorePlugin;
import com.espressif.idf.core.IDFCorePreferenceConstants;
import com.espressif.idf.core.IDFEnvironmentVariables;
import com.espressif.idf.core.LaunchBarTargetConstants;
import com.espressif.idf.core.internal.CMakeConsoleWrapper;
import com.espressif.idf.core.internal.CMakeErrorParser;
import com.espressif.idf.core.logging.Logger;
Expand Down Expand Up @@ -136,7 +137,7 @@
ICMakeToolChainFile toolChainFile, String launchMode)
{
super(config, name, toolChain, launchMode);
this.toolChainFile = toolChainFile;

Check warning on line 140 in bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java

View workflow job for this annotation

GitHub Actions / spotbugs

EI_EXPOSE_REP2

new com.espressif.idf.core.build.IDFBuildConfiguration(IBuildConfiguration, String, IToolChain, ICMakeToolChainFile, String) may expose internal representation by storing an externally mutable object into IDFBuildConfiguration.toolChainFile
Raw output
This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
}

@Override
Expand Down Expand Up @@ -168,7 +169,7 @@
org.eclipse.core.runtime.Path path = new org.eclipse.core.runtime.Path(customBuildDir);
if (!path.toFile().exists())
{
path.toFile().mkdirs();

Check warning on line 172 in bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java

View workflow job for this annotation

GitHub Actions / spotbugs

RV_RETURN_VALUE_IGNORED_BAD_PRACTICE

Exceptional return value of java.io.File.mkdirs() ignored in com.espressif.idf.core.build.IDFBuildConfiguration.getBuildContainerPath()
Raw output
This method returns a value that is not checked. The return value should be checked since it can indicate an unusual or unexpected function execution. For example, the File.delete() method returns false if the file could not be successfully deleted (rather than throwing an Exception). If you don't check the result, you won't notice if the method invocation signals unexpected behavior by returning an atypical return value.
}
return path;
}
Expand Down Expand Up @@ -278,7 +279,7 @@
{
ICMakeToolChainManager manager = IDFCorePlugin.getService(ICMakeToolChainManager.class);
this.toolChainFile = manager.getToolChainFileFor(getToolChain());
return toolChainFile;

Check warning on line 282 in bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java

View workflow job for this annotation

GitHub Actions / spotbugs

EI_EXPOSE_REP

com.espressif.idf.core.build.IDFBuildConfiguration.getToolChainFile() may expose internal representation by returning IDFBuildConfiguration.toolChainFile
Raw output
Returning a reference to a mutable object value stored in one of the object's fields exposes the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Returning a new copy of the object is better approach in many situations.
}

private boolean isLocal() throws CoreException
Expand All @@ -305,7 +306,7 @@
Logger.log(e);
}

this.monitor = monitor;

Check warning on line 309 in bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java

View workflow job for this annotation

GitHub Actions / spotbugs

EI_EXPOSE_REP2

com.espressif.idf.core.build.IDFBuildConfiguration.build(int, Map, IConsole, IProgressMonitor) may expose internal representation by storing an externally mutable object into IDFBuildConfiguration.monitor
Raw output
This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
isProgressSet = false;

IProject project = getProject();
Expand All @@ -326,7 +327,7 @@
Path buildDir = getBuildDirectory();
if (!buildDir.toFile().exists())
{
buildDir.toFile().mkdir();

Check warning on line 330 in bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java

View workflow job for this annotation

GitHub Actions / spotbugs

RV_RETURN_VALUE_IGNORED_BAD_PRACTICE

Exceptional return value of java.io.File.mkdir() ignored in com.espressif.idf.core.build.IDFBuildConfiguration.build(int, Map, IConsole, IProgressMonitor)
Raw output
This method returns a value that is not checked. The return value should be checked since it can indicate an unusual or unexpected function execution. For example, the File.delete() method returns false if the file could not be successfully deleted (rather than throwing an Exception). If you don't check the result, you won't notice if the method invocation signals unexpected behavior by returning an atypical return value.
}

try
Expand Down Expand Up @@ -357,38 +358,38 @@

private boolean buildPrechecks(IConsole console) throws Exception
{
ProjectDescriptionReader projectDescriptionReader = new ProjectDescriptionReader(getProject());
String projectDescriptionIdfPath = projectDescriptionReader.getIdfPath();
Path pathPdIdfPath = Paths.get(projectDescriptionIdfPath);

if (StringUtil.isEmpty(projectDescriptionIdfPath))
{
return true;
}
IDFEnvironmentVariables idfEnvironmentVariables = new IDFEnvironmentVariables();
String envIdfPath = idfEnvironmentVariables.getEnvValue(IDFEnvironmentVariables.IDF_PATH);
Path pathEnvIdf = Paths.get(envIdfPath);

boolean samePaths = false;
if (Platform.getOS().equals(Platform.OS_WIN32))
{
samePaths = pathEnvIdf.toString().equalsIgnoreCase(pathPdIdfPath.toString());
}
else
{
samePaths = pathEnvIdf.toString().equals(pathPdIdfPath.toString());
}

if (!samePaths)
{
String outputMessage = MessageFormat.format(Messages.IDFBuildConfiguration_PreCheck_DifferentIdfPath,
projectDescriptionIdfPath, envIdfPath);
console.getInfoStream().write(outputMessage);

return false;
}

return true;

Check warning on line 392 in bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].
}

private void runCmakeBuildCommand(IConsole console, IProgressMonitor monitor, IProject project, Instant start,
Expand Down Expand Up @@ -515,7 +516,7 @@

if (launchtarget != null)
{
String idfTargetName = launchtarget.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, StringUtil.EMPTY);
String idfTargetName = launchtarget.getAttribute(LaunchBarTargetConstants.TARGET, StringUtil.EMPTY);
if (!idfTargetName.isEmpty())
{
command.add("-DIDF_TARGET=" + idfTargetName); //$NON-NLS-1$
Expand Down Expand Up @@ -651,7 +652,7 @@
ILaunchBarManager launchBarManager = CCorePlugin.getService(ILaunchBarManager.class);
Collection<IToolChain> matchedToolChains = toolChainManager
.getToolChainsMatching(Map.of(IToolChain.ATTR_OS, launchBarManager.getActiveLaunchTarget()
.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, StringUtil.EMPTY), TOOLCHAIN_TYPE, typeId));
.getAttribute(LaunchBarTargetConstants.TARGET, StringUtil.EMPTY), TOOLCHAIN_TYPE, typeId));
return matchedToolChains.stream().findAny().orElse(toolChainManager.getToolChain(typeId, id));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public final class IDFLaunchConstants
{
public static final String ESP_LAUNCH_TARGET_TYPE = "com.espressif.idf.launch.serial.core.serialFlashTarget"; //$NON-NLS-1$
public static final String ATTR_IDF_TARGET = "com.espressif.idf.launch.serial.core.idfTarget"; //$NON-NLS-1$
public static final String DEBUG_LAUNCH_CONFIG_TYPE = "com.espressif.idf.debug.gdbjtag.openocd.launchConfigurationType"; //$NON-NLS-1$
public static final String RUN_LAUNCH_CONFIG_TYPE = "com.espressif.idf.launch.serial.launchConfigurationType"; //$NON-NLS-1$
public static final String FLASH_OVER_JTAG = "FLASH_OVER_JTAG"; //$NON-NLS-1$
Expand All @@ -15,7 +14,6 @@ public final class IDFLaunchConstants
public static final String ATTR_DFU_FLASH_ARGUMENTS = "com.espressif.idf.launch.serial.core.dfuFlashArguments"; //$NON-NLS-1$
public static final String ATTR_JTAG_FLASH_ARGUMENTS = "com.espressif.idf.debug.gdbjtag.openocd.jtagFlashArguments"; //$NON-NLS-1$
public static final String ATTR_LAUNCH_CONFIGURATION_NAME = "com.espressif.idf.debug.gdbjtag.openocd.launchConfigurationName"; //$NON-NLS-1$
public static final String ATTR_SERIAL_PORT = "com.espressif.idf.launch.serial.core.serialPort"; //$NON-NLS-1$
public static final String IDF_TARGET_TYPE = "com.espressif.idf.launch.serial.core.serialFlashTarget"; //$NON-NLS-1$
public static final String OPEN_SERIAL_MONITOR = "OPEN_SERIAL_MONITOR"; //$NON-NLS-1$
public static final String SERIAL_MONITOR_ENCODING = "SERIAL_MONITOR_ENCODING"; //$NON-NLS-1$
Expand Down
Loading
Loading