Skip to content

Commit 9f8cd62

Browse files
author
jantje
committed
#1322 ESP32 ATO upload should be fine now
Also added 2 regression tests checking the upload pattern key
1 parent 2adae74 commit 9f8cd62

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ public IPath getReferencingLibraryPath() {
658658
return this.getreferencingPlatformPath().append(LIBRARY_PATH_SUFFIX);
659659
}
660660

661-
public String getUploadCommand(ICConfigurationDescription confdesc) {
661+
public String getUploadPatternKey() {
662662
updateWhenDirty();
663663
String upLoadTool = getActualUploadTool();
664664
String action = UPLOAD;
@@ -667,14 +667,10 @@ public String getUploadCommand(ICConfigurationDescription confdesc) {
667667
}
668668
String networkPrefix = EMPTY;
669669
if (isNetworkUpload()) {
670-
networkPrefix = DOT + NETWORK_PREFIX;
670+
networkPrefix = NETWORK_PREFIX;
671671
}
672-
String key = TOOLS + DOT + upLoadTool + DOT + action + networkPrefix + DOT + PATTERN;
673-
String ret = Common.getBuildEnvironmentVariable(confdesc, key, EMPTY);
674-
if (ret.isEmpty()) {
675-
Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, key + " : not found in the platform.txt file")); //$NON-NLS-1$
676-
}
677-
return ret;
672+
return TOOLS + DOT + upLoadTool + DOT + action + DOT + networkPrefix + PATTERN;
673+
678674
}
679675

680676
public String getActualUploadTool() {

io.sloeber.core/src/io/sloeber/core/tools/uploaders/arduinoUploader.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ public boolean uploadUsingPreferences(IFile hexFile, BoardDescription boardDescr
5151
} else {
5252
uploadPort = ArduinoSerial.makeArduinoUploadready(highStream, this.myProject, mycConf, boardDescr);
5353
}
54-
55-
String command = boardDescr.getUploadCommand(mycConf);
56-
if (command == null) {
54+
String uploadRecipoeKey = boardDescr.getUploadPatternKey();
55+
String command = Common.getBuildEnvironmentVariable(mycConf, uploadRecipoeKey, EMPTY);
56+
if (command.isEmpty()) {
57+
Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
58+
uploadRecipoeKey + " : not found in the platform.txt file")); //$NON-NLS-1$
5759
highStream.println(Messages.uploader_Failed_to_get_upload_recipe);
5860
return false;
5961
}

io.sloeber.tests/src/io/sloeber/core/RegressionTest.java

+21-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.sloeber.core.api.Preferences;
3131
import io.sloeber.core.api.SloeberProject;
3232
import io.sloeber.providers.Arduino;
33+
import io.sloeber.providers.ESP32;
3334
import io.sloeber.providers.ESP8266;
3435
import io.sloeber.providers.MCUBoard;
3536
import io.sloeber.providers.Teensy;
@@ -52,14 +53,15 @@ public static void WaitForInstallerToFinish() {
5253

5354
public static void installAdditionalBoards() {
5455

55-
String[] packageUrlsToAdd = { ESP8266.packageURL };
56+
String[] packageUrlsToAdd = { ESP8266.packageURL, ESP32.packageURL };
5657
PackageManager.addPackageURLs(new HashSet<>(Arrays.asList(packageUrlsToAdd)), true);
5758
if (reinstall_boards_and_libraries) {
5859
PackageManager.removeAllInstalledPlatforms();
5960
}
6061
;
6162
// make sure the needed boards are available
6263
ESP8266.installLatest();
64+
ESP32.installLatest();
6365
Arduino.installLatestAVRBoards();
6466

6567
if (!MySystem.getTeensyPlatform().isEmpty()) {
@@ -567,4 +569,22 @@ static CompileDescription getBunkersCompileDescription() {
567569
inCompileDescription.setWarningLevel(false);
568570
return inCompileDescription;
569571
}
572+
573+
/**
574+
* check to see whether upload recipe key is correct for a couple of boards that
575+
* have failed in the past
576+
*
577+
* @throws Exception
578+
*/
579+
@Test
580+
public void uploadPattern() throws Exception {
581+
BoardDescription boardDescriptor = Arduino.uno().getBoardDescriptor();
582+
String recipeKey = boardDescriptor.getUploadPatternKey();
583+
assertEquals("uno upload recipe key is wrong", "tools.avrdude.upload.pattern", recipeKey);
584+
boardDescriptor = ESP32.esp32().getBoardDescriptor();
585+
boardDescriptor.setUploadPort("host 10.10.10.10");
586+
recipeKey = boardDescriptor.getUploadPatternKey();
587+
assertEquals("ESP OTA upload recipe key is wrong", "tools.esptool_py.upload.network_pattern", recipeKey);
588+
589+
}
570590
}

io.sloeber.tests/src/io/sloeber/providers/ESP32.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.sloeber.providers;
22

3-
import static org.junit.Assert.fail;
3+
import static org.junit.Assert.*;
44

55
import java.util.Map;
66
import java.util.TreeMap;
@@ -10,7 +10,7 @@
1010
@SuppressWarnings("nls")
1111
public class ESP32 extends MCUBoard {
1212
private static final String provider = "esp32";
13-
private static final String architectureName = "esp23";
13+
private static final String architectureName = "esp32";
1414
private static final String jsonFileName ="package_esp32_index.json";
1515
public static final String packageURL ="https://dl.espressif.com/dl/package_esp32_index.json";
1616
public static final String esp32ID ="esp32";

0 commit comments

Comments
 (0)