Skip to content

Commit 52bb368

Browse files
authored
[VSC-1814] Serial usb adapter doesn't clear (#1725)
* fix: persist adapter serial - Parse and persist OpenOCD USB-JTAG adapter serial in extension workspace state. - Clear stored serial when changing target to avoid stale device selection. - Add toggleable [Adapter] S:<serial> L:<location> status bar item (highest priority) and expose it in ESP-IDF Explorer. - Add translations and document the new command. * fix: clear adapter binding - stop OpenOCD on config select/switch * fix(statusbar): refresh adapter item on idf.customExtraVars changes * fix: lint * Update status bar item name and action * fix: lint * Add validation logic to block flash JTAG for edge case - In case no usb adapter location/serial is set and multiple boards are connected, make user to select a target. * Add silent mode for ESP Detect Config (used by JTAG guard)
1 parent d3cc71a commit 52bb368

File tree

16 files changed

+283
-18
lines changed

16 files changed

+283
-18
lines changed

docs_espressif/en/commands.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ All commands start with ``ESP-IDF:``.
9494
- Launch UI to create a CSV file for `ESP-IDF Non-Volatile Storage Library <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/nvs_flash.html>`_.
9595
* - Open ESP-IDF Terminal
9696
- Open a terminal with IDF_PATH and Python virtual environment activated.
97+
* - OpenOCD Adaptor (serial & location)
98+
- Toggle the status bar item that shows the OpenOCD adapter serial number (S) and USB adapter location (L), useful to verify which adapter will be used when multiple devices are connected.
9799
* - Partition Table Editor
98100
- Launch UI to manage custom partition table as described in `ESP-IDF Partition Tables <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html>`_.
99101
* - Pick a Workspace Folder

docs_espressif/zh_CN/commands.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
- 启动 UI,创建 `ESP-IDF 非易失性存储库 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-reference/storage/nvs_flash.html>`_ 的 CSV 文件。
9595
* - 打开 ESP-IDF 终端
9696
- 打开一个终端,并激活 IDF_PATH 和 Python 虚拟环境。
97+
* - OpenOCD 适配器状态栏
98+
- 切换状态栏显示 OpenOCD 适配器序列号(S)和 USB 适配器位置(L),用于在连接多个设备时确认将使用的适配器。
9799
* - 分区表编辑器
98100
- 启动 UI,如 `ESP-IDF 分区表 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/partition-tables.html>`_ 中所述,管理自定义分区表。
99101
* - 选择工作区文件夹

l10n/bundle.l10n.es.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"Show notifications but do not focus tasks output.": "Muestra notificaciones pero no centras el resultado de las tareas.",
2929
"Do not show notifications but focus tasks output.": "No muestre notificaciones, pero centre la salida de las tareas.",
3030
"Show notifications and focus tasks output.": "Muestra notificaciones y resultados de tareas de enfoque.",
31+
"OpenOCD Adaptor (serial & location)": "Adaptador OpenOCD (serie y ubicación)",
32+
"Set Target": "Establecer objetivo",
33+
"Multiple connected boards were detected, but no OpenOCD adapter is selected (serial/location). To avoid flashing the wrong device, set the target for the connected board and rebuild.": "Se detectaron varias placas conectadas, pero no se ha seleccionado ningún adaptador OpenOCD (serie/ubicación). Para evitar flashear el dispositivo incorrecto, establezca el objetivo de la placa conectada y vuelva a compilar.",
3134
"Select the output and notification mode": "Seleccione el modo de salida y notificación",
3235
"Notification mode has changed to {mode}": "El modo de notificación ha cambiado a {mode}",
3336
"No project configuration found": "No se encontró ninguna configuración de proyecto",

l10n/bundle.l10n.pt.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"Show notifications but do not focus tasks output.": "Mostre notificações, mas não concentre a saída das tarefas.",
2929
"Do not show notifications but focus tasks output.": "Não mostre notificações, mas concentre a saída das tarefas.",
3030
"Show notifications and focus tasks output.": "Mostre notificações e concentre a saída das tarefas.",
31+
"OpenOCD Adaptor (serial & location)": "Adaptador OpenOCD (serial e localização)",
32+
"Set Target": "Definir alvo",
33+
"Multiple connected boards were detected, but no OpenOCD adapter is selected (serial/location). To avoid flashing the wrong device, set the target for the connected board and rebuild.": "Várias placas conectadas foram detectadas, mas nenhum adaptador OpenOCD foi selecionado (serial/localização). Para evitar gravar o dispositivo errado, defina o alvo da placa conectada e reconstrua o projeto.",
3134
"Select the output and notification mode": "Selecione o modo de saída e notificação",
3235
"Notification mode has changed to {mode}": "O modo de notificação mudou para {mode}",
3336
"No project configuration found": "Nenhuma configuração de projeto encontrada",

