diff --git a/src/cdtDebugAdapter/debugConfProvider.ts b/src/cdtDebugAdapter/debugConfProvider.ts index fc7470ca0..ec36ef545 100644 --- a/src/cdtDebugAdapter/debugConfProvider.ts +++ b/src/cdtDebugAdapter/debugConfProvider.ts @@ -110,7 +110,10 @@ export class CDTDebugConfigurationProvider | "esp32c3" | "esp32c6" | "esp32h2" - | "esp32p4"; + | "esp32p4" + | "esp32c4" + | "esp32c5" + | "esp32c61"; // Mapping of idfTarget to corresponding CPU watchpoint numbers const idfTargetWatchpointMap: Record = { esp32: 2, @@ -121,11 +124,14 @@ export class CDTDebugConfigurationProvider esp32c6: 4, esp32h2: 4, esp32p4: 3, + esp32c4: 2, + esp32c5: 4, + esp32c61: 4, }; config.initCommands = config.initCommands.map((cmd: string) => cmd.replace( "{IDF_TARGET_CPU_WATCHPOINT_NUM}", - idfTargetWatchpointMap[idfTarget] + idfTargetWatchpointMap[idfTarget] || 2 ) ); } diff --git a/src/espIdf/openOcd/boardConfiguration.ts b/src/espIdf/openOcd/boardConfiguration.ts index 98e7ef3e4..f00eaff33 100644 --- a/src/espIdf/openOcd/boardConfiguration.ts +++ b/src/espIdf/openOcd/boardConfiguration.ts @@ -124,11 +124,26 @@ export async function selectOpenOcdConfigFiles( return; } } + if (idfTarget === "linux") { + return; + } const currentOpenOcdConfigs = readParameter( "idf.openOcdConfigs", workspaceFolder ) as string[]; const boards = await getBoards(openOcdScriptsPath, idfTarget); + const message = l10n.t( + "No OpenOCD boards found for target {target}. Please check your OPENOCD_SCRIPTS environment variable.", + { target: idfTarget } + ); + if (!boards || boards.length === 0) { + Logger.errorNotify( + message, + new Error(message), + "boardConfiguration selectOpenOcdConfigFiles" + ); + return; + } const choices = boards.map((b) => { return { description: `${b.description} (${b.configFiles})`, diff --git a/src/espIdf/setTarget/index.ts b/src/espIdf/setTarget/index.ts index 22e6d83bf..b5e7fdd8c 100644 --- a/src/espIdf/setTarget/index.ts +++ b/src/espIdf/setTarget/index.ts @@ -34,13 +34,25 @@ import { import { Logger } from "../../logger/logger"; import { OutputChannel } from "../../logger/outputChannel"; import { selectOpenOcdConfigFiles } from "../openOcd/boardConfiguration"; -import { getTargetsFromEspIdf } from "./getTargets"; +import { getTargetsFromEspIdf, IdfTarget } from "./getTargets"; import { setTargetInIDF } from "./setTargetInIdf"; import { updateCurrentProfileIdfTarget } from "../../project-conf"; import { DevkitsCommand } from "./DevkitsCommand"; export let isSettingIDFTarget = false; +export interface ISetTargetQuickPickItems { + label: string; + idfTarget?: IdfTarget; + boardInfo?: { + location: string; + config_files: string[]; + }; + description?: string; + isConnected?: boolean; + kind?: QuickPickItemKind; +} + export async function setIdfTarget( placeHolderMsg: string, workspaceFolder: WorkspaceFolder @@ -73,7 +85,7 @@ export async function setIdfTarget( async (progress: Progress<{ message: string; increment: number }>) => { try { const targetsFromIdf = await getTargetsFromEspIdf(workspaceFolder.uri); - let connectedBoards: any[] = []; + let connectedBoards: ISetTargetQuickPickItems[] = []; const isDebugging = debug.activeDebugSession !== undefined; @@ -81,22 +93,27 @@ export async function setIdfTarget( try { const devkitsCmd = new DevkitsCommand(workspaceFolder.uri); const scriptPath = await devkitsCmd.getScriptPath(); - + if (scriptPath) { const devkitsOutput = await devkitsCmd.runDevkitsScript(); if (devkitsOutput) { const parsed = JSON.parse(devkitsOutput); if (parsed && Array.isArray(parsed.boards)) { - connectedBoards = parsed.boards.map((b: any) => ({ - label: b.name, - target: b.target, - description: b.description, - detail: `Status: CONNECTED${ - b.location ? ` Location: ${b.location}` : "" - }`, - isConnected: true, - boardInfo: b, - })); + connectedBoards = parsed.boards.map( + (b: any) => + ({ + label: b.name, + idfTarget: targetsFromIdf.find( + (t) => t.target === b.target + ), + description: b.description, + detail: `Status: CONNECTED${ + b.location ? ` Location: ${b.location}` : "" + }`, + isConnected: true, + boardInfo: b, + } as ISetTargetQuickPickItems) + ); } } } else { @@ -115,26 +132,24 @@ export async function setIdfTarget( "Connected ESP-IDF devkit detection is skipped while debugging. You can still select a target manually." ); } - let quickPickItems: any[] = []; - if (connectedBoards.length > 0) { - quickPickItems = [ - ...connectedBoards, - { kind: QuickPickItemKind.Separator, label: "Default Boards" }, - ...targetsFromIdf.map((t) => ({ - label: t.label, - target: t.target, - description: t.isPreview ? "Preview target" : undefined, - isConnected: false, - })), - ]; - } else { - quickPickItems = targetsFromIdf.map((t) => ({ + let quickPickItems: ISetTargetQuickPickItems[] = []; + const defaultBoards: ISetTargetQuickPickItems[] = targetsFromIdf.map( + (t) => ({ label: t.label, - target: t.target, + idfTarget: t, description: t.isPreview ? "Preview target" : undefined, isConnected: false, - })); - } + }) + ); + + quickPickItems = + connectedBoards.length > 0 + ? [ + ...connectedBoards, + { kind: QuickPickItemKind.Separator, label: "Default Boards" }, + ...defaultBoards, + ] + : defaultBoards; const selectedTarget = await window.showQuickPick(quickPickItems, { placeHolder: placeHolderMsg, }); @@ -171,16 +186,16 @@ export async function setIdfTarget( } else { await selectOpenOcdConfigFiles( workspaceFolder.uri, - selectedTarget.target + selectedTarget.idfTarget.target ); } - await setTargetInIDF(workspaceFolder, selectedTarget); + await setTargetInIDF(workspaceFolder, selectedTarget.idfTarget); const customExtraVars = readParameter( "idf.customExtraVars", workspaceFolder ) as { [key: string]: string }; - customExtraVars["IDF_TARGET"] = selectedTarget.target; + customExtraVars["IDF_TARGET"] = selectedTarget.idfTarget.target; await writeParameter( "idf.customExtraVars", customExtraVars, @@ -188,7 +203,7 @@ export async function setIdfTarget( workspaceFolder.uri ); await updateCurrentProfileIdfTarget( - selectedTarget.target, + selectedTarget.idfTarget.target, workspaceFolder.uri ); } catch (err) { diff --git a/src/espIdf/setTarget/setTargetInIdf.ts b/src/espIdf/setTarget/setTargetInIdf.ts index 14662d6b0..010e5a6aa 100644 --- a/src/espIdf/setTarget/setTargetInIdf.ts +++ b/src/espIdf/setTarget/setTargetInIdf.ts @@ -79,6 +79,7 @@ export async function setTargetInIDF( const setTargetResult = await spawn(pythonBinPath, setTargetArgs, { cwd: workspaceFolder.uri.fsPath, env: modifiedEnv, + silent: false, }); Logger.info(setTargetResult.toString()); const msg = vscode.l10n.t( diff --git a/src/statusBar/index.ts b/src/statusBar/index.ts index f51909b61..8ed1f5669 100644 --- a/src/statusBar/index.ts +++ b/src/statusBar/index.ts @@ -26,6 +26,7 @@ import { Uri, window, l10n, + ThemeIcon, } from "vscode"; import { getCurrentIdfSetup } from "../versionSwitcher"; import { readParameter } from "../idfConfiguration"; @@ -277,7 +278,9 @@ export function updateHintsStatusBarItem(hasHints: boolean) { statusBarItems["hints"].tooltip = l10n.t( "ESP-IDF: Hints available. Click to view." ); - statusBarItems["hints"].backgroundColor = "statusBarItem.warningBackground"; + statusBarItems["hints"].backgroundColor = new ThemeIcon( + "statusBarItem.warningBackground" + ); statusBarItems["hints"].show(); } else { statusBarItems["hints"].hide(); diff --git a/src/utils.ts b/src/utils.ts index b96d2221d..6b3760a8f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -173,17 +173,21 @@ export interface ISpawnOptions extends childProcess.SpawnOptions { export function spawn( command: string, args: string[] = [], - options: ISpawnOptions = { outputString: "", silent: true } + options: ISpawnOptions = { + outputString: "", + silent: false, + appendMode: "appendLine", + } ): Promise { let buff = Buffer.alloc(0); const sendToOutputChannel = (data: Buffer) => { buff = Buffer.concat([buff, data]); options.outputString += buff.toString(); if (!options.silent) { - if (options.appendMode === "appendLine") { - OutputChannel.appendLine(data.toString()); - } else if (options.appendMode === "append") { + if (options.appendMode === "append") { OutputChannel.append(data.toString()); + } else { + OutputChannel.appendLine(data.toString()); } } };