@@ -125,6 +125,20 @@ async function runCommand(exe : string, opts : any[]) {
125
125
return exitCode ;
126
126
}
127
127
128
+ function getSelectedUploadMethod ( boardDetails : BoardDetails ) : string {
129
+ const uploadOptions = boardDetails . configOptions . find ( option => option . option === "uploadmethod" ) ;
130
+ if ( uploadOptions === undefined ) {
131
+ return "default" ;
132
+ }
133
+
134
+ const selectedOption = uploadOptions . values . find ( value => value . selected === true ) ;
135
+ if ( selectedOption === undefined ) {
136
+ return "default" ;
137
+ }
138
+
139
+ return selectedOption . value ;
140
+ }
141
+
128
142
function getSelectedPartitionScheme ( boardDetails : BoardDetails ) : string | undefined {
129
143
const partitionSchemeOptions = boardDetails . configOptions . find ( option => option . option === "PartitionScheme" ) ;
130
144
if ( partitionSchemeOptions === undefined ) {
@@ -222,13 +236,18 @@ export function activate(context: vscode.ExtensionContext) {
222
236
223
237
// Figure out what we're running on
224
238
let pico = false ;
239
+ let rp2350 = false ;
240
+ let uploadmethod = "default" ;
225
241
let esp8266 = false ;
226
242
let esp32 = false ;
227
243
let esp32variant = "" ;
228
244
switch ( arduinoContext . fqbn . split ( ':' ) [ 1 ] ) {
229
245
case "rp2040" : {
230
246
writeEmitter . fire ( blue ( " Device: " ) + green ( "RP2040 series" ) + "\r\n" ) ;
231
247
pico = true ;
248
+ rp2350 = arduinoContext . boardDetails . buildProperties [ 'build.chip' ] . startsWith ( "rp2350" ) ;
249
+ uploadmethod = getSelectedUploadMethod ( arduinoContext . boardDetails ) ;
250
+ writeEmitter . fire ( blue ( "Upload Using: " ) + green ( uploadmethod ) + "\r\n" ) ;
232
251
break ;
233
252
}
234
253
case "esp8266" : {
@@ -354,24 +373,31 @@ export function activate(context: vscode.ExtensionContext) {
354
373
355
374
// TBD - add non-serial UF2 upload via OpenOCD
356
375
let serialPort = "" ;
357
- if ( arduinoContext . port ?. address === undefined ) {
376
+ if ( uploadmethod === "picotool" ) {
377
+ serialPort = "picotool" ;
378
+ } else if ( uploadmethod === "picoprobe_cmsis_dap" ) {
379
+ serialPort = "openocd" ;
380
+ } else if ( arduinoContext . port ?. address === undefined ) {
358
381
writeEmitter . fire ( red ( "\r\n\r\nERROR: No port specified, check IDE menus.\r\n" ) ) ;
359
382
return ;
360
383
} else {
361
384
serialPort = arduinoContext . port ?. address ;
362
385
}
363
- if ( arduinoContext . port ?. protocol !== "serial" ) {
364
- writeEmitter . fire ( red ( "\r\n\r\nERROR: Only serial port upload supported at this time.\r\n" ) ) ;
365
- return ;
366
- }
386
+ // if (arduinoContext.port?.protocol !== "serial") {
387
+ // writeEmitter.fire(red("\r\n\r\nERROR: Only serial port upload supported at this time.\r\n"));
388
+ // return;
389
+ // }
367
390
368
391
let python3 = "python3" + ext ;
369
392
let python3Path = undefined ;
370
393
let picotool = "picotool" + ext ;
371
394
let picotoolPath = undefined ;
395
+ let openocd = "openocd" + ext ;
396
+ let openocdPath = undefined ;
372
397
if ( pico ) {
373
398
python3Path = findTool ( arduinoContext , "runtime.tools.pqt-python3" ) ;
374
399
picotoolPath = findTool ( arduinoContext , "runtime.tools.pqt-picotool" ) ;
400
+ openocdPath = findTool ( arduinoContext , "runtime.tools.pqt-openocd" ) ;
375
401
} else if ( esp8266 ) {
376
402
python3Path = findTool ( arduinoContext , "runtime.tools.python3" ) ;
377
403
} else if ( esp32 ) {
@@ -383,6 +409,9 @@ export function activate(context: vscode.ExtensionContext) {
383
409
if ( picotoolPath ) {
384
410
picotool = picotoolPath + path . sep + picotool ;
385
411
}
412
+ if ( openocdPath ) {
413
+ openocd = openocdPath + path . sep + "bin" + path . sep + openocd ;
414
+ }
386
415
387
416
// We can't always know where the compile path is, so just use a temp name
388
417
const tmp = require ( 'tmp' ) ;
@@ -404,7 +433,7 @@ export function activate(context: vscode.ExtensionContext) {
404
433
let conversion = false
405
434
if ( pico ) {
406
435
if ( Number ( arduinoContext . boardDetails ?. buildProperties [ 'version' ] . split ( '.' ) [ 0 ] ) > 3 ) {
407
- if ( arduinoContext . boardDetails . buildProperties [ 'build.chip' ] == " rp2350" ) {
436
+ if ( rp2350 ) {
408
437
// Pico 4.x needs a preparation stage for the RP2350
409
438
writeEmitter . fire ( bold ( "\r\n4.0 or above\r\n" ) ) ;
410
439
let picotoolOpts = [ "uf2" , "convert" , imageFile , "-t" , "bin" , imageFile + ".uf2" , "-o" , "0x" + fsStart . toString ( 16 ) , "--family" , "data" ] ;
@@ -426,15 +455,28 @@ export function activate(context: vscode.ExtensionContext) {
426
455
let uploadOpts : any [ ] = [ ] ;
427
456
let cmdApp = python3 ;
428
457
if ( pico ) {
429
- let uf2conv = "tools" + path . sep + "uf2conv.py" ;
430
- let uf2Path = findTool ( arduinoContext , "runtime.platform.path" ) ;
431
- if ( uf2Path ) {
432
- uf2conv = uf2Path + path . sep + uf2conv ;
433
- }
434
- if ( conversion ) {
435
- uploadOpts = [ uf2conv , "--serial" , serialPort , "--family" , "RP2040" , imageFile + ".uf2" , "--deploy" ] ;
458
+ if ( uploadmethod === "picotool" ) {
459
+ cmdApp = picotool ;
460
+ uploadOpts = [ "load" , imageFile , "-o" , "0x" + fsStart . toString ( 16 ) , "-f" , "-x" ] ;
461
+ } else if ( uploadmethod === "picoprobe_cmsis_dap" ) {
462
+ cmdApp = openocd ;
463
+ let chip = "rp2040" ;
464
+ if ( arduinoContext . boardDetails . buildProperties [ 'build.chip' ] ) {
465
+ chip = arduinoContext . boardDetails . buildProperties [ 'build.chip' ] ;
466
+ }
467
+ uploadOpts = [ "-f" , "interface/cmsis-dap.cfg" , "-f" , "target/" + chip + ".cfg" , "-s" , openocdPath + "/share/openocd/scripts" ,
468
+ "-c" , "init; adapter speed 5000; program " + imageFile + " verify 0x" + fsStart . toString ( 16 ) + "; reset; exit" ] ;
436
469
} else {
437
- uploadOpts = [ uf2conv , "--base" , String ( fsStart ) , "--serial" , serialPort , "--family" , "RP2040" , imageFile ] ;
470
+ let uf2conv = "tools" + path . sep + "uf2conv.py" ;
471
+ let uf2Path = findTool ( arduinoContext , "runtime.platform.path" ) ;
472
+ if ( uf2Path ) {
473
+ uf2conv = uf2Path + path . sep + uf2conv ;
474
+ }
475
+ if ( conversion ) {
476
+ uploadOpts = [ uf2conv , "--serial" , serialPort , "--family" , "RP2040" , imageFile + ".uf2" , "--deploy" ] ;
477
+ } else {
478
+ uploadOpts = [ uf2conv , "--base" , String ( fsStart ) , "--serial" , serialPort , "--family" , "RP2040" , imageFile ] ;
479
+ }
438
480
}
439
481
} else if ( esp32 ) {
440
482
let flashMode = arduinoContext . boardDetails . buildProperties [ "build.flash_mode" ] ;
0 commit comments