Line 0
Link Here
|
|
|
1 |
--- src/bossac.cpp.orig 2017-03-31 15:31:35 UTC |
2 |
+++ src/bossac.cpp |
3 |
@@ -64,6 +64,7 @@ class BossaConfig (public) |
4 |
bool help; |
5 |
bool forceUsb; |
6 |
string forceUsbArg; |
7 |
+ bool arduinoErase; |
8 |
|
9 |
int readArg; |
10 |
string portArg; |
11 |
@@ -89,6 +90,7 @@ BossaConfig::BossaConfig() |
12 |
info = false; |
13 |
help = false; |
14 |
forceUsb = false; |
15 |
+ arduinoErase = false; |
16 |
|
17 |
readArg = 0; |
18 |
bootArg = 1; |
19 |
@@ -189,6 +191,11 @@ static Option opts[] = |
20 |
'R', "reset", &config.reset, |
21 |
{ ArgNone }, |
22 |
"reset CPU (if supported)" |
23 |
+ }, |
24 |
+ { |
25 |
+ 'a', "arduino_erase", &config.arduinoErase, |
26 |
+ { ArgNone }, |
27 |
+ "erase and reset via Arduino 1200 baud hack (cannot be used with port autodetection)" |
28 |
} |
29 |
}; |
30 |
|
31 |
@@ -257,6 +264,12 @@ main(int argc, char* argv[]) |
32 |
return help(argv[0]); |
33 |
} |
34 |
|
35 |
+ if (config.arduinoErase && !config.port) |
36 |
+ { |
37 |
+ fprintf(stderr, "%s: port must be specified for Arduino 1200bps erase hack\n", argv[0]); |
38 |
+ return help(argv[0]); |
39 |
+ } |
40 |
+ |
41 |
if (config.read || config.write || config.verify) |
42 |
{ |
43 |
if (args == argc) |
44 |
@@ -311,6 +324,25 @@ main(int argc, char* argv[]) |
45 |
fprintf(stderr, "Invalid USB value: %s\n", config.forceUsbArg.c_str()); |
46 |
return 1; |
47 |
} |
48 |
+ } |
49 |
+ |
50 |
+ if (config.arduinoErase) |
51 |
+ { |
52 |
+ SerialPort::Ptr port; |
53 |
+ if (config.forceUsb) |
54 |
+ port = portFactory.create(config.portArg, isUsb); |
55 |
+ else |
56 |
+ port = portFactory.create(config.portArg); |
57 |
+ |
58 |
+ if(!port->open(1200)) |
59 |
+ { |
60 |
+ fprintf(stderr, "Failed to open port at 1200bps\n"); |
61 |
+ return 1; |
62 |
+ } |
63 |
+ |
64 |
+ port->setRTS(true); |
65 |
+ port->setDTR(false); |
66 |
+ port->close(); |
67 |
} |
68 |
|
69 |
if (config.port) |