From 4c74c4c34517dc32510bf231be27654884373ecb Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Wed, 1 Jan 2025 10:39:29 -0800 Subject: [PATCH] ESP32 Arduino now ships binary esptool under Linux (#77) Sometimes we'll have a PY, sometimes we'll have an ELF. Use hueristics to pick the right version at runtime. Fixes #76 --- package.json | 2 +- src/extension.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 79e9b33..3990b46 100644 --- a/package.json +++ b/package.json @@ -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.5.2", + "version": "1.5.3", "engines": { "vscode": "^1.82.0" }, diff --git a/src/extension.ts b/src/extension.ts index ea76883..19ad749 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -516,7 +516,7 @@ export function activate(context: vscode.ExtensionContext) { } else { let flashMode = arduinoContext.boardDetails.buildProperties["build.flash_mode"]; let flashFreq = arduinoContext.boardDetails.buildProperties["build.flash_freq"]; - let espTool = "esptool" + extEspTool; + let espTool = "esptool"; let espToolPath = findTool(arduinoContext, "runtime.tools.esptool_py.path"); if (espToolPath) { espTool = espToolPath + path.sep + espTool; @@ -525,10 +525,16 @@ export function activate(context: vscode.ExtensionContext) { "--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 + cmdApp = espTool + extEspTool; // Have binary EXE on Mac/Windows } else { - cmdApp = "python3"; // Not shipped, assumed installed on Linux - uploadOpts.unshift(espTool); // Need to call Python3 + // Sometimes they give a .py, sometimes they give a precompiled binary + // If there's a .py we'll use that one, OTW hope there's a binary one + if (fs.existsSync(espTool + extEspTool)) { + cmdApp = "python3"; // Not shipped, assumed installed on Linux + uploadOpts.unshift(espTool + extEspTool); // Need to call Python3 + } else { + cmdApp = espTool; // Binary without extension + } } } } else { // esp8266