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
|
||||
let disposable = vscode.commands.registerCommand('pico-littlefs-upload.uploadLittleFS', () => {
|
||||
// let str = JSON.stringify(arduinoContext, null, 4);
|
||||
// console.log(str);
|
||||
//let str = JSON.stringify(arduinoContext, null, 4);
|
||||
//console.log(str);
|
||||
|
||||
if ((arduinoContext.boardDetails === undefined) || (arduinoContext.fqbn === undefined)){
|
||||
vscode.window.showErrorMessage("Board details not available. Compile the sketch once.");
|
||||
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");
|
||||
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;
|
||||
@ -45,13 +46,12 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
let mklittlefs = "mklittlefs";
|
||||
if (arduinoContext.compileSummary?.buildProperties["runtime.os"].includes("windows")) {
|
||||
mklittlefs = mklittlefs + ".exe";
|
||||
}
|
||||
// Windows exes need ".exe" suffix
|
||||
let ext = (platform() === 'win32') ? ".exe" : "";
|
||||
let mklittlefs = "mklittlefs" + ext;
|
||||
|
||||
if (arduinoContext.compileSummary?.buildProperties["runtime.tools.pqt-mklittlefs.path"] !== undefined) {
|
||||
mklittlefs = arduinoContext.compileSummary?.buildProperties["runtime.tools.pqt-mklittlefs.path"] + "/" + mklittlefs;
|
||||
if (arduinoContext.boardDetails.buildProperties["runtime.tools.pqt-mklittlefs.path"] !== undefined) {
|
||||
mklittlefs = arduinoContext.boardDetails.buildProperties["runtime.tools.pqt-mklittlefs.path"] + "/" + mklittlefs;
|
||||
} // OTW, assume it's in the path is best we can do
|
||||
|
||||
// TBD - add non-serial UF2 upload via OpenOCD
|
||||
@ -67,17 +67,14 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
let python3 = "python3";
|
||||
if (arduinoContext.compileSummary?.buildProperties["runtime.tools.pqt-python3.path"] !== undefined) {
|
||||
python3 = arduinoContext.compileSummary?.buildProperties["runtime.tools.pqt-python3.path"] + "/" + python3;
|
||||
let python3 = "python3" + ext;
|
||||
if (arduinoContext.boardDetails.buildProperties["runtime.tools.pqt-python3.path"] !== undefined) {
|
||||
python3 = arduinoContext.boardDetails.buildProperties["runtime.tools.pqt-python3.path"] + "/" + python3;
|
||||
} // 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";
|
||||
if (arduinoContext.compileSummary?.buildProperties["runtime.platform.path"] !== undefined) {
|
||||
uf2conv = arduinoContext.compileSummary?.buildProperties["runtime.platform.path"] + "/" + uf2conv;
|
||||
if (arduinoContext.boardDetails.buildProperties["runtime.platform.path"] !== undefined) {
|
||||
uf2conv = arduinoContext.boardDetails.buildProperties["runtime.platform.path"] + "/" + uf2conv;
|
||||
} // OTW, assume it's in the path is best we can do
|
||||
|
||||
let dataFolder = arduinoContext.sketchPath + "/data";
|
||||
@ -87,14 +84,14 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
imageFile = arduinoContext.compileSummary?.buildPath + imageFile;
|
||||
}
|
||||
imageFile = imageFile + ".mklittlefs.bin";
|
||||
let buildCmd = ["-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 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];
|
||||
|
||||
const { spawnSync } = require('child_process');
|
||||
console.log("Building the file system image: " + mklittlefs + " " + buildCmd.join(" "));
|
||||
spawnSync(mklittlefs, buildCmd);
|
||||
console.log("Uploading the file system image: " + python3 + " " + uploadCmd.join(" "));
|
||||
spawnSync(python3, uploadCmd);
|
||||
console.log("Building the file system image: " + mklittlefs + " " + buildOpts.join(" "));
|
||||
spawnSync(mklittlefs, buildOpts);
|
||||
console.log("Uploading the file system image: " + python3 + " " + uploadOpts.join(" "));
|
||||
spawnSync(python3, uploadOpts);
|
||||
console.log("Completed upload");
|
||||
vscode.window.showInformationMessage("LittleFS upload completed!");
|
||||
});
|
||||
|
Reference in New Issue
Block a user