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

Enhance/openocd troubleshooting #1137

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export namespace ESP {
}
export const GithubRepository =
"https://github.com/espressif/vscode-esp-idf-extension";
export const OpenOcdTroubleshootingFaq =
"https://github.com/espressif/openocd-esp32/wiki/Troubleshooting-FAQ";
export const ARDUINO_ESP32_URL =
"https://github.com/espressif/arduino-esp32.git";
export namespace Docs {
Expand Down
10 changes: 10 additions & 0 deletions src/espIdf/openOcd/openOcdManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
spawn as sspawn,
} from "../../utils";
import { TCLClient, TCLConnection } from "./tcl/tclClient";
import { ESP } from "../../config";

export interface IOpenOCDConfig {
host: string;
Expand All @@ -52,6 +53,7 @@ export class OpenOCDManager extends EventEmitter {
private statusBar: vscode.StatusBarItem;
private tclConnectionParams: TCLConnection;
private workspace: vscode.Uri;
private encounteredErrors: boolean = false;

private constructor() {
super();
Expand Down Expand Up @@ -211,6 +213,7 @@ export class OpenOCDManager extends EventEmitter {
env: modifiedEnv,
});
this.server.stderr.on("data", (data) => {
this.encounteredErrors = true;
data = typeof data === "string" ? Buffer.from(data) : data;
this.sendToOutputChannel(data);
const regex = /Error:.*/i;
Expand Down Expand Up @@ -240,6 +243,13 @@ export class OpenOCDManager extends EventEmitter {
this.stop();
});
this.server.on("close", (code: number, signal: string) => {
if (this.encounteredErrors) {
OutputChannel.appendLine(
`For assistance with OpenOCD errors, please refer to our Troubleshooting FAQ: ${ESP.URL.OpenOcdTroubleshootingFaq}`,
"OpenOCD"
);
}
this.encounteredErrors = false;
if (!signal && code && code !== 0) {
Logger.errorNotify(
`OpenOCD Exit with non-zero error code ${code}`,
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class PreCheck {
/v(\d+.?\d+.?\d)-esp32-(\d+)/
);
if (!minVersionParsed || !currentVersionParsed) {
throw new Error("Error parsing versions");
throw new Error("Error parsing OpenOCD versions");
}
const validationResult =
currentVersionParsed[1] >= minVersionParsed[1]
Expand Down
Loading