Skip to content

Commit 88e8019

Browse files
author
Federico Fissore
committed
Extending remote upload. Sketch merge with bootloader is done by the IDE (using "noblink" bootloader if board definition provides one). If platform provides a "remote" upload tool, that tool is used, otherwise falls back to hardcoded "run-avrdude"
1 parent 1f8c964 commit 88e8019

File tree

14 files changed

+662
-89
lines changed

14 files changed

+662
-89
lines changed

app/build.xml

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
<fileset dir="test" includes="**/*.ino" />
102102
<fileset dir="test" includes="**/*.json*" />
103103
<fileset dir="test" includes="**/*.key" />
104+
<fileset dir="test" includes="**/*.hex" />
104105
</copy>
105106

106107
<junit printsummary="yes" dir="${work.dir}" fork="true">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Arduino is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
* As a special exception, you may use this file as part of a free software
19+
* library without restriction. Specifically, if other files instantiate
20+
* templates or use macros or inline functions from this file, or you compile
21+
* this file and link it with other files to produce an executable, this
22+
* file does not by itself cause the resulting executable to be covered by
23+
* the GNU General Public License. This exception does not however
24+
* invalidate any other reasons why the executable file might be covered by
25+
* the GNU General Public License.
26+
*
27+
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
28+
*/
29+
30+
package cc.arduino.packages.uploaders;
31+
32+
import org.junit.After;
33+
import org.junit.Before;
34+
import org.junit.Test;
35+
import processing.app.helpers.FileUtils;
36+
37+
import java.io.File;
38+
39+
import static org.junit.Assert.assertEquals;
40+
41+
public class MergeSketchWithUploaderTest {
42+
43+
private File sketch;
44+
45+
@Before
46+
public void setup() throws Exception {
47+
File originalSketch = new File(MergeSketchWithUploaderTest.class.getResource("/sketch.hex").getFile());
48+
sketch = new File(System.getProperty("java.io.tmpdir"), "sketch.hex");
49+
FileUtils.copyFile(originalSketch, sketch);
50+
}
51+
52+
@After
53+
public void removeTmpFile() {
54+
sketch.delete();
55+
}
56+
57+
@Test
58+
public void shouldMergeWithOptiboot() throws Exception {
59+
assertEquals(11720, sketch.length());
60+
61+
File bootloader = new File(MergeSketchWithUploaderTest.class.getResource("/optiboot_atmega328.hex").getFile());
62+
new MergeSketchWithBooloader().merge(sketch, bootloader);
63+
assertEquals(13140, sketch.length());
64+
}
65+
66+
67+
}

app/test/optiboot_atmega328.hex

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
:107E0000112484B714BE81FFF0D085E080938100F7
2+
:107E100082E08093C00088E18093C10086E0809377
3+
:107E2000C20080E18093C4008EE0C9D0259A86E02C
4+
:107E300020E33CEF91E0309385002093840096BBD3
5+
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
6+
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
7+
:107E6000A2D0813461F49FD0082FAFD0023811F036
8+
:107E7000013811F484E001C083E08DD089C08234E0
9+
:107E800011F484E103C0853419F485E0A6D080C0E4
10+
:107E9000853579F488D0E82EFF2485D0082F10E0AE
11+
:107EA000102F00270E291F29000F111F8ED06801E7
12+
:107EB0006FC0863521F484E090D080E0DECF843638
13+
:107EC00009F040C070D06FD0082F6DD080E0C81688
14+
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
15+
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
16+
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
17+
:107F0000A601A0E0B1E02C9130E011968C91119780
18+
:107F100090E0982F8827822B932B1296FA010C0160
19+
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
20+
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
21+
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
22+
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
23+
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
24+
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
25+
:107F80000AD08FE07ACF813511F488E018D01DD067
26+
:107F900080E101D065CF982F8091C00085FFFCCF94
27+
:107FA0009093C60008958091C00087FFFCCF809118
28+
:107FB000C00084FD01C0A8958091C6000895E0E648
29+
:107FC000F0E098E1908380830895EDDF803219F02E
30+
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
31+
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
32+
:047FF000FF270994CA
33+
:027FFE00040479
34+
:0400000300007E007B
35+
:00000001FF

app/test/processing/app/debug/UploaderFactoryTest.java

-16
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
4747
@Test
4848
public void shouldCreateAnInstanceOfSSHUploader() throws Exception {
4949
TargetBoard board = new LegacyTargetBoard("yun", new PreferencesMap(new HashMap<String, String>()), new TargetPlatformStub("id", new TargetPackageStub("id")));
50-
board.getPreferences().put("upload.via_ssh", "true");
5150

5251
BoardPort boardPort = new BoardPort();
5352
boardPort.setBoardName("yun");
@@ -58,24 +57,9 @@ public void shouldCreateAnInstanceOfSSHUploader() throws Exception {
5857
assertTrue(uploader instanceof SSHUploader);
5958
}
6059

61-
@Test
62-
public void shouldCreateAnInstanceOfBasicUploaderWhenSSHIsUnsupported() throws Exception {
63-
TargetBoard board = new LegacyTargetBoard("uno", new PreferencesMap(new HashMap<String, String>()), new TargetPlatformStub("id", new TargetPackageStub("id")));
64-
board.getPreferences().put("upload.via_ssh", "false");
65-
66-
BoardPort boardPort = new BoardPort();
67-
boardPort.setBoardName("myyun");
68-
boardPort.setAddress("192.168.0.1");
69-
boardPort.setProtocol("network");
70-
Uploader uploader = new UploaderFactory().newUploader(board, boardPort, false);
71-
72-
assertTrue(uploader instanceof SerialUploader);
73-
}
74-
7560
@Test
7661
public void shouldCreateAnInstanceOfBasicUploaderWhenPortIsSerial() throws Exception {
7762
TargetBoard board = new LegacyTargetBoard("uno", new PreferencesMap(new HashMap<String, String>()), new TargetPlatformStub("id", new TargetPackageStub("id")));
78-
board.getPreferences().put("upload.via_ssh", "false");
7963

8064
BoardPort boardPort = new BoardPort();
8165
boardPort.setBoardName("Arduino Leonardo");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Arduino is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
* As a special exception, you may use this file as part of a free software
19+
* library without restriction. Specifically, if other files instantiate
20+
* templates or use macros or inline functions from this file, or you compile
21+
* this file and link it with other files to produce an executable, this
22+
* file does not by itself cause the resulting executable to be covered by
23+
* the GNU General Public License. This exception does not however
24+
* invalidate any other reasons why the executable file might be covered by
25+
* the GNU General Public License.
26+
*
27+
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
28+
*/
29+
30+
package processing.app.helpers;
31+
32+
import org.junit.Test;
33+
34+
import static org.junit.Assert.assertEquals;
35+
36+
public class StringUtilsTest {
37+
38+
@Test
39+
public void shouldJoinAnArray() {
40+
assertEquals("1 - 2 - 3", StringUtils.join(new String[]{"1", "2", "3"}, " - "));
41+
}
42+
}

0 commit comments

Comments
 (0)