Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ These icons will be used in the steps below showing common ESP-IDF use cases:

10. Make sure to configure your drivers as mentioned in ESP-IDF [Configure JTAG Interface](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/jtag-debugging/configure-ft2232h-jtag.html) documentation.

11. Before debugging your device, select the device OpenOCD board configuration files by pressing <kbd>F1</kbd> and typing **ESP-IDF: Select OpenOCD Board Configuration**. You can test the connection by clicking status bar icon ![openocd](./media/readme/openocd.png) or pressing <kbd>F1</kbd> and typing **ESP-IDF: OpenOCD Manager**. The output is shown in the menu `View` -> `Output` and choose `ESP-IDF` from the dropdown list.
11. Before debugging your device, if you are using a connected ESP-IDF development board, the OpenOCD configuration will be automatically selected based on your connected board, including the USB location if available (requires OpenOCD version v0.12.0-esp32-20240821 or higher). Otherwise, you can manually select the device OpenOCD board configuration files by pressing <kbd>F1</kbd> and typing **ESP-IDF: Select OpenOCD Board Configuration**. You can test the connection by clicking status bar icon ![openocd](./media/readme/openocd.png) or pressing <kbd>F1</kbd> and typing **ESP-IDF: OpenOCD Manager**. The output is shown in the menu `View` -> `Output` and choose `ESP-IDF` from the dropdown list.

> **NOTE:** You can start or stop the OpenOCD in Visual Studio Code using the **ESP-IDF: OpenOCD Manager** command or by clicking the `OpenOCD Server (Running | Stopped)` button in the status bar.

Expand Down Expand Up @@ -159,7 +159,7 @@ Press <kbd>F1</kbd> or click menu `View` -> `Command Palette...` to show Visual
</tr>
<tr>
<td>Pick a Workspace Folder</td>
<td>When using a Visual Studio Code workspace with multiple folders, this command allows you to choose which workspace folder to apply this extensions commands to.
<td>When using a Visual Studio Code workspace with multiple folders, this command allows you to choose which workspace folder to apply this extension's commands to.
More information in <a href="https://docs.espressif.com/projects/vscode-esp-idf-extension/en/latest/additionalfeatures/multiple-projects.html">working with multiple projects</a>.</td>
<td></td>
<td></td>
Expand Down Expand Up @@ -203,7 +203,7 @@ Press <kbd>F1</kbd> or click menu `View` -> `Command Palette...` to show Visual
</tr>
<tr>
<td>Flash Your Project</td>
<td>Write binary data to the ESPs flash chip from your current ESP-IDF project. This command will use either UART, DFU or JTAG based on <strong>idf.flashType</strong>.</td>
<td>Write binary data to the ESP's flash chip from your current ESP-IDF project. This command will use either UART, DFU or JTAG based on <strong>idf.flashType</strong>.</td>
<td><kbd>⌘</kbd> <kbd>I</kbd> <kbd>F</kbd></td>
<td><kbd>Ctrl</kbd> <kbd>E</kbd> <kbd>F</kbd></td>
</tr>
Expand Down Expand Up @@ -272,25 +272,25 @@ Press <kbd>F1</kbd> or click menu `View` -> `Command Palette...` to show Visual
</tr>
<tr>
<td>Flash Your Project</td>
<td>Write binary data to the ESPs flash chip from your current ESP-IDF project. This command will use either UART, DFU or JTAG based on <strong>idf.flashType</strong></td>
<td>Write binary data to the ESP's flash chip from your current ESP-IDF project. This command will use either UART, DFU or JTAG based on <strong>idf.flashType</strong></td>
<td><kbd>⌘</kbd> <kbd>I</kbd> <kbd>F</kbd></td>
<td><kbd>Ctrl</kbd> <kbd>E</kbd> <kbd>F</kbd></td>
</tr>
<tr>
<td>Flash (DFU) Your Project</td>
<td>Write binary data to the ESPs flash chip from your current ESP-IDF project using DFU. Only for ESP32-S2 and ESP32-S3. </td>
<td>Write binary data to the ESP's flash chip from your current ESP-IDF project using DFU. Only for ESP32-S2 and ESP32-S3. </td>
<td></td>
<td></td>
</tr>
<tr>
<td>Flash (UART) Your Project</td>
<td>Write binary data to the ESPs flash chip from your current ESP-IDF project using esptool.py.</td>
<td>Write binary data to the ESP's flash chip from your current ESP-IDF project using esptool.py.</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Flash (with JTAG)</td>
<td>Write binary data to the ESPs flash chip from your current ESP-IDF project using OpenOCD JTAG.</td>
<td>Write binary data to the ESP's flash chip from your current ESP-IDF project using OpenOCD JTAG.</td>
<td></td>
<td></td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion docs_espressif/en/configureproject.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Configure Your Project

