diff --git a/package-lock.json b/package-lock.json index 9e48090..fecff76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,8 +7,10 @@ "": { "name": "pico-littlefs-upload", "version": "0.0.2", + "license": "MIT", "dependencies": { - "execa": "^8.0.1" + "execa": "^8.0.1", + "tmp": "^0.2.1" }, "devDependencies": { "@types/mocha": "^10.0.1", @@ -569,8 +571,7 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, "node_modules/binary-extensions": { "version": "2.2.0", @@ -585,7 +586,6 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -754,8 +754,7 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, "node_modules/core-util-is": { "version": "1.0.3", @@ -1183,8 +1182,7 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, "node_modules/fsevents": { "version": "2.3.3", @@ -1416,7 +1414,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -1425,8 +1422,7 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/is-binary-path": { "version": "2.1.0", @@ -1710,7 +1706,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -1903,7 +1898,6 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, "dependencies": { "wrappy": "1" } @@ -2000,7 +1994,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -2162,7 +2155,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, "dependencies": { "glob": "^7.1.3" }, @@ -2177,7 +2169,6 @@ "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -2443,6 +2434,17 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, + "node_modules/tmp": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", + "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", + "dependencies": { + "rimraf": "^3.0.0" + }, + "engines": { + "node": ">=8.17.0" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -2636,8 +2638,7 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "node_modules/y18n": { "version": "5.0.8", diff --git a/package.json b/package.json index 7214a83..69aba4f 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "typescript": "^5.1.6" }, "dependencies": { - "execa": "^8.0.1" + "execa": "^8.0.1", + "tmp": "^0.2.1" } } diff --git a/pico-littlefs-upload-0.0.2.vsix b/pico-littlefs-upload-0.0.2.vsix index aa704c8..f02bfdd 100644 Binary files a/pico-littlefs-upload-0.0.2.vsix and b/pico-littlefs-upload-0.0.2.vsix differ diff --git a/src/extension.ts b/src/extension.ts index b290dba..d7e0bcf 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -30,14 +30,21 @@ export function activate(context: vscode.ExtensionContext) { return; } - // TODO - Can we get the ArduinoContext to export the actual set of values, not just the label? Then we can use arduinoContext.boardDetails.configOptions - if ((arduinoContext.compileSummary?.buildProperties["build.fs_start"] === undefined) || (arduinoContext.compileSummary?.buildProperties["build.fs_end"] === undefined)) { - vscode.window.showErrorMessage("No filesystem settings defined. Compile the sketch once."); - return; - } + // Need to find the selected menu item, then get the associated build values + let fsStart = 0; + let fsEnd = 0; + arduinoContext.boardDetails.configOptions.forEach( (opt) => { + if (opt.option === "flash") { + opt.values.forEach( (itm) => { + if (itm.selected) { + let menustr = "menu.flash." + itm.value + ".build."; + fsStart = Number(arduinoContext.boardDetails?.buildProperties[menustr + "fs_start"]); + fsEnd = Number(arduinoContext.boardDetails?.buildProperties[menustr + "fs_end"]); + } + }); + } + }); - let fsStart = Number(arduinoContext.compileSummary?.buildProperties["build.fs_start"]); - let fsEnd = Number(arduinoContext.compileSummary?.buildProperties["build.fs_end"]); let page = 256; let blocksize = 4096; @@ -78,12 +85,12 @@ export function activate(context: vscode.ExtensionContext) { } // OTW, assume it's in the path is best we can do let dataFolder = arduinoContext.sketchPath + "/data"; - var path = require('path'); - let imageFile = "/" + path.basename(arduinoContext.sketchPath); - if (arduinoContext.compileSummary?.buildPath !== undefined) { - imageFile = arduinoContext.compileSummary?.buildPath + imageFile; - } - imageFile = imageFile + ".mklittlefs.bin"; + + // We can't always know where the compile path is, so just use a temp name + const tmp = require('tmp'); + tmp.setGracefulCleanup(); + let imageFile = tmp.tmpNameSync({postfix: ".littlefs.bin"}); + let buildOpts = ["-c", dataFolder, "-p", String(page), "-b", String(blocksize), "-s", String(fsEnd - fsStart), imageFile]; let uploadOpts = [uf2conv, "--base", String(fsStart), "--serial", serialPort, "--family", "RP2040", imageFile]; @@ -98,6 +105,4 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(disposable); } -export function deactivate() {} - - +export function deactivate() {} \ No newline at end of file