Skip to content

Allow OTA uploads #66

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "arduino-littlefs-upload",
"displayName": "arduino-littlefs-upload",
"description": "Build and uploads LittleFS filesystems for the Arduino-Pico RP2040 core, ESP8266 core, or ESP32 core under Arduino IDE 2.2.1 or higher",
"version": "1.4.0",
"version": "1.5.0",
"engines": {
"vscode": "^1.82.0"
},
Expand Down
90 changes: 63 additions & 27 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ export function activate(context: vscode.ExtensionContext) {
writeEmitter.fire(red("\r\n\r\nERROR: mklittlefs not found!\r\n" + resetStyle));
}

// TBD - add non-serial UF2 upload via OpenOCD
let network = false;
let networkPort = 0;
let serialPort = "";
if (uploadmethod === "picotool") {
serialPort = "picotool";
Expand All @@ -383,10 +384,20 @@ export function activate(context: vscode.ExtensionContext) {
} else {
serialPort = arduinoContext.port?.address;
}
//if (arduinoContext.port?.protocol !== "serial") {
// writeEmitter.fire(red("\r\n\r\nERROR: Only serial port upload supported at this time.\r\n"));
// return;
//}
if (arduinoContext.port?.protocol === "network") {
if (!arduinoContext.port?.properties.port) {
writeEmitter.fire(red("\r\n\r\nERROR: Network upload but port specified, check IDE menus.\r\n"));
return;
}
networkPort = Number(arduinoContext.port?.properties.port);
network = true;
writeEmitter.fire(blue("Network Info: ") + green(serialPort + ":" + String(networkPort)) + "\r\n");
} else if (arduinoContext.port?.protocol === "serial") {
writeEmitter.fire(blue(" Serial Port: ") + green(serialPort) + "\r\n");
} else {
writeEmitter.fire(red("\r\n\r\nERROR: Unknown upload method '" + String(arduinoContext.port?.properties.port) + "' specified, check IDE menus.\r\n"));
return;
}

let python3 = "python3" + ext;
let python3Path = undefined;
Expand Down Expand Up @@ -467,33 +478,58 @@ export function activate(context: vscode.ExtensionContext) {
uploadOpts = ["-f", "interface/cmsis-dap.cfg", "-f", "target/" + chip +".cfg", "-s", openocdPath + "/share/openocd/scripts",
"-c", "init; adapter speed 5000; program "+ imageFile + " verify 0x" + fsStart.toString(16) + "; reset; exit"];
} else {
let uf2conv = "tools" + path.sep + "uf2conv.py";
let uf2Path = findTool(arduinoContext, "runtime.platform.path");
if (uf2Path) {
uf2conv = uf2Path + path.sep + uf2conv;
}
if (conversion) {
uploadOpts = [uf2conv, "--serial", serialPort, "--family", "RP2040", imageFile + ".uf2", "--deploy"];
if (network) {
let espota = "tools" + path.sep + "espota.py";
let espotaPath = findTool(arduinoContext, "runtime.platform.path");
if (espotaPath) {
espota = espotaPath + path.sep + espota;
}
uploadOpts = ["-I", espota, "-i", serialPort, "-p", String(networkPort), "-f", imageFile, "-s"];
} else {
uploadOpts = [uf2conv, "--base", String(fsStart), "--serial", serialPort, "--family", "RP2040", imageFile];
let uf2conv = "tools" + path.sep + "uf2conv.py";
let uf2Path = findTool(arduinoContext, "runtime.platform.path");
if (uf2Path) {
uf2conv = uf2Path + path.sep + uf2conv;
}
if (conversion) {
uploadOpts = [uf2conv, "--serial", serialPort, "--family", "RP2040", imageFile + ".uf2", "--deploy"];
} else {
uploadOpts = [uf2conv, "--base", String(fsStart), "--serial", serialPort, "--family", "RP2040", imageFile];
}
}
}
} else if (esp32) {
let flashMode = arduinoContext.boardDetails.buildProperties["build.flash_mode"];
let flashFreq = arduinoContext.boardDetails.buildProperties["build.flash_freq"];
let espTool = "esptool" + extEspTool;
let espToolPath = findTool(arduinoContext, "runtime.tools.esptool_py.path");
if (espToolPath) {
espTool = espToolPath + path.sep + espTool;
}
uploadOpts = ["--chip", esp32variant, "--port", serialPort, "--baud", String(uploadSpeed),
"--before", "default_reset", "--after", "hard_reset", "write_flash", "-z",
"--flash_mode", flashMode, "--flash_freq", flashFreq, "--flash_size", "detect", String(fsStart), imageFile];
if ((platform() === 'win32') || (platform() === 'darwin')) {
cmdApp = espTool; // Have binary EXE on Mac/Windows
if (network) {
let espota = "tools" + path.sep + "espota.py";
let espotaPath = findTool(arduinoContext, "runtime.platform.path");
if (espotaPath) {
espota = espotaPath + path.sep + espota;
}
uploadOpts = ["-r", "-i", serialPort, "-p", String(networkPort), "-f", imageFile, "-s"];

if ((platform() === 'win32') || (platform() === 'darwin')) {
cmdApp = espota; // Have binary EXE on Mac/Windows
} else {
cmdApp = "python3"; // Not shipped, assumed installed on Linux
uploadOpts.unshift(espota); // Need to call Python3
}
} else {
cmdApp = "python3"; // Not shipped, assumed installed on Linux
uploadOpts.unshift(espTool); // Need to call Python3
let flashMode = arduinoContext.boardDetails.buildProperties["build.flash_mode"];
let flashFreq = arduinoContext.boardDetails.buildProperties["build.flash_freq"];
let espTool = "esptool" + extEspTool;
let espToolPath = findTool(arduinoContext, "runtime.tools.esptool_py.path");
if (espToolPath) {
espTool = espToolPath + path.sep + espTool;
}
uploadOpts = ["--chip", esp32variant, "--port", serialPort, "--baud", String(uploadSpeed),
"--before", "default_reset", "--after", "hard_reset", "write_flash", "-z",
"--flash_mode", flashMode, "--flash_freq", flashFreq, "--flash_size", "detect", String(fsStart), imageFile];
if ((platform() === 'win32') || (platform() === 'darwin')) {
cmdApp = espTool; // Have binary EXE on Mac/Windows
} else {
cmdApp = "python3"; // Not shipped, assumed installed on Linux
uploadOpts.unshift(espTool); // Need to call Python3
}
}
} else { // esp8266
let upload = "tools" + path.sep + "upload.py";
Expand Down