Skip to content

Commit

Permalink
add monitor no reset flag (#914)
Browse files Browse the repository at this point in the history
* add monitor no reset flag

* fix lint

* add idf monitor delay before debugging under v5

* fix lint

* fix idf monitor

* add setting to enable no reset

* use no reset in websocket monitor
  • Loading branch information
brianignacio5 authored Apr 4, 2023
1 parent 368827b commit 370d615
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 36 deletions.
2 changes: 2 additions & 0 deletions docs/SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ These settings are used to configure the [Code coverage](./COVERAGE.md) colors.
| `idf.useIDFKconfigStyle` | Enable style validation for Kconfig files | |
| `idf.telemetry` | Enable Telemetry | User, Remote or Workspace |
| `idf.deleteComponentsOnFullClean` | Delete `managed_components` on full clean project command (default `false`) | User, Remote or Workspace |
| `idf.monitorNoReset` | Enable no-reset flag to IDF Monitor (default `false`) | User, Remote or Workspace |
| `idf.monitorStartDelayBeforeDebug` | Delay to start debug session after IDF monitor execution | User, Remote or Workspace |

## Custom tasks for build and flash tasks

Expand Down
2 changes: 2 additions & 0 deletions i18n/en/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
"param.launchMonitorOnDebugSession.title": "Start IDF Monitor along with ESP-IDF Debug Adapter session",
"param.enableIdfComponentManager.title": "Enable IDF Component Manager in build task",
"param.enableCCache.title": "Enable CCache in build task",
"param.monitorStartDelayBeforeDebug": "Delay to start debug session after IDF monitor execution (ms)",
"param.monitorNoReset": "Enable no-reset flag to IDF Monitor",
"esp.rainmaker.backend.sync.title": "Sync with ESP-Rainmaker Cloud Server",
"esp.rainmaker.backend.connect.title": "Connect with ESP-Rainmaker Cloud Server",
"esp.rainmaker.backend.logout.title": "Unlink Rainmaker Account",
Expand Down
2 changes: 2 additions & 0 deletions i18n/es/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
"param.sdkconfigDefaults": "Lista de valores por defecto para crear el archivo sdkconfig",
"param.svdFile": "Archivo SVD para la vista de perifericos en ventana de depuracion",
"param.deleteComponentsOnFullClean": "Borrar managed_components en el comando limpiar proyecto",
"param.monitorStartDelayBeforeDebug": "Retraso para iniciar la sesión de depuración luego de IDF Monitor (ms)",
"param.monitorNoReset": "Habilitar no-reset en el IDF Monitor",
"view.components.name": "Componentes de proyecto",
"configuration.title": "ESP-IDF",
"espIdf.apptrace.archive.refresh.title": "Refresh Trace Archive List",
Expand Down
2 changes: 2 additions & 0 deletions i18n/ru/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
"param.sdkconfigDefaults": "Список значений по умолчанию sdkconfig для начальной конфигурации сборки",
"param.svdFile": "Файл SVD для разрешения периферийного представления ESP-IDF в представлении отладки",
"param.deleteComponentsOnFullClean": "Удалить manage_components при полной очистке проекта.",
"param.monitorStartDelayBeforeDebug": "Задержка запуска сеанса отладки после выполнения монитора IDF (мс)",
"param.monitorNoReset": "Включить флаг отсутствия сброса для монитора IDF",
"view.components.name": "Компоненты проекта",
"configuration.title": "ESP-IDF",
"espIdf.apptrace.archive.refresh.title": "Обновить список архива трассировки",
Expand Down
2 changes: 2 additions & 0 deletions i18n/zh-CN/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
"param.sdkconfigDefaults": "初始生成配置的sdkconfig默认值列表",
"param.svdFile": "用于在调试视图中解析ESP-IDF外围视图的奇异值分解文件",
"param.deleteComponentsOnFullClean": "完全清除项目命令时删除managed_components",
"param.monitorStartDelayBeforeDebug": "IDF监视器执行后延迟启动调试会话 (ms)",
"param.monitorNoReset": "对IDF监视器启用无重置标志",
"view.components.name": "项目组件",
"configuration.title": "ESP-IDF",
"espIdf.apptrace.archive.refresh.title": "刷新跟踪归档列表",
Expand Down
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,18 @@
"default": false,
"scope": "resource",
"description": "%param.deleteComponentsOnFullClean%"
},
"idf.monitorStartDelayBeforeDebug": {
"type": "number",
"default": 5000,
"scope": "resource",
"description": "%param.monitorStartDelayBeforeDebug%"
},
"idf.monitorNoReset": {
"type": "boolean",
"default": false,
"scope": "resource",
"description": "%param.monitorNoReset%"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
"param.deleteComponentsOnFullClean": "Delete managed_components on full clean project command",
"param.buildPath": "Name of CMake build directory",
"param.sdkconfigDefaults": "List of sdkconfig default values for initial build configuration",
"param.monitorStartDelayBeforeDebug": "Delay to start debug session after IDF monitor execution (ms)",
"param.monitorNoReset": "Enable no-reset flag to IDF Monitor",
"view.components.name": "Project Components",
"configuration.title": "ESP-IDF",
"espIdf.apptrace.archive.refresh.title": "Refresh Trace Archive List",
Expand Down
2 changes: 2 additions & 0 deletions schema.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
"param.uncoveredLightTheme",
"param.uncoveredDarkTheme",
"param.sdkconfigDefaults",
"param.monitorStartDelayBeforeDebug",
"param.monitorNoReset",
"view.components.name",
"configuration.title",
"espIdf.apptrace.archive.refresh.title",
Expand Down
6 changes: 3 additions & 3 deletions src/espIdf/monitor/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const locDic = new LocDictionary(__filename);

export async function createNewIdfMonitor(
workspaceFolder: Uri,
noReset: boolean = false,
serialPort?: string
) {
if (BuildTask.isBuilding || FlashTask.isFlashing) {
Expand Down Expand Up @@ -58,9 +59,7 @@ export async function createNewIdfMonitor(
new Error("NOT_SELECTED_PORT")
);
}
let sdkMonitorBaudRate: string = utils.getMonitorBaudRate(
workspaceFolder
);
let sdkMonitorBaudRate: string = utils.getMonitorBaudRate(workspaceFolder);
const pythonBinPath = readParameter(
"idf.pythonBinPath",
workspaceFolder
Expand Down Expand Up @@ -98,6 +97,7 @@ export async function createNewIdfMonitor(
idfTarget,
idfMonitorToolPath,
idfVersion,
noReset,
elfFilePath,
workspaceFolder,
toolchainPrefix,
Expand Down
4 changes: 4 additions & 0 deletions src/espIdf/monitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface MonitorConfig {
idfMonitorToolPath: string;
idfTarget: string;
idfVersion: string;
noReset: boolean;
port: string;
pythonBinPath: string;
toolchainPrefix: string;
Expand Down Expand Up @@ -69,6 +70,9 @@ export class IDFMonitor {
"--toolchain-prefix",
this.config.toolchainPrefix,
];
if (this.config.noReset && this.config.idfVersion >= "5.0") {
args.splice(2, 0, "--no-reset");
}
if (this.config.idfVersion >= "4.3") {
args.push("--target", this.config.idfTarget);
}
Expand Down
81 changes: 48 additions & 33 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,18 @@ export async function activate(context: vscode.ExtensionContext) {
try {
const portToUse = session.configuration.debugPort || DEBUG_DEFAULT_PORT;
const launchMode = session.configuration.mode || "auto";
const useMonitorWithDebug = idfConf.readParameter(
"idf.launchMonitorOnDebugSession",
workspaceRoot
);
if (
(session.configuration.sessionID !== "core-dump.debug.session.ws" ||
session.configuration.sessionID !== "gdbstub.debug.session.ws") &&
useMonitorWithDebug
) {
isMonitorLaunchedByDebug = true;
await createIdfMonitor(true);
}
if (
launchMode === "auto" &&
!openOCDManager.isRunning() &&
Expand Down Expand Up @@ -1211,18 +1223,6 @@ export async function activate(context: vscode.ExtensionContext) {
debugAdapterManager.configureAdapter(debugAdapterConfig);
await debugAdapterManager.start();
}
const useMonitorWithDebug = idfConf.readParameter(
"idf.launchMonitorOnDebugSession",
workspaceRoot
);
if (
(session.configuration.sessionID !== "core-dump.debug.session.ws" ||
session.configuration.sessionID !== "gdbstub.debug.session.ws") &&
useMonitorWithDebug
) {
isMonitorLaunchedByDebug = true;
createMonitor();
}
return new vscode.DebugAdapterServer(portToUse);
} catch (error) {
const errMsg =
Expand All @@ -1249,23 +1249,7 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.debug.registerDebugAdapterTrackerFactory("espidf", {
createDebugAdapterTracker(session: vscode.DebugSession) {
return {
onWillReceiveMessage: (m) => {
const useMonitorWithDebug = idfConf.readParameter(
"idf.launchMonitorOnDebugSession",
workspaceRoot
);
if (
m &&
m.command &&
m.command === "stackTrace" &&
(session.configuration.sessionID !== "core-dump.debug.session.ws" ||
session.configuration.sessionID !== "gdbstub.debug.session.ws") &&
monitorTerminal &&
useMonitorWithDebug
) {
monitorTerminal.show();
}
},
onWillReceiveMessage: (m) => {},
};
},
});
Expand Down Expand Up @@ -2597,6 +2581,10 @@ export async function activate(context: vscode.ExtensionContext) {
const elfFilePath = path.join(buildDirPath, `${projectName}.elf`);
const wsPort = idfConf.readParameter("idf.wssPort", workspaceRoot);
const idfVersion = await utils.getEspIdfFromCMake(idfPath);
const noReset = idfConf.readParameter(
"idf.monitorNoReset",
workspaceRoot
) as boolean;
const monitor = new IDFMonitor({
port,
baudRate: sdkMonitorBaudRate,
Expand All @@ -2605,6 +2593,7 @@ export async function activate(context: vscode.ExtensionContext) {
toolchainPrefix,
idfMonitorToolPath,
idfVersion,
noReset,
elfFilePath,
wsPort,
workspaceFolder: workspaceRoot,
Expand Down Expand Up @@ -3160,7 +3149,7 @@ const flash = (
});
};

function createQemuMonitor() {
function createQemuMonitor(noReset: boolean = false) {
PreCheck.perform([openFolderCheck], async () => {
const isQemuLaunched = await qemuManager.isRunning();
if (!isQemuLaunched) {
Expand All @@ -3172,7 +3161,11 @@ function createQemuMonitor() {
workspaceRoot
) as number;
const serialPort = `socket://localhost:${qemuTcpPort}`;
const idfMonitor = await createNewIdfMonitor(workspaceRoot, serialPort);
const idfMonitor = await createNewIdfMonitor(
workspaceRoot,
noReset,
serialPort
);
monitorTerminal = idfMonitor.start();
});
}
Expand Down Expand Up @@ -3311,11 +3304,33 @@ function createIdfTerminal() {

function createMonitor() {
PreCheck.perform([webIdeCheck, openFolderCheck], async () => {
const idfMonitor = await createNewIdfMonitor(workspaceRoot);
monitorTerminal = idfMonitor.start();
const noReset = idfConf.readParameter(
"idf.monitorNoReset",
workspaceRoot
) as boolean;
await createIdfMonitor(noReset);
});
}

async function createIdfMonitor(noReset: boolean = false) {
const idfMonitor = await createNewIdfMonitor(workspaceRoot, noReset);
monitorTerminal = idfMonitor.start();
if (noReset) {
const idfPath = idfConf.readParameter(
"idf.espIdfPath",
workspaceRoot
) as string;
const idfVersion = await utils.getEspIdfFromCMake(idfPath);
if (idfVersion <= "5.0") {
const monitorDelay = idfConf.readParameter(
"idf.monitorStartDelayBeforeDebug",
workspaceRoot
) as number;
await utils.sleep(monitorDelay);
}
}
}

export function deactivate() {
Telemetry.dispose();
if (monitorTerminal) {
Expand Down

0 comments on commit 370d615

Please sign in to comment.