Skip to content

Commit 5a92c35

Browse files
aykevldeadprogram
authored andcommitted
main: restore support for flashing Espressif chips
This reverts commit 303410d and also removes the unnecessary fallback.
1 parent 7513fa2 commit 5a92c35

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

main.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,8 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e
998998
preferredPortIDs = append(preferredPortIDs, [2]uint16{uint16(vid), uint16(pid)})
999999
}
10001000

1001-
var primaryPorts []string // ports picked from preferred USB VID/PID
1001+
var primaryPorts []string // ports picked from preferred USB VID/PID
1002+
var secondaryPorts []string // other ports (as a fallback)
10021003
for _, p := range portsList {
10031004
if !p.IsUSB {
10041005
continue
@@ -1020,6 +1021,8 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e
10201021
continue
10211022
}
10221023
}
1024+
1025+
secondaryPorts = append(secondaryPorts, p.Name)
10231026
}
10241027
if len(primaryPorts) == 1 {
10251028
// There is exactly one match in the set of preferred ports. Use
@@ -1031,18 +1034,10 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e
10311034
// one device of the same type are connected (e.g. two Arduino
10321035
// Unos).
10331036
ports = primaryPorts
1034-
}
1035-
1036-
if len(ports) == 0 {
1037-
// fallback
1038-
switch runtime.GOOS {
1039-
case "darwin":
1040-
ports, err = filepath.Glob("/dev/cu.usb*")
1041-
case "linux":
1042-
ports, err = filepath.Glob("/dev/ttyACM*")
1043-
case "windows":
1044-
ports, err = serial.GetPortsList()
1045-
}
1037+
} else {
1038+
// No preferred ports found. Fall back to other serial ports
1039+
// available in the system.
1040+
ports = secondaryPorts
10461041
}
10471042
default:
10481043
return "", errors.New("unable to search for a default USB device to be flashed on this OS")

0 commit comments

Comments
 (0)