Select an Espressif target (esp32, esp32s2, etc.) by going to ``View`` > ``Command Palette`` and entering ``ESP-IDF: Set Espressif Device Target`` command.

Go to ``View`` > ``Command Palette`` and enter ``ESP-IDF: Select OpenOCD Board Configuration`` to choose the openOCD configuration files for the extension openOCD server.
If you are using a connected ESP-IDF development board, the OpenOCD configuration will be automatically selected based on your connected board. Otherwise, you can manually select the OpenOCD configuration by going to ``View`` > ``Command Palette`` and entering ``ESP-IDF: Select OpenOCD Board Configuration``.

.. note::

Expand Down
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,7 @@
"Type 'SWITCH' to confirm switching to Release Mode": "Escriba 'SWITCH' para confirmar el cambio al Modo Release",
"Please type 'SWITCH' exactly to confirm": "Por favor escriba 'SWITCH' exactamente para confirmar",
"Switching to Release Mode cancelled by user": "Cambio al Modo Release cancelado por el usuario",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Usuario confirmó el cambio al Modo Release. Procediendo con el cifrado de flash."
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Usuario confirmó el cambio al Modo Release. Procediendo con el cifrado de flash.",
"Connected ESP-IDF devkit detection is skipped while debugging. You can still select a target manually.": "La detección de devkit ESP-IDF conectados se omite durante la depuración. Aún puede seleccionar un objetivo manualmente.",
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "La detección de devkit ESP-IDF conectados no está disponible para su versión de OpenOCD {openOCDVersion}. Se requiere la versión {minRequiredVersion} o superior. Aún puede seleccionar un objetivo manualmente."
}
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,7 @@
"Type 'SWITCH' to confirm switching to Release Mode": "Digite 'SWITCH' para confirmar a mudança para o Modo de Release",
"Please type 'SWITCH' exactly to confirm": "Por favor, digite 'SWITCH' exatamente para confirmar",
"Switching to Release Mode cancelled by user": "Mudança para o Modo de Release cancelada pelo usuário",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Usuário confirmou a mudança para o Modo de Release. Prosseguindo com a criptografia flash."
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Usuário confirmou a mudança para o Modo de Release. Prosseguindo com a criptografia flash.",
"Connected ESP-IDF devkit detection is skipped while debugging. You can still select a target manually.": "A detecção de devkit ESP-IDF conectados é ignorada durante a depuração. Você ainda pode selecionar um alvo manualmente.",
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "A detecção de devkit ESP-IDF conectados não está disponível para sua versão do OpenOCD {openOCDVersion}. É necessária a versão {minRequiredVersion} ou superior. Você ainda pode selecionar um alvo manualmente."
}
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,7 @@
"Type 'SWITCH' to confirm switching to Release Mode": "Введите 'SWITCH' для подтверждения переключения в Режим Релиза",
"Please type 'SWITCH' exactly to confirm": "Пожалуйста, введите точно 'SWITCH' для подтверждения",
"Switching to Release Mode cancelled by user": "Переключение в Режим Релиза отменено пользователем",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Пользователь подтвердил переключение в Режим Релиза. Продолжаем шифрование флеш-памяти."
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Пользователь подтвердил переключение в Режим Релиза. Продолжаем шифрование флеш-памяти.",
"Connected ESP-IDF devkit detection is skipped while debugging. You can still select a target manually.": "Обнаружение подключенных ESP-IDF devkit пропускается во время отладки. Вы все еще можете выбрать цель вручную.",
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "Обнаружение подключенных ESP-IDF devkit недоступно для вашей версии OpenOCD {openOCDVersion}. Требуется версия {minRequiredVersion} или выше. Вы все еще можете выбрать цель вручную."
}
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,7 @@
"Type 'SWITCH' to confirm switching to Release Mode": "输入 'SWITCH' 确认切换到发布模式",
"Please type 'SWITCH' exactly to confirm": "请准确输入 'SWITCH' 以确认",
"Switching to Release Mode cancelled by user": "用户取消了切换到发布模式",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "用户确认切换到发布模式。继续进行闪存加密。"
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "用户确认切换到发布模式。继续进行闪存加密。",
"Connected ESP-IDF devkit detection is skipped while debugging. You can still select a target manually.": "调试时跳过已连接的 ESP-IDF 开发板检测。您仍可以手动选择目标。",
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "您的 OpenOCD 版本 {openOCDVersion} 不支持已连接的 ESP-IDF 开发板检测功能。需要 {minRequiredVersion} 或更高版本。您仍可以手动选择目标。"
}
150 changes: 150 additions & 0 deletions src/espIdf/setTarget/DevkitsCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
* Project: ESP-IDF VSCode Extension
* File Created: Friday, 8th January 2021 5:34:24 pm
* Copyright 2021 Espressif Systems (Shanghai) CO LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as vscode from "vscode";
import * as fs from "fs"
import { join } from "path";
import * as idfConf from "../../idfConfiguration";
import { Logger } from "../../logger/logger";
import { getVirtualEnvPythonPath } from "../../pythonManager";
import { OpenOCDManager } from "../openOcd/openOcdManager";
import { appendIdfAndToolsToPath, execChildProcess } from "../../utils";
import { OutputChannel } from "../../logger/outputChannel";
import { getOpenOcdScripts } from "../openOcd/boardConfiguration";

