mirror of
https://gitcode.com/gh_mirrors/ar/arduino-littlefs-upload.git
synced 2025-08-06 18:24:30 +08:00
Try and use only boardDetails, not compileSummary
This commit is contained in:
Binary file not shown.
@ -17,19 +17,20 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
// Register the command
|
// Register the command
|
||||||
let disposable = vscode.commands.registerCommand('pico-littlefs-upload.uploadLittleFS', () => {
|
let disposable = vscode.commands.registerCommand('pico-littlefs-upload.uploadLittleFS', () => {
|
||||||
// let str = JSON.stringify(arduinoContext, null, 4);
|
//let str = JSON.stringify(arduinoContext, null, 4);
|
||||||
// console.log(str);
|
//console.log(str);
|
||||||
|
|
||||||
if ((arduinoContext.boardDetails === undefined) || (arduinoContext.fqbn === undefined)){
|
if ((arduinoContext.boardDetails === undefined) || (arduinoContext.fqbn === undefined)){
|
||||||
vscode.window.showErrorMessage("Board details not available. Compile the sketch once.");
|
vscode.window.showErrorMessage("Board details not available. Compile the sketch once.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arduinoContext.fqbn.startsWith("pico:rp2040")) { //} && !arduinoContext.compileSummary?.buildProperties.fqbn.startsWith("esp8266com:esp8266")) {
|
if (!arduinoContext.fqbn.startsWith("pico:rp2040")) { //} && !arduinoContext.fqbn.startsWith("esp8266com:esp8266")) {
|
||||||
vscode.window.showErrorMessage("Only Arduino-Pico RP2040 supported"); //and the ESP8266 supported");
|
vscode.window.showErrorMessage("Only Arduino-Pico RP2040 supported"); //and the ESP8266 supported");
|
||||||
return;
|
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)) {
|
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.");
|
vscode.window.showErrorMessage("No filesystem settings defined. Compile the sketch once.");
|
||||||
return;
|
return;
|
||||||
@ -45,13 +46,12 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mklittlefs = "mklittlefs";
|
// Windows exes need ".exe" suffix
|
||||||
if (arduinoContext.compileSummary?.buildProperties["runtime.os"].includes("windows")) {
|
let ext = (platform() === 'win32') ? ".exe" : "";
|
||||||
mklittlefs = mklittlefs + ".exe";
|
let mklittlefs = "mklittlefs" + ext;
|
||||||
}
|
|
||||||
|
|
||||||
if (arduinoContext.compileSummary?.buildProperties["runtime.tools.pqt-mklittlefs.path"] !== undefined) {
|
if (arduinoContext.boardDetails.buildProperties["runtime.tools.pqt-mklittlefs.path"] !== undefined) {
|
||||||
mklittlefs = arduinoContext.compileSummary?.buildProperties["runtime.tools.pqt-mklittlefs.path"] + "/" + mklittlefs;
|
mklittlefs = arduinoContext.boardDetails.buildProperties["runtime.tools.pqt-mklittlefs.path"] + "/" + mklittlefs;
|
||||||
} // OTW, assume it's in the path is best we can do
|
} // OTW, assume it's in the path is best we can do
|
||||||
|
|
||||||
// TBD - add non-serial UF2 upload via OpenOCD
|
// TBD - add non-serial UF2 upload via OpenOCD
|
||||||
@ -67,17 +67,14 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let python3 = "python3";
|
let python3 = "python3" + ext;
|
||||||
if (arduinoContext.compileSummary?.buildProperties["runtime.tools.pqt-python3.path"] !== undefined) {
|
if (arduinoContext.boardDetails.buildProperties["runtime.tools.pqt-python3.path"] !== undefined) {
|
||||||
python3 = arduinoContext.compileSummary?.buildProperties["runtime.tools.pqt-python3.path"] + "/" + python3;
|
python3 = arduinoContext.boardDetails.buildProperties["runtime.tools.pqt-python3.path"] + "/" + python3;
|
||||||
} // OTW, assume it's in the path is best we can do
|
} // OTW, assume it's in the path is best we can do
|
||||||
if (arduinoContext.compileSummary?.buildProperties["runtime.os"].includes("windows")) {
|
|
||||||
python3 = python3 + ".exe";
|
|
||||||
}
|
|
||||||
|
|
||||||
let uf2conv = "tools/uf2conv.py";
|
let uf2conv = "tools/uf2conv.py";
|
||||||
if (arduinoContext.compileSummary?.buildProperties["runtime.platform.path"] !== undefined) {
|
if (arduinoContext.boardDetails.buildProperties["runtime.platform.path"] !== undefined) {
|
||||||
uf2conv = arduinoContext.compileSummary?.buildProperties["runtime.platform.path"] + "/" + uf2conv;
|
uf2conv = arduinoContext.boardDetails.buildProperties["runtime.platform.path"] + "/" + uf2conv;
|
||||||
} // OTW, assume it's in the path is best we can do
|
} // OTW, assume it's in the path is best we can do
|
||||||
|
|
||||||
let dataFolder = arduinoContext.sketchPath + "/data";
|
let dataFolder = arduinoContext.sketchPath + "/data";
|
||||||
@ -87,14 +84,14 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
imageFile = arduinoContext.compileSummary?.buildPath + imageFile;
|
imageFile = arduinoContext.compileSummary?.buildPath + imageFile;
|
||||||
}
|
}
|
||||||
imageFile = imageFile + ".mklittlefs.bin";
|
imageFile = imageFile + ".mklittlefs.bin";
|
||||||
let buildCmd = ["-c", dataFolder, "-p", String(page), "-b", String(blocksize), "-s", String(fsEnd - fsStart), imageFile];
|
let buildOpts = ["-c", dataFolder, "-p", String(page), "-b", String(blocksize), "-s", String(fsEnd - fsStart), imageFile];
|
||||||
let uploadCmd = [uf2conv, "--base", String(fsStart), "--serial", serialPort, "--family", "RP2040", imageFile];
|
let uploadOpts = [uf2conv, "--base", String(fsStart), "--serial", serialPort, "--family", "RP2040", imageFile];
|
||||||
|
|
||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
console.log("Building the file system image: " + mklittlefs + " " + buildCmd.join(" "));
|
console.log("Building the file system image: " + mklittlefs + " " + buildOpts.join(" "));
|
||||||
spawnSync(mklittlefs, buildCmd);
|
spawnSync(mklittlefs, buildOpts);
|
||||||
console.log("Uploading the file system image: " + python3 + " " + uploadCmd.join(" "));
|
console.log("Uploading the file system image: " + python3 + " " + uploadOpts.join(" "));
|
||||||
spawnSync(python3, uploadCmd);
|
spawnSync(python3, uploadOpts);
|
||||||
console.log("Completed upload");
|
console.log("Completed upload");
|
||||||
vscode.window.showInformationMessage("LittleFS upload completed!");
|
vscode.window.showInformationMessage("LittleFS upload completed!");
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user