@@ -341,6 +341,9 @@ func (pm *PackageManager) loadPlatformRelease(platform *cores.PlatformRelease, p
341
341
// Create programmers properties
342
342
if programmersProperties , err := properties .SafeLoad (programmersTxtPath .String ()); err == nil {
343
343
for programmerID , programmerProperties := range programmersProperties .FirstLevelOf () {
344
+ if ! platform .PluggableDiscoveryAware {
345
+ convertUploadToolsToPluggableDiscovery (programmersProperties )
346
+ }
344
347
platform .Programmers [programmerID ] = pm .loadProgrammer (programmerProperties )
345
348
platform .Programmers [programmerID ].PlatformRelease = platform
346
349
}
@@ -391,12 +394,6 @@ func (pm *PackageManager) loadBoards(platform *cores.PlatformRelease) error {
391
394
// set all other boards properties
392
395
delete (propertiesByBoard , "menu" )
393
396
394
- if ! platform .PluggableDiscoveryAware {
395
- for _ , boardProperties := range propertiesByBoard {
396
- convertVidPidIdentificationPropertiesToPluggableDiscovery (boardProperties )
397
- }
398
- }
399
-
400
397
skippedBoards := []string {}
401
398
for boardID , boardProperties := range propertiesByBoard {
402
399
var board * cores.Board
@@ -415,6 +412,12 @@ func (pm *PackageManager) loadBoards(platform *cores.PlatformRelease) error {
415
412
goto next_board
416
413
}
417
414
}
415
+
416
+ if ! platform .PluggableDiscoveryAware {
417
+ convertVidPidIdentificationPropertiesToPluggableDiscovery (boardProperties )
418
+ convertUploadToolsToPluggableDiscovery (boardProperties )
419
+ }
420
+
418
421
// The board's ID must be available in a board's properties since it can
419
422
// be used in all configuration files for several reasons, like setting compilation
420
423
// flags depending on the board id.
@@ -471,6 +474,22 @@ func convertVidPidIdentificationPropertiesToPluggableDiscovery(boardProperties *
471
474
}
472
475
}
473
476
477
+ func convertUploadToolsToPluggableDiscovery (props * properties.Map ) {
478
+ actions := []string {"upload" , "bootloader" , "program" }
479
+ for _ , action := range actions {
480
+ if ! props .ContainsKey (fmt .Sprintf ("%s.tool.default" , action )) {
481
+ tool , found := props .GetOk (fmt .Sprintf ("%s.tool" , action ))
482
+ if ! found {
483
+ // Just skip it, ideally this must never happen but if a platform
484
+ // doesn't define an expected upload.tool, bootloader.tool or program.tool
485
+ // there will be other issues further down the road after this conversion
486
+ continue
487
+ }
488
+ props .Set (fmt .Sprintf ("%s.tool.default" , action ), tool )
489
+ }
490
+ }
491
+ }
492
+
474
493
func (pm * PackageManager ) loadToolsFromPackage (targetPackage * cores.Package , toolsPath * paths.Path ) []* status.Status {
475
494
pm .Log .Infof ("Loading tools from dir: %s" , toolsPath )
476
495
0 commit comments