@@ -371,7 +371,8 @@ export function activate(context: vscode.ExtensionContext) {
371
371
writeEmitter . fire ( red ( "\r\n\r\nERROR: mklittlefs not found!\r\n" + resetStyle ) ) ;
372
372
}
373
373
374
- // TBD - add non-serial UF2 upload via OpenOCD
374
+ let network = false ;
375
+ let networkPort = 0 ;
375
376
let serialPort = "" ;
376
377
if ( uploadmethod === "picotool" ) {
377
378
serialPort = "picotool" ;
@@ -383,10 +384,20 @@ export function activate(context: vscode.ExtensionContext) {
383
384
} else {
384
385
serialPort = arduinoContext . port ?. address ;
385
386
}
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
- //}
387
+ if ( arduinoContext . port ?. protocol === "network" ) {
388
+ if ( ! arduinoContext . port ?. properties . port ) {
389
+ writeEmitter . fire ( red ( "\r\n\r\nERROR: Network upload but port specified, check IDE menus.\r\n" ) ) ;
390
+ return ;
391
+ }
392
+ networkPort = Number ( arduinoContext . port ?. properties . port ) ;
393
+ network = true ;
394
+ writeEmitter . fire ( blue ( "Network Info: " ) + green ( serialPort + ":" + String ( networkPort ) ) + "\r\n" ) ;
395
+ } else if ( arduinoContext . port ?. protocol === "serial" ) {
396
+ writeEmitter . fire ( blue ( " Serial Port: " ) + green ( serialPort ) + "\r\n" ) ;
397
+ } else {
398
+ writeEmitter . fire ( red ( "\r\n\r\nERROR: Unknown upload method '" + String ( arduinoContext . port ?. properties . port ) + "' specified, check IDE menus.\r\n" ) ) ;
399
+ return ;
400
+ }
390
401
391
402
let python3 = "python3" + ext ;
392
403
let python3Path = undefined ;
@@ -467,33 +478,58 @@ export function activate(context: vscode.ExtensionContext) {
467
478
uploadOpts = [ "-f" , "interface/cmsis-dap.cfg" , "-f" , "target/" + chip + ".cfg" , "-s" , openocdPath + "/share/openocd/scripts" ,
468
479
"-c" , "init; adapter speed 5000; program " + imageFile + " verify 0x" + fsStart . toString ( 16 ) + "; reset; exit" ] ;
469
480
} else {
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 " ] ;
481
+ if ( network ) {
482
+ let espota = "tools" + path . sep + "espota.py" ;
483
+ let espotaPath = findTool ( arduinoContext , "runtime.platform.path" ) ;
484
+ if ( espotaPath ) {
485
+ espota = espotaPath + path . sep + espota ;
486
+ }
487
+ uploadOpts = [ "-I" , espota , "-i ", serialPort , "-p " , String ( networkPort ) , "-f ", imageFile , "-s " ] ;
477
488
} else {
478
- uploadOpts = [ uf2conv , "--base" , String ( fsStart ) , "--serial" , serialPort , "--family" , "RP2040" , imageFile ] ;
489
+ let uf2conv = "tools" + path . sep + "uf2conv.py" ;
490
+ let uf2Path = findTool ( arduinoContext , "runtime.platform.path" ) ;
491
+ if ( uf2Path ) {
492
+ uf2conv = uf2Path + path . sep + uf2conv ;
493
+ }
494
+ if ( conversion ) {
495
+ uploadOpts = [ uf2conv , "--serial" , serialPort , "--family" , "RP2040" , imageFile + ".uf2" , "--deploy" ] ;
496
+ } else {
497
+ uploadOpts = [ uf2conv , "--base" , String ( fsStart ) , "--serial" , serialPort , "--family" , "RP2040" , imageFile ] ;
498
+ }
479
499
}
480
500
}
481
501
} else if ( esp32 ) {
482
- let flashMode = arduinoContext . boardDetails . buildProperties [ "build.flash_mode" ] ;
483
- let flashFreq = arduinoContext . boardDetails . buildProperties [ "build.flash_freq" ] ;
484
- let espTool = "esptool" + extEspTool ;
485
- let espToolPath = findTool ( arduinoContext , "runtime.tools.esptool_py.path" ) ;
486
- if ( espToolPath ) {
487
- espTool = espToolPath + path . sep + espTool ;
488
- }
489
- uploadOpts = [ "--chip" , esp32variant , "--port" , serialPort , "--baud" , String ( uploadSpeed ) ,
490
- "--before" , "default_reset" , "--after" , "hard_reset" , "write_flash" , "-z" ,
491
- "--flash_mode" , flashMode , "--flash_freq" , flashFreq , "--flash_size" , "detect" , String ( fsStart ) , imageFile ] ;
492
- if ( ( platform ( ) === 'win32' ) || ( platform ( ) === 'darwin' ) ) {
493
- cmdApp = espTool ; // Have binary EXE on Mac/Windows
502
+ if ( network ) {
503
+ let espota = "tools" + path . sep + "espota.py" ;
504
+ let espotaPath = findTool ( arduinoContext , "runtime.platform.path" ) ;
505
+ if ( espotaPath ) {
506
+ espota = espotaPath + path . sep + espota ;
507
+ }
508
+ uploadOpts = [ "-r" , "-i" , serialPort , "-p" , String ( networkPort ) , "-f" , imageFile , "-s" ] ;
509
+
510
+ if ( ( platform ( ) === 'win32' ) || ( platform ( ) === 'darwin' ) ) {
511
+ cmdApp = espota ; // Have binary EXE on Mac/Windows
512
+ } else {
513
+ cmdApp = "python3" ; // Not shipped, assumed installed on Linux
514
+ uploadOpts . unshift ( espota ) ; // Need to call Python3
515
+ }
494
516
} else {
495
- cmdApp = "python3" ; // Not shipped, assumed installed on Linux
496
- uploadOpts . unshift ( espTool ) ; // Need to call Python3
517
+ let flashMode = arduinoContext . boardDetails . buildProperties [ "build.flash_mode" ] ;
518
+ let flashFreq = arduinoContext . boardDetails . buildProperties [ "build.flash_freq" ] ;
519
+ let espTool = "esptool" + extEspTool ;
520
+ let espToolPath = findTool ( arduinoContext , "runtime.tools.esptool_py.path" ) ;
521
+ if ( espToolPath ) {
522
+ espTool = espToolPath + path . sep + espTool ;
523
+ }
524
+ uploadOpts = [ "--chip" , esp32variant , "--port" , serialPort , "--baud" , String ( uploadSpeed ) ,
525
+ "--before" , "default_reset" , "--after" , "hard_reset" , "write_flash" , "-z" ,
526
+ "--flash_mode" , flashMode , "--flash_freq" , flashFreq , "--flash_size" , "detect" , String ( fsStart ) , imageFile ] ;
527
+ if ( ( platform ( ) === 'win32' ) || ( platform ( ) === 'darwin' ) ) {
528
+ cmdApp = espTool ; // Have binary EXE on Mac/Windows
529
+ } else {
530
+ cmdApp = "python3" ; // Not shipped, assumed installed on Linux
531
+ uploadOpts . unshift ( espTool ) ; // Need to call Python3
532
+ }
497
533
}
498
534
} else { // esp8266
499
535
let upload = "tools" + path . sep + "upload.py" ;
0 commit comments