export class DevkitsCommand {
private workspaceRoot: vscode.Uri;

constructor(workspaceRoot: vscode.Uri) {
this.workspaceRoot = workspaceRoot;
}

public async runDevkitsScript(): Promise<string> {
try {
const workspaceFolder = vscode.workspace.getWorkspaceFolder(
this.workspaceRoot
);
if (!workspaceFolder) {
throw new Error("No workspace folder found");
}

const toolsPath = idfConf.readParameter(
"idf.toolsPath",
this.workspaceRoot
) as string;
const openOCDManager = OpenOCDManager.init();
const openOCDVersion = await openOCDManager.version();

if (!toolsPath || !openOCDVersion) {
throw new Error("Could not get toolsPath or OpenOCD version");
}

const scriptPath = join(
toolsPath,
"tools",
"openocd-esp32",
openOCDVersion,
"openocd-esp32",
"share",
"openocd",
"espressif",
"tools",
"esp_detect_config.py"
);

if (!fs.existsSync(scriptPath)) {
const infoMsg = `Devkit detection script not available at: ${scriptPath}. A default list of targets will be displayed instead.`;
Logger.info(infoMsg);
OutputChannel.appendLine(infoMsg, "ESP Detect Config");
OutputChannel.show();
return;
}

const openOcdScriptsPath = await getOpenOcdScripts(this.workspaceRoot);
if (!openOcdScriptsPath) {
throw new Error("Could not get OpenOCD scripts path");
}

const espConfigPath = join(openOcdScriptsPath, "esp-config.json");

const notificationMode = idfConf.readParameter(
"idf.notificationMode",
this.workspaceRoot
) as string;

const ProgressLocation =
notificationMode === idfConf.NotificationMode.All ||
notificationMode === idfConf.NotificationMode.Notifications
? vscode.ProgressLocation.Notification
: vscode.ProgressLocation.Window;

const pythonBinPath = await getVirtualEnvPythonPath(this.workspaceRoot);
const modifiedEnv = await appendIdfAndToolsToPath(this.workspaceRoot);

OutputChannel.init();
OutputChannel.appendLine(
"Running ESP Detect Config...",
"ESP Detect Config"
);
OutputChannel.show();

return await vscode.window.withProgress(
{
cancellable: true,
location: ProgressLocation,
title: "ESP-IDF: Running ESP Detect Config",
},
async (
progress: vscode.Progress<{ message: string; increment: number }>,
cancelToken: vscode.CancellationToken
) => {
try {
const result = await execChildProcess(
pythonBinPath,
[scriptPath, "--esp-config", espConfigPath],
this.workspaceRoot.fsPath,
OutputChannel.init(),
{ env: modifiedEnv },
cancelToken
);

OutputChannel.appendLine(result, "ESP Detect Config");
OutputChannel.show();
vscode.window.showInformationMessage("ESP Detect Config completed");
return result;
} catch (error) {
const msg = error.message
? error.message
: "Error running ESP Detect Config";
Logger.errorNotify(msg, error, "DevkitsCommand");
OutputChannel.appendLine(msg, "ESP Detect Config");
OutputChannel.show();
throw error;
}
}
);
} catch (error) {
const msg = error.message
? error.message
: "Error running ESP Detect Config";
Logger.errorNotify(msg, error, "DevkitsCommand");
OutputChannel.appendLine(msg, "ESP Detect Config");
OutputChannel.show();
}
}
}
Loading