Skip to content

Commit

Permalink
add usb filter and optional esptool py chip id request to serial port…
Browse files Browse the repository at this point in the history
… list
  • Loading branch information
brianignacio5 committed Aug 9, 2024
1 parent 81dea08 commit 5e9ef1a
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ These settings are specific to the ESP32 Chip/Board
| `idf.openOcdDebugLevel` | Set openOCD Debug Level (0-4) Default: 2 | |
| `idf.port` | Path of Selected Device port | |
| `idf.portWin` | Path of Selected Device Port in Windows | |
| `idf.enableSerialPortChipIdRequest` | Enable detecting the chip id and show on serial port selection list | |
| `idf.useSerialPortVendorProductFilter` | Use USB productID and vendorID to filter known Espressif devices | |
| `openocd.jtag.command.force_unix_path_separator` | Forced to Use `/` as Path sep. for Win32 Based OS Instead of `\\` | User, Remote or Workspace |
| `idf.listDfuDevices` | List of DFU Devices Connected to USB | User, Remote or Workspace |
| `idf.selectedDfuDevicePath` | Selected DFU Device Connected to USB | User, Remote or Workspace |
Expand Down
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,18 @@
"scope": "resource",
"default": "espidf.spdx",
"description": "%param.sbomFilePath.title%"
},
"idf.enableSerialPortChipIdRequest": {
"type":"boolean",
"scope": "application",
"default": true,
"description": "%param.enableSerialPortChipIdRequest.title%"
},
"idf.useSerialPortVendorProductFilter": {
"type":"boolean",
"scope": "application",
"default": true,
"description": "%param.useSerialPortVendorProductFilter.title%"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions package.nls.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
"param.uncoveredLightTheme": "Color de fondo para líneas no cubiertas en tema claro para Cobertura de ESP-IDF.",
"param.useIDFKConfigStyle": "Habilitar/Deshabilitar validación de estilo ESP-IDF para archivos Kconfig",
"param.hintsViewer.title": "Ruta al archivo de sugerencias.",
"param.enableSerialPortChipIdRequest.title": "Habilite la detección de la identificación del chip y muéstrela en la lista de selección del puerto serie",
"param.useSerialPortVendorProductFilter.title": "Utilice el USB productID y el USB vendorID para filtrar dispositivos Espressif conocidos",
"trace.poll_period.description": "poll_period se establecerá para el rastreo de la aplicación",
"trace.skip_size.description": "skip_size se establecerá para el rastreo de la aplicación",
"trace.stop_tmo.description": "stop_tmo se establecerá para el rastreo de la aplicación",
Expand Down
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
"param.uncoveredLightTheme": "Background color for uncovered lines in Light theme for ESP-IDF Coverage.",
"param.useIDFKConfigStyle": "Enable/Disable ESP-IDF style validation for Kconfig files",
"param.hintsViewer.title": "Path to the hints file.",
"param.enableSerialPortChipIdRequest.title": "Enable detecting the chip id and show on serial port selection list",
"param.useSerialPortVendorProductFilter.title": "Use USB productID and vendorID to filter known Espressif devices",
"trace.poll_period.description": "poll_period will be set for the apptrace",
"trace.skip_size.description": "skip_size will be set for the apptrace",
"trace.stop_tmo.description": "stop_tmo will be set for the apptrace",
Expand Down
2 changes: 2 additions & 0 deletions package.nls.pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@
"param.uncoveredDarkTheme": "Cor de fundo para linhas descobertas no tema Dark para cobertura ESP-IDF.",
"param.uncoveredLightTheme": "Cor de fundo para linhas descobertas no tema Light para cobertura ESP-IDF.",
"param.useIDFKConfigStyle": "Habilitar/desabilitar validação de estilo ESP-IDF para arquivos Kconfig",
"param.enableSerialPortChipIdRequest.title": "Habilite a detecção do ID do chip e mostre na lista de seleção de porta serial",
"param.useSerialPortVendorProductFilter.title": "Use USB productID e vendorID para filtrar dispositivos Espressif conhecidos",
"trace.poll_period.description": "poll_period será definido para o apptrace",
"trace.skip_size.description": "skip_size será definido para o apptrace",
"trace.stop_tmo.description": "stop_tmo será definido para o apptrace",
Expand Down
2 changes: 2 additions & 0 deletions package.nls.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
"param.uncoveredLightTheme": "Цвет фона для непокрытых линий в светлой теме для покрытия ESP-IDF.",
"param.useIDFKConfigStyle": "Включить/отключить проверку стиля ESP-IDF для файлов Kconfig.",
"param.hintsViewer.title": "Путь к файлу подсказок",
"param.enableSerialPortChipIdRequest.title": "Включить определение идентификатора чипа и отобразить его в списке выбора последовательного порта.",
"param.useSerialPortVendorProductFilter.title": "Используйте USB ProductID и VendorID для фильтрации известных устройств Espressif.",
"trace.poll_period.description": "poll_ period будет установлен для apptrace",
"trace.skip_size.description": "Skip_size будет установлен для трассировки приложения.",
"trace.stop_tmo.description": "stop_tmo будет установлен для apptrace",
Expand Down
2 changes: 2 additions & 0 deletions package.nls.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
"param.uncoveredLightTheme": "在 ESP-IDF 覆盖率的浅色主题中未覆盖的行的背景颜色。",
"param.useIDFKConfigStyle": "启用/禁用 Kconfig 文件的 ESP-IDF 样式验证",
"param.hintsViewer.title": "提示文件的路径",
"param.enableSerialPortChipIdRequest.title": "启用检测芯片 ID 并显示在串口选择列表上",
"param.useSerialPortVendorProductFilter.title": "使用 USB 产品 ID 和供应商 ID 过滤已知的乐鑫设备",
"trace.poll_period.description": "将为 apptrace 设置 poll_period",
"trace.skip_size.description": "将为 apptrace 设置 skip_size",
"trace.stop_tmo.description": "将为 apptrace 设置 stop_tmo",
Expand Down
18 changes: 18 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ export namespace ESP {
"esp_idf_project_configuration.json";
}

export const USB_PORT_FILTERS: { vendorId: number; productId: number }[] = [
{ vendorId: 0x10c4, productId: 0xea60 } /* CP2102/CP2102N */,
{ vendorId: 0x0403, productId: 0x6010 } /* FT2232H */,
{
vendorId: 0x303a,
productId: 0x1001,
} /* Espressif USB_SERIAL_JTAG */,
{
vendorId: 0x303a,
productId: 0x1002,
} /* Espressif esp-usb-bridge firmware */,
{ vendorId: 0x303a, productId: 0x0002 } /* ESP32-S2 USB_CDC */,
{ vendorId: 0x303a, productId: 0x0009 } /* ESP32-S3 USB_CDC */,
{ vendorId: 0x1a86, productId: 0x55d4 } /* CH9102F */,
{ vendorId: 0x1a86, productId: 0x7523 } /* CH340T */,
{ vendorId: 0x0403, productId: 0x6001 } /* FT232R */,
];

export enum FlashType {
JTAG = "JTAG",
UART = "UART",
Expand Down
33 changes: 31 additions & 2 deletions src/espIdf/serial/serialPort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { spawn } from "../../utils";
import { SerialPortDetails } from "./serialPortDetails";
import { OutputChannel } from "../../logger/outputChannel";
import * as SerialPortLib from "serialport";
import { ESP } from "../../config";

export class SerialPort {
public static shared(): SerialPort {
Expand Down Expand Up @@ -93,7 +94,7 @@ export class SerialPort {
return;
}

const choices = listOfSerialPorts.map((item) => {
let choices = listOfSerialPorts.map((item) => {
return new SerialPortDetails(
item.path,
item.manufacturer,
Expand All @@ -109,6 +110,30 @@ export class SerialPort {
"idf.espIdfPath",
workspaceFolder
);
const enableSerialPortChipIdRequest = idfConf.readParameter(
"idf.enableSerialPortChipIdRequest",
workspaceFolder
) as boolean;
const useSerialPortVendorProductFilter = idfConf.readParameter(
"idf.enableSerialPortChipIdRequest",
workspaceFolder
) as boolean;
if (useSerialPortVendorProductFilter) {
choices = choices.filter((port) => {
const vendorIdNumber = parseInt(port.vendorId, 16);
const productIdNumber = parseInt(port.productId, 16);
return ESP.USB_PORT_FILTERS.some(
(filter) =>
filter.vendorId === vendorIdNumber &&
filter.productId === productIdNumber
);
});
}

if (!enableSerialPortChipIdRequest) {
return choices;
}

const esptoolPath = join(
idfPath,
"components",
Expand Down Expand Up @@ -145,7 +170,11 @@ export class SerialPort {
return serialPort;
}

resolve(await Promise.all(choices.map((item) => processPorts(item))));
resolve(
await Promise.all(
choices.map((item) => processPorts(item))
)
);
} catch (error) {
reject(error);
}
Expand Down

0 comments on commit 5e9ef1a

Please sign in to comment.