l10n/bundle.l10n.ru.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"Show notifications but do not focus tasks output.": "Показывать уведомления, но не фокусировать вывод задач.",
2929
"Do not show notifications but focus tasks output.": "Не показывать уведомления, но сосредоточить вывод задач.",
3030
"Show notifications and focus tasks output.": "Показывать уведомления и фокусировать вывод задач.",
31+
"OpenOCD Adaptor (serial & location)": "Адаптер OpenOCD (серийный номер и расположение)",
32+
"Set Target": "Задать цель",
33+
"Multiple connected boards were detected, but no OpenOCD adapter is selected (serial/location). To avoid flashing the wrong device, set the target for the connected board and rebuild.": "Обнаружено несколько подключённых плат, но не выбран адаптер OpenOCD (серийный номер/расположение). Чтобы избежать прошивки неправильного устройства, задайте цель для подключённой платы и пересоберите проект.",
3134
"Select the output and notification mode": "Выберите режим вывода и уведомления",
3235
"Notification mode has changed to {mode}": "Режим уведомлений изменен на {mode}",
3336
"No project configuration found": "Конфигурация проекта не найдена",

l10n/bundle.l10n.zh-CN.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"Show notifications but do not focus tasks output.": "显示通知,但不显示任务输出。",
2929
"Do not show notifications but focus tasks output.": "不显示通知,但显示任务输出。",
3030
"Show notifications and focus tasks output.": "同时显示通知和任务输出。",
31+
"OpenOCD Adaptor (serial & location)": "OpenOCD 适配器(序列号与位置)",
32+
"Set Target": "设置目标",
33+
"Multiple connected boards were detected, but no OpenOCD adapter is selected (serial/location). To avoid flashing the wrong device, set the target for the connected board and rebuild.": "检测到多个已连接的开发板,但未选择 OpenOCD 适配器(序列号/位置)。为避免烧录到错误的设备,请为已连接的开发板设置目标并重新构建项目。",
3134
"Select the output and notification mode": "选择输出和通知模式",
3235
"Notification mode has changed to {mode}": "通知模式已改为 {mode}",
3336
"No project configuration found": "找不到项目配置",

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"onCommand:espIdf.apptrace",
7575
"onCommand:espIdf.heaptrace",
7676
"onCommand:espIdf.openOCDCommand",
77+
"onCommand:espIdf.openOcdAdapterStatusBar",
7778
"onCommand:espIdf.apptrace.archive.refresh",
7879
"onCommand:espIdf.apptrace.archive.showReport",
7980
"onCommand:espIdf.apptrace.customize",
@@ -1479,6 +1480,11 @@
14791480
"title": "%espIdf.openOCDCommand.title%",
14801481
"category": "ESP-IDF"
14811482
},
1483+
{
1484+
"command": "espIdf.openOcdAdapterStatusBar",
1485+
"title": "%espIdf.openOcdAdapterStatusBar.title%",
1486+
"category": "ESP-IDF"
1487+
},
14821488
{
14831489
"command": "espIdf.partition.table.refresh",
14841490
"title": "%espIdf.partition.table.refresh.title%",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"espIdf.ninja.summary.title": "Show Ninja Build Summary",
7171
"espIdf.openDocUrl.title": "Open ESP-IDF Documentation...",
7272
"espIdf.openOCDCommand.title": "OpenOCD Manager",
73+
"espIdf.openOcdAdapterStatusBar.title": "OpenOCD Adaptor (serial & location)",
7374
"espIdf.partition.table.refresh.title": "Refresh Partition Table",
7475
"espIdf.pickAWorkspaceFolder.title": "Pick a Workspace Folder",
7576
"espIdf.projectConf.title": "Select Project Configuration",

src/cmdTreeView/cmdStore.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export enum CommandKeys {
5050
CustomTask = "espIdf.customTask",
5151
QemuServer = "espIdf.qemuCommand",
5252
OpenOCD = "espIdf.openOCDCommand",
53+
OpenOcdAdapterStatusBar = "espIdf.openOcdAdapterStatusBar",
5354
}
5455

5556
export enum AdvancedCommandKeys {
@@ -300,6 +301,14 @@ export function createCommandDictionary(): Record<
300301
iconId: "server-environment",
301302
tooltip: l10n.t("OpenOCD Server"),
302303
},
304+
[CommandKeys.OpenOcdAdapterStatusBar]: {
305+
checkboxState: ESP.GlobalConfiguration.store.get<TreeItemCheckboxState>(
306+
CommandKeys.OpenOcdAdapterStatusBar,
307+
TreeItemCheckboxState.Unchecked
308+
),
309+
iconId: "link",
310+
tooltip: l10n.t("OpenOCD Adaptor (serial & location)"),
311+
},
303312
[CommandKeys.Debug]: {
304313
checkboxState: ESP.GlobalConfiguration.store.get<TreeItemCheckboxState>(
305314
CommandKeys.Debug,

src/espIdf/openOcd/adapterSerial.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import { ESP } from "../../config";
2121
import { Logger } from "../../logger/logger";
2222

2323
/**
24-
* Key used to store the OpenOCD USB adapter serial number in workspace state
24+
* Key used to store the OpenOCD USB adapter serial number in the extension workspace state
25+
* (VS Code `context.workspaceState` via `ESP.ProjectConfiguration.store`), not in user/workspace settings.json.
2526
*/
2627
const OPENOCD_ADAPTER_SERIAL_KEY = "openocd.usbAdapterSerial";
2728

0 commit comments

Comments
 (0)