@@ -41,16 +41,21 @@ func Run(ctx context.Context) {
41
41
42
42
var err error
43
43
44
- if strings .Contains (filepath .Base (ctx .ProgrammerPath ), "bossac" ) {
45
- programmer = & bossac.Bossac {}
46
- } else if strings .Contains (filepath .Base (ctx .ProgrammerPath ), "avrdude" ) {
47
- programmer = & avrdude.Avrdude {}
48
- } else {
49
- log .Fatal ("Programmer path not specified correctly, programmer path set to: " + ctx .ProgrammerPath )
44
+ if ctx .ProgrammerPath != "" {
45
+ if strings .Contains (filepath .Base (ctx .ProgrammerPath ), "bossac" ) {
46
+ programmer = & bossac.Bossac {}
47
+ } else if strings .Contains (filepath .Base (ctx .ProgrammerPath ), "avrdude" ) {
48
+ programmer = & avrdude.Avrdude {}
49
+ } else {
50
+ log .Fatal ("Programmer path not specified correctly, programmer path set to: " + ctx .ProgrammerPath )
51
+ }
50
52
}
51
53
52
54
if ctx .FWUploaderBinary != "" {
53
55
log .Println ("Flashing firmware uploader nina" )
56
+ if programmer == nil {
57
+ log .Fatal ("ERROR: You must specify a programmer!" )
58
+ }
54
59
if ctx .BinaryToRestore == "" {
55
60
ctx .BinaryToRestore , err = programmer .DumpAndFlash (& ctx , ctx .FWUploaderBinary )
56
61
} else {
@@ -107,9 +112,12 @@ func Run(ctx context.Context) {
107
112
}
108
113
109
114
if ctx .BinaryToRestore != "" {
110
- log .Println ("Restoring previous sketch" )
111
115
f .Close ()
112
116
117
+ log .Println ("Restoring previous sketch" )
118
+ if programmer == nil {
119
+ log .Fatal ("ERROR: You must specify a programmer!" )
120
+ }
113
121
if err := programmer .Flash (& ctx , ctx .BinaryToRestore ); err != nil {
114
122
log .Fatal (err )
115
123
}
0 commit comments