@@ -182,18 +182,13 @@ export class OpenOCDManager extends EventEmitter {
182
182
) ;
183
183
}
184
184
185
- const openOcdArgs = [ ] ;
185
+ const openOcdArgs : string [ ] = [ ] ;
186
186
const openOcdDebugLevel = idfConf . readParameter (
187
187
"idf.openOcdDebugLevel" ,
188
188
this . workspace
189
189
) as string ;
190
190
openOcdArgs . push ( `-d${ openOcdDebugLevel } ` ) ;
191
191
192
- openOcdConfigFilesList . forEach ( ( configFile ) => {
193
- openOcdArgs . push ( "-f" ) ;
194
- openOcdArgs . push ( configFile ) ;
195
- } ) ;
196
-
197
192
const addLaunchArgs = idfConf . readParameter (
198
193
"idf.openOcdLaunchArgs" ,
199
194
this . workspace
@@ -205,6 +200,16 @@ export class OpenOCDManager extends EventEmitter {
205
200
} ) ;
206
201
}
207
202
203
+ openOcdConfigFilesList . forEach ( ( configFile ) => {
204
+ const isFileAlreadyInArgs = openOcdArgs . some ( ( arg ) =>
205
+ arg . includes ( configFile )
206
+ ) ;
207
+ if ( ! isFileAlreadyInArgs ) {
208
+ openOcdArgs . push ( "-f" ) ;
209
+ openOcdArgs . push ( configFile ) ;
210
+ }
211
+ } ) ;
212
+
208
213
this . server = spawn ( "openocd" , openOcdArgs , {
209
214
cwd : this . workspace . fsPath ,
210
215
env : modifiedEnv ,
@@ -250,7 +255,8 @@ export class OpenOCDManager extends EventEmitter {
250
255
if ( ! signal && code && code !== 0 ) {
251
256
Logger . error (
252
257
`OpenOCD Exit with non-zero error code ${ code } ` ,
253
- new Error ( "Spawn exit with non-zero" + code ) , "OpenOCDManager close"
258
+ new Error ( "Spawn exit with non-zero" + code ) ,
259
+ "OpenOCDManager close"
254
260
) ;
255
261
OutputChannel . appendLine (
256
262
`OpenOCD Exit with non-zero error code ${ code } ` ,
0 commit comments