@@ -337,8 +337,11 @@ export function activate(context: vscode.ExtensionContext) {
337
337
338
338
let python3 = "python3" + ext ;
339
339
let python3Path = undefined ;
340
+ let picotool = "picotool" + ext ;
341
+ let picotoolPath = undefined ;
340
342
if ( pico ) {
341
343
python3Path = findTool ( arduinoContext , "runtime.tools.pqt-python3" ) ;
344
+ picotoolPath = findTool ( arduinoContext , "runtime.tools.pqt-picotool" ) ;
342
345
} else if ( esp8266 ) {
343
346
python3Path = findTool ( arduinoContext , "runtime.tools.python3" ) ;
344
347
} else if ( esp32 ) {
@@ -347,6 +350,9 @@ export function activate(context: vscode.ExtensionContext) {
347
350
if ( python3Path ) {
348
351
python3 = python3Path + path . sep + python3 ;
349
352
}
353
+ if ( picotoolPath ) {
354
+ picotool = picotoolPath + path . sep + picotool ;
355
+ }
350
356
351
357
// We can't always know where the compile path is, so just use a temp name
352
358
const tmp = require ( 'tmp' ) ;
@@ -365,6 +371,25 @@ export function activate(context: vscode.ExtensionContext) {
365
371
return ;
366
372
}
367
373
374
+ let conversion = false
375
+ if ( pico ) {
376
+ if ( Number ( arduinoContext . boardDetails ?. buildProperties [ 'version' ] . split ( '.' ) [ 0 ] ) > 3 ) {
377
+ // Pico 4.x needs a preparation stage for the RP2350
378
+ writeEmitter . fire ( bold ( "\r\n4.0 or above\r\n" ) ) ;
379
+ let picotoolOpts = [ "uf2" , "convert" , imageFile , "-t" , "bin" , imageFile + ".uf2" , "-o" , "0x" + fsStart . toString ( 16 ) , "--family" , "data" ] ;
380
+ writeEmitter . fire ( bold ( "\r\nGenerating UF2 image\r\n" ) ) ;
381
+ writeEmitter . fire ( blue ( "Command Line: " ) + green ( picotool + " " + picotoolOpts . join ( " " ) + "\r\n" ) ) ;
382
+ exitCode = await runCommand ( picotool , picotoolOpts ) ;
383
+ if ( exitCode ) {
384
+ writeEmitter . fire ( red ( "\r\n\r\nERROR: Generation failed, error code: " + String ( exitCode ) + "\r\n\r\n" ) ) ;
385
+ return ;
386
+ }
387
+ conversion = true ;
388
+ } else {
389
+ writeEmitter . fire ( bold ( "\r\n3.x, no UF2 conversion\r\n" ) ) ;
390
+ }
391
+ }
392
+
368
393
// Upload stage differs per core
369
394
let uploadOpts : any [ ] = [ ] ;
370
395
let cmdApp = python3 ;
@@ -374,7 +399,11 @@ export function activate(context: vscode.ExtensionContext) {
374
399
if ( uf2Path ) {
375
400
uf2conv = uf2Path + path . sep + uf2conv ;
376
401
}
377
- uploadOpts = [ uf2conv , "--base" , String ( fsStart ) , "--serial" , serialPort , "--family" , "RP2040" , imageFile ] ;
402
+ if ( conversion ) {
403
+ uploadOpts = [ uf2conv , "--serial" , serialPort , "--family" , "RP2040" , imageFile + ".uf2" , "--deploy" ] ;
404
+ } else {
405
+ uploadOpts = [ uf2conv , "--base" , String ( fsStart ) , "--serial" , serialPort , "--family" , "RP2040" , imageFile ] ;
406
+ }
378
407
} else if ( esp32 ) {
379
408
let flashMode = arduinoContext . boardDetails . buildProperties [ "build.flash_mode" ] ;
380
409
let flashFreq = arduinoContext . boardDetails . buildProperties [ "build.flash_freq" ] ;
0 commit comments