diff --git a/src/coverage/coverageService.ts b/src/coverage/coverageService.ts index 0c81d0f5b..94abe9977 100644 --- a/src/coverage/coverageService.ts +++ b/src/coverage/coverageService.ts @@ -61,15 +61,24 @@ export async function getGcovFilterPaths() { const idfExists = await dirExistPromise(espIdfPath); if (idfExists) { - pathsToFilter.push("--filter", join(espIdfPath, "components")); + pathsToFilter.push( + "--filter", + join(espIdfPath, "components").replace(/\\/g, "/") + ); } const adfExists = await dirExistPromise(espAdfPath); if (adfExists) { - pathsToFilter.push("--filter", join(espAdfPath, "components")); + pathsToFilter.push( + "--filter", + join(espAdfPath, "components").replace(/\\/g, "/") + ); } const mdfExists = await dirExistPromise(espMdfPath); if (mdfExists) { - pathsToFilter.push("--filter", join(espMdfPath, "components")); + pathsToFilter.push( + "--filter", + join(espMdfPath, "components").replace(/\\/g, "/") + ); } return pathsToFilter; } @@ -83,13 +92,13 @@ export async function buildJson(dirPath: string) { "gcovr", [ "--filter", - ".", + ".*", ...componentsDir, "--gcov-executable", gcovTool, "--json", ], - dirPath + dirPath.replace(/\\/g, "/") ); return JSON.parse(result); } @@ -141,20 +150,26 @@ export async function generateCoverageForEditors( if (fileParts && fileParts.length > 1) { const fileName = fileParts.pop(); gcovObjFilePath = join( + dirPath, "build", "esp-idf", fileParts[fileParts.length - 1], "CMakeFiles", `__idf_${fileParts[fileParts.length - 1]}.dir`, fileName - ); + ).replace(/\\/g, "/"); } } for (const gcovFile of gcovJsonObj.files) { + const gcovFilePath = gcovFile.file as string; if ( - gcovFile.file === gcovObjFilePath || - gcovFile.file === editor.document.fileName + gcovObjFilePath.toLowerCase().indexOf(gcovFilePath.toLowerCase()) !== + -1 || + editor.document.fileName + .replace(/\\/g, "/") + .toLowerCase() + .indexOf(gcovFilePath.toLowerCase()) !== -1 ) { const coveredEditor: textEditorWithCoverage = { allLines: [], diff --git a/src/espIdf/debugAdapter/verifyApp.ts b/src/espIdf/debugAdapter/verifyApp.ts index 3206844c3..ba4336bfd 100644 --- a/src/espIdf/debugAdapter/verifyApp.ts +++ b/src/espIdf/debugAdapter/verifyApp.ts @@ -26,6 +26,15 @@ export async function verifyAppBinary(workspaceFolder: string) { const modifiedEnv = appendIdfAndToolsToPath(); const serialPort = readParameter("idf.port"); const flashBaudRate = readParameter("idf.flashBaudRate"); + const idfPath = readParameter("idf.espIdfPath"); + const pythonBinPath = readParameter("idf.pythonBinPath") as string; + const esptoolPath = join( + idfPath, + "components", + "esptool_py", + "esptool", + "esptool.py" + ); const flasherArgsJsonPath = join( workspaceFolder, "build", @@ -39,8 +48,9 @@ export async function verifyAppBinary(workspaceFolder: string) { try { const cmdResult = await spawn( - "esptool.py", + pythonBinPath, [ + esptoolPath, "-p", serialPort, "verify_flash", @@ -53,9 +63,13 @@ export async function verifyAppBinary(workspaceFolder: string) { } ); Logger.info(cmdResult.toString()); - if (cmdResult.toString().indexOf("verify FAILED (digest mismatch)") !== -1) { + if ( + cmdResult.toString().indexOf("verify FAILED (digest mismatch)") !== -1 + ) { return false; - } else if (cmdResult.toString().indexOf("verify OK (digest matched)") !== -1) { + } else if ( + cmdResult.toString().indexOf("verify OK (digest matched)") !== -1 + ) { return true; } return false; diff --git a/src/espIdf/partition-table/partitionFlasher.ts b/src/espIdf/partition-table/partitionFlasher.ts index 7d848a51b..456b4d77c 100644 --- a/src/espIdf/partition-table/partitionFlasher.ts +++ b/src/espIdf/partition-table/partitionFlasher.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -import { basename } from "path"; +import { basename, join } from "path"; import { Progress, ProgressLocation, window, workspace } from "vscode"; import { readParameter } from "../../idfConfiguration"; import { Logger } from "../../logger/logger"; @@ -36,10 +36,19 @@ export async function flashBinaryToPartition(offset: string, binPath: string) { : ""; const modifiedEnv = appendIdfAndToolsToPath(); const serialPort = readParameter("idf.port"); + const idfPath = readParameter("idf.espIdfPath"); + const pythonBinPath = readParameter("idf.pythonBinPath") as string; + const esptoolPath = join( + idfPath, + "components", + "esptool_py", + "esptool", + "esptool.py" + ); await spawn( - "esptool.py", - ["-p", serialPort, "write_flash", offset, binPath], + pythonBinPath, + [esptoolPath, "-p", serialPort, "write_flash", offset, binPath], { cwd: workspaceFolder, env: modifiedEnv, diff --git a/src/espIdf/partition-table/tree.ts b/src/espIdf/partition-table/tree.ts index cad64d69d..2c19fbb39 100644 --- a/src/espIdf/partition-table/tree.ts +++ b/src/espIdf/partition-table/tree.ts @@ -83,6 +83,8 @@ export class PartitionTreeDataProvider try { const modifiedEnv = appendIdfAndToolsToPath(); const serialPort = readParameter("idf.port") as string; + const idfPath = readParameter("idf.espIdfPath"); + const pythonBinPath = readParameter("idf.pythonBinPath") as string; const partitionTableOffsetOption = await window.showQuickPick( [ { @@ -129,9 +131,25 @@ export class PartitionTreeDataProvider "partitionTable.csv" ); + const esptoolPath = join( + idfPath, + "components", + "esptool_py", + "esptool", + "esptool.py" + ); + + const genEsp32PartPath = join( + idfPath, + "components", + "partition_table", + "gen_esp32part.py" + ); + await spawn( - "esptool.py", + pythonBinPath, [ + esptoolPath, "-p", serialPort, "read_flash", @@ -145,10 +163,14 @@ export class PartitionTreeDataProvider } ); - await spawn("gen_esp32part.py", [partTableBin, partTableCsv], { - cwd: workspaceFolder, - env: modifiedEnv, - }); + await spawn( + pythonBinPath, + [genEsp32PartPath, partTableBin, partTableCsv], + { + cwd: workspaceFolder, + env: modifiedEnv, + } + ); const csvData = await readFile(partTableCsv); let csvItems = this.CSV2JSON(csvData.toString()); this.partitionItems = this.createPartitionItemNode(csvItems); @@ -190,24 +212,23 @@ export class PartitionTreeDataProvider public CSV2JSON(csv: String): PartitionItem[] { const rows = new Array(); const lines = csv.split(EOL); - const comment = lines.shift(); - if (!comment.includes("# ESP-IDF Partition Table")) { + const matches = csv.match(/#\s*Name,\s*Type,\s*SubType,\s*Offset,\s*Size,\s*Flags/g); + if (!matches || !matches.length) { console.log("Not a partition table csv, skipping..."); return rows; } - const headers = lines.shift(); lines.forEach((line) => { - if (line === "") { + if (line === "" || line.startsWith("#")) { return; } const cols = line.split(","); rows.push({ - name: cols.shift(), - type: cols.shift(), - subtype: cols.shift(), - offset: cols.shift(), - size: cols.shift(), - flag: cols.shift() === "encrypted" ? true : false, + name: cols.shift().trim(), + type: cols.shift().trim(), + subtype: cols.shift().trim(), + offset: cols.shift().trim(), + size: cols.shift().trim(), + flag: cols.shift().trim() === "encrypted" ? true : false, error: undefined, }); }); diff --git a/src/views/partition-table/util.ts b/src/views/partition-table/util.ts index 113abd31c..f0cace62f 100644 --- a/src/views/partition-table/util.ts +++ b/src/views/partition-table/util.ts @@ -103,24 +103,25 @@ export function JSON2CSV(rows: PartitionTable.Row[]): String { export function CSV2JSON(csv: String): PartitionTable.Row[] { const rows = new Array(); const lines = csv.split(EOL); - const comment = lines.shift(); - if (!comment.includes("# ESP-IDF Partition Table")) { + const matches = csv.match( + /#\s*Name,\s*Type,\s*SubType,\s*Offset,\s*Size,\s*Flags/g + ); + if (!matches || !matches.length) { console.log("Not a partition table csv, skipping..."); return rows; } - const headers = lines.shift(); lines.forEach((line) => { - if (line === "") { + if (line === "" || line.startsWith("#")) { return; } const cols = line.split(","); rows.push({ - name: cols.shift(), - type: cols.shift(), - subtype: cols.shift(), - offset: cols.shift(), - size: cols.shift(), - flag: cols.shift() === "encrypted" ? true : false, + name: cols.shift().trim(), + type: cols.shift().trim(), + subtype: cols.shift().trim(), + offset: cols.shift().trim(), + size: cols.shift().trim(), + flag: cols.shift().trim() === "encrypted" ? true : false, error: undefined, }); });