Skip to content

Commit c42b971

Browse files
committed
"keep" as default FlashMode and FlashFreq (possible since esptool v2) (fixes kash4kev#2)
1 parent efa1f80 commit c42b971

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

esp8266fs.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,20 @@ function _getTarget(arduinJson, preferences) {
478478

479479
//------------------------------------------------------------------------------
480480

481-
function getPreference(arduinoJson, preferences, index) {
481+
function getPreference(arduinoJson, preferences, index, defval) {
482+
482483
if (arduinoJson.hasOwnProperty(index))
483484
return arduinoJson[index];
484485

485486
const value = preferences["custom_" + index];
486487

487-
if (!value)
488-
throw `Can't determine ${index}.`;
488+
if (!value) {
489+
if (defval != undefined) {
490+
return defval;
491+
} else {
492+
throw `Can't determine ${index}.`;
493+
}
494+
}
489495

490496
const match = value.match(/^(${target.board}|generic)_(\S+)/);
491497

@@ -501,8 +507,8 @@ function getTarget(arduinoJson, preferences) {
501507
throw `Current Arduino package/architecture is not ESP8266 or ESP32.`;
502508

503509
target.flashSize = getPreference(arduinoJson, preferences, "FlashSize");
504-
target.flashMode = getPreference(arduinoJson, preferences, "FlashMode");
505-
target.flashFreq = getPreference(arduinoJson, preferences, "FlashFreq");
510+
target.flashMode = getPreference(arduinoJson, preferences, "FlashMode", "keep");
511+
target.flashFreq = getPreference(arduinoJson, preferences, "FlashFreq", "keep");
506512

507513
logDebug(`target:`);
508514
JSONify(target).split("\n").map(line => logDebug(line));

0 commit comments

Comments
 (0)