From c42b97187072001ad48d4feacd1f19af5e412fbe Mon Sep 17 00:00:00 2001 From: maciekn Date: Sat, 9 Mar 2019 13:51:05 +0100 Subject: [PATCH 1/3] "keep" as default FlashMode and FlashFreq (possible since esptool v2) (fixes #2) --- esp8266fs.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/esp8266fs.js b/esp8266fs.js index 62943ab..a00f106 100644 --- a/esp8266fs.js +++ b/esp8266fs.js @@ -478,14 +478,20 @@ function _getTarget(arduinJson, preferences) { //------------------------------------------------------------------------------ -function getPreference(arduinoJson, preferences, index) { +function getPreference(arduinoJson, preferences, index, defval) { + if (arduinoJson.hasOwnProperty(index)) return arduinoJson[index]; const value = preferences["custom_" + index]; - if (!value) - throw `Can't determine ${index}.`; + if (!value) { + if (defval != undefined) { + return defval; + } else { + throw `Can't determine ${index}.`; + } + } const match = value.match(/^(${target.board}|generic)_(\S+)/); @@ -501,8 +507,8 @@ function getTarget(arduinoJson, preferences) { throw `Current Arduino package/architecture is not ESP8266 or ESP32.`; target.flashSize = getPreference(arduinoJson, preferences, "FlashSize"); - target.flashMode = getPreference(arduinoJson, preferences, "FlashMode"); - target.flashFreq = getPreference(arduinoJson, preferences, "FlashFreq"); + target.flashMode = getPreference(arduinoJson, preferences, "FlashMode", "keep"); + target.flashFreq = getPreference(arduinoJson, preferences, "FlashFreq", "keep"); logDebug(`target:`); JSONify(target).split("\n").map(line => logDebug(line)); From 747729d64d8879b94c2ae61f5dfd22c381dc0cec Mon Sep 17 00:00:00 2001 From: maciekn Date: Sat, 9 Mar 2019 13:53:38 +0100 Subject: [PATCH 2/3] Change `FlashSize` to `eesz` as per breaking change described in https://github.com/esp8266/Arduino/issues/5572 (fixes #8) --- esp8266fs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp8266fs.js b/esp8266fs.js index a00f106..e25e077 100644 --- a/esp8266fs.js +++ b/esp8266fs.js @@ -506,7 +506,7 @@ function getTarget(arduinoJson, preferences) { if (!["esp8266", "esp32"].includes(target.architecture)) throw `Current Arduino package/architecture is not ESP8266 or ESP32.`; - target.flashSize = getPreference(arduinoJson, preferences, "FlashSize"); + target.flashSize = getPreference(arduinoJson, preferences, "eesz"); target.flashMode = getPreference(arduinoJson, preferences, "FlashMode", "keep"); target.flashFreq = getPreference(arduinoJson, preferences, "FlashFreq", "keep"); @@ -580,7 +580,7 @@ function getSpiffsOptions(packagesPath, target, arduinoJson, preferences) { readLines(path.join(packagesPath, "boards.txt")) .forEach(line => { const match = line.match(`${target.board}\\.(?:build|upload)\\.(\\S+)=(\\S+)`) - || line.match(`${target.board}\\.menu\\.FlashSize\\.${target.flashSize}\\.(?:build|upload)\\.(\\S+)=(\\S+)`) + || line.match(`${target.board}\\.menu\\.eesz\\.${target.flashSize}\\.(?:build|upload)\\.(\\S+)=(\\S+)`) || line.match(`${target.board}\\.menu\\.PartitionScheme\\.${arduinoJson.PartitionScheme}\\.(?:build|upload)\\.(\\S+)=(\\S+)`); if (match) From b6b77e1bcb1337aa3a0e0031126a42ba729ca113 Mon Sep 17 00:00:00 2001 From: maciekn Date: Wed, 13 Mar 2019 17:41:04 +0100 Subject: [PATCH 3/3] Change `UploadSpeed` to `baud` as per breaking change described in https://github.com/esp8266/Arduino/issues/5572 --- esp8266fs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp8266fs.js b/esp8266fs.js index e25e077..49f41e7 100644 --- a/esp8266fs.js +++ b/esp8266fs.js @@ -616,8 +616,8 @@ function getSpiffsOptions(packagesPath, target, arduinoJson, preferences) { spiffsOptions.flashFreq = preferences.flash_freq; spiffsOptions.flashSize = "0x" + toHex(stringToInt(spiffsOptions.spiffs_start) + stringToInt(spiffsOptions.dataSize)); - if (arduinoJson.UploadSpeed) - spiffsOptions.speed = arduinoJson.UploadSpeed; + if (arduinoJson.baud) + spiffsOptions.speed = arduinoJson.baud; if (arduinoJson.ResetMethod) spiffsOptions.resetmethod = arduinoJson.ResetMethod;