Browse Source

targets: make msd-volume-name an array

pull/3665/head
Kenneth Bell 2 years ago
committed by Ron Evans
parent
commit
1bba5f5d7b
  1. 2
      compileopts/target.go
  2. 91
      main.go
  3. 2
      targets/circuitplay-bluefruit.json
  4. 2
      targets/circuitplay-express.json
  5. 2
      targets/clue-alpha.json
  6. 2
      targets/feather-m0-express.json
  7. 2
      targets/feather-m0.json
  8. 2
      targets/feather-m4-can.json
  9. 2
      targets/feather-m4.json
  10. 2
      targets/feather-nrf52840-sense.json
  11. 2
      targets/feather-nrf52840.json
  12. 2
      targets/grandcentral-m4.json
  13. 2
      targets/hifive1b.json
  14. 2
      targets/itsybitsy-m0.json
  15. 2
      targets/itsybitsy-m4.json
  16. 2
      targets/itsybitsy-nrf52840.json
  17. 2
      targets/matrixportal-m4.json
  18. 2
      targets/mdbt50qrx-uf2.json
  19. 2
      targets/metro-m4-airlift.json
  20. 2
      targets/microbit-v2.json
  21. 2
      targets/microbit.json
  22. 2
      targets/nano-33-ble-s140v6-uf2.json
  23. 2
      targets/nano-33-ble-s140v7-uf2.json
  24. 2
      targets/nicenano.json
  25. 2
      targets/nrf52840-mdk-usb-dongle.json
  26. 2
      targets/pca10056.json
  27. 2
      targets/pybadge.json
  28. 2
      targets/pygamer.json
  29. 2
      targets/pyportal.json
  30. 2
      targets/qtpy.json
  31. 2
      targets/reelboard.json
  32. 2
      targets/rp2040.json
  33. 2
      targets/trinket-m0.json
  34. 2
      targets/wioterminal.json
  35. 2
      targets/xiao-ble.json
  36. 2
      targets/xiao.json

2
compileopts/target.go

@ -50,7 +50,7 @@ type TargetSpec struct {
PortReset string `json:"flash-1200-bps-reset"`
SerialPort []string `json:"serial-port"` // serial port IDs in the form "vid:pid"
FlashMethod string `json:"flash-method"`
FlashVolume string `json:"msd-volume-name"`
FlashVolume []string `json:"msd-volume-name"`
FlashFilename string `json:"msd-firmware-name"`
UF2FamilyID string `json:"uf2-family-id"`
BinaryFormat string `json:"binary-format"`

91
main.go

@ -945,28 +945,29 @@ func touchSerialPortAt1200bps(port string) (err error) {
return fmt.Errorf("opening port: %s", err)
}
func flashUF2UsingMSD(volume, tmppath string, options *compileopts.Options) error {
func flashUF2UsingMSD(volumes []string, tmppath string, options *compileopts.Options) error {
// find standard UF2 info path
var infoPath string
switch runtime.GOOS {
case "linux", "freebsd":
fi, err := os.Stat("/run/media")
if err != nil || !fi.IsDir() {
infoPath = "/media/*/" + volume + "/INFO_UF2.TXT"
} else {
infoPath = "/run/media/*/" + volume + "/INFO_UF2.TXT"
}
case "darwin":
infoPath = "/Volumes/" + volume + "/INFO_UF2.TXT"
case "windows":
path, err := windowsFindUSBDrive(volume, options)
if err != nil {
return err
infoPaths := make([]string, 0, len(volumes))
for _, volume := range volumes {
switch runtime.GOOS {
case "linux", "freebsd":
fi, err := os.Stat("/run/media")
if err != nil || !fi.IsDir() {
infoPaths = append(infoPaths, "/media/*/"+volume+"/INFO_UF2.TXT")
} else {
infoPaths = append(infoPaths, "/run/media/*/"+volume+"/INFO_UF2.TXT")
}
case "darwin":
infoPaths = append(infoPaths, "/Volumes/"+volume+"/INFO_UF2.TXT")
case "windows":
path, err := windowsFindUSBDrive(volume, options)
if err == nil {
infoPaths = append(infoPaths, path+"/INFO_UF2.TXT")
}
}
infoPath = path + "/INFO_UF2.TXT"
}
d, err := locateDevice(volume, infoPath, options.Timeout)
d, err := locateDevice(volumes, infoPaths, options.Timeout)
if err != nil {
return err
}
@ -974,28 +975,29 @@ func flashUF2UsingMSD(volume, tmppath string, options *compileopts.Options) erro
return moveFile(tmppath, filepath.Dir(d)+"/flash.uf2")
}
func flashHexUsingMSD(volume, tmppath string, options *compileopts.Options) error {
func flashHexUsingMSD(volumes []string, tmppath string, options *compileopts.Options) error {
// find expected volume path
var destPath string
switch runtime.GOOS {
case "linux", "freebsd":
fi, err := os.Stat("/run/media")
if err != nil || !fi.IsDir() {
destPath = "/media/*/" + volume
} else {
destPath = "/run/media/*/" + volume
}
case "darwin":
destPath = "/Volumes/" + volume
case "windows":
path, err := windowsFindUSBDrive(volume, options)
if err != nil {
return err
destPaths := make([]string, 0, len(volumes))
for _, volume := range volumes {
switch runtime.GOOS {
case "linux", "freebsd":
fi, err := os.Stat("/run/media")
if err != nil || !fi.IsDir() {
destPaths = append(destPaths, "/media/*/"+volume)
} else {
destPaths = append(destPaths, "/run/media/*/"+volume)
}
case "darwin":
destPaths = append(destPaths, "/Volumes/"+volume)
case "windows":
path, err := windowsFindUSBDrive(volume, options)
if err == nil {
destPaths = append(destPaths, path+"/")
}
}
destPath = path + "/"
}
d, err := locateDevice(volume, destPath, options.Timeout)
d, err := locateDevice(volumes, destPaths, options.Timeout)
if err != nil {
return err
}
@ -1003,21 +1005,28 @@ func flashHexUsingMSD(volume, tmppath string, options *compileopts.Options) erro
return moveFile(tmppath, d+"/flash.hex")
}
func locateDevice(volume, path string, timeout time.Duration) (string, error) {
func locateDevice(volumes, paths []string, timeout time.Duration) (string, error) {
var d []string
var err error
for start := time.Now(); time.Since(start) < timeout; {
d, err = filepath.Glob(path)
if err != nil {
return "", err
for _, path := range paths {
d, err = filepath.Glob(path)
if err != nil {
return "", err
}
if d != nil {
break
}
}
if d != nil {
break
}
time.Sleep(500 * time.Millisecond)
}
if d == nil {
return "", errors.New("unable to locate device: " + volume)
return "", errors.New("unable to locate any volume: [" + strings.Join(volumes, ",") + "]")
}
return d[0], nil
}

2
targets/circuitplay-bluefruit.json

@ -2,5 +2,5 @@
"inherits": ["nrf52840", "nrf52840-s140v6-uf2"],
"build-tags": ["circuitplay_bluefruit"],
"serial-port": ["239a:8045"],
"msd-volume-name": "CPLAYBTBOOT"
"msd-volume-name": ["CPLAYBTBOOT"]
}

2
targets/circuitplay-express.json

@ -4,6 +4,6 @@
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["239a:8018"],
"msd-volume-name": "CPLAYBOOT",
"msd-volume-name": ["CPLAYBOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/clue-alpha.json

@ -2,5 +2,5 @@
"inherits": ["nrf52840", "nrf52840-s140v6-uf2"],
"build-tags": ["clue_alpha"],
"serial-port": ["239a:8072", "239a:8071"],
"msd-volume-name": "CLUEBOOT"
"msd-volume-name": ["CLUEBOOT"]
}

2
targets/feather-m0-express.json

@ -5,6 +5,6 @@
"serial-port": ["239a:801b"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "FEATHERBOOT",
"msd-volume-name": ["FEATHERBOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/feather-m0.json

@ -5,6 +5,6 @@
"serial-port": ["239a:801b", "239a:800b"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "FEATHERBOOT",
"msd-volume-name": ["FEATHERBOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/feather-m4-can.json

@ -5,6 +5,6 @@
"serial-port": ["239a:80cd"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "FTHRCANBOOT",
"msd-volume-name": ["FTHRCANBOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/feather-m4.json

@ -5,6 +5,6 @@
"serial-port": ["239a:8022"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "FEATHERBOOT",
"msd-volume-name": ["FEATHERBOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/feather-nrf52840-sense.json

@ -2,5 +2,5 @@
"inherits": ["nrf52840", "nrf52840-s140v6-uf2"],
"build-tags": ["feather_nrf52840_sense"],
"serial-port": ["239a:8087", "239a:8088"],
"msd-volume-name": "FTHRSNSBOOT"
"msd-volume-name": ["FTHRSNSBOOT"]
}

2
targets/feather-nrf52840.json

@ -2,5 +2,5 @@
"inherits": ["nrf52840", "nrf52840-s140v6-uf2"],
"build-tags": ["feather_nrf52840"],
"serial-port": ["239a:8029", "239a:802a"],
"msd-volume-name": "FTHR840BOOT"
"msd-volume-name": ["FTHR840BOOT"]
}

2
targets/grandcentral-m4.json

@ -5,7 +5,7 @@
"serial-port": ["239a:8031"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "GCM4BOOT",
"msd-volume-name": ["GCM4BOOT"],
"msd-firmware-name": "firmware.uf2",
"openocd-interface": "jlink"
}

2
targets/hifive1b.json

@ -4,7 +4,7 @@
"serial": "uart",
"linkerscript": "targets/hifive1b.ld",
"flash-method": "msd",
"msd-volume-name": "HiFive",
"msd-volume-name": ["HiFive"],
"msd-firmware-name": "firmware.hex",
"jlink-device": "fe310"
}

2
targets/itsybitsy-m0.json

@ -5,6 +5,6 @@
"serial-port": ["239a:800f", "239a:8012"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "ITSYBOOT",
"msd-volume-name": ["ITSYBOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/itsybitsy-m4.json

@ -5,6 +5,6 @@
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["239a:802b"],
"msd-volume-name": "ITSYM4BOOT",
"msd-volume-name": ["ITSYM4BOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/itsybitsy-nrf52840.json

@ -2,5 +2,5 @@
"inherits": ["nrf52840", "nrf52840-s140v6-uf2"],
"build-tags": ["itsybitsy_nrf52840"],
"serial-port": ["239A:8052", "239A:8051"],
"msd-volume-name": "ITSY840BOOT"
"msd-volume-name": ["ITSY840BOOT"]
}

2
targets/matrixportal-m4.json

@ -5,7 +5,7 @@
"serial-port": ["239a:80c9", "239a:80ca"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "MATRIXBOOT",
"msd-volume-name": ["MATRIXBOOT"],
"msd-firmware-name": "firmware.uf2",
"openocd-transport": "swd",
"openocd-interface": "jlink",

2
targets/mdbt50qrx-uf2.json

@ -2,5 +2,5 @@
"inherits": ["nrf52840", "nrf52840-s140v6-uf2"],
"build-tags": ["mdbt50qrx"],
"serial-port": ["239a:810b", "239a:810c"],
"msd-volume-name": "MDBT50QBOOT"
"msd-volume-name": ["MDBT50QBOOT"]
}

2
targets/metro-m4-airlift.json

@ -5,6 +5,6 @@
"serial-port": ["239A:8037"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "METROM4BOOT",
"msd-volume-name": ["METROM4BOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/microbit-v2.json

@ -4,6 +4,6 @@
"serial": "uart",
"flash-method": "msd",
"openocd-interface": "cmsis-dap",
"msd-volume-name": "MICROBIT",
"msd-volume-name": ["MICROBIT"],
"msd-firmware-name": "firmware.hex"
}

2
targets/microbit.json

@ -4,6 +4,6 @@
"serial": "uart",
"flash-method": "msd",
"openocd-interface": "cmsis-dap",
"msd-volume-name": "MICROBIT",
"msd-volume-name": ["MICROBIT"],
"msd-firmware-name": "firmware.hex"
}

2
targets/nano-33-ble-s140v6-uf2.json

@ -2,5 +2,5 @@
"inherits": ["nrf52840", "nrf52840-s140v6-uf2"],
"build-tags": ["nano_33_ble"],
"serial-port": ["239a:8063", "239a:0063"],
"msd-volume-name": "NANO33BOOT"
"msd-volume-name": ["NANO33BOOT"]
}

2
targets/nano-33-ble-s140v7-uf2.json

@ -2,5 +2,5 @@
"inherits": ["nrf52840", "nrf52840-s140v7-uf2"],
"build-tags": ["nano_33_ble"],
"serial-port": ["239a:8063", "239a:0063"],
"msd-volume-name": "NANO33BOOT"
"msd-volume-name": ["NANO33BOOT"]
}

2
targets/nicenano.json

@ -1,5 +1,5 @@
{
"inherits": ["nrf52840", "nrf52840-s140v6-uf2"],
"build-tags": ["nicenano"],
"msd-volume-name": "NICENANO"
"msd-volume-name": ["NICENANO"]
}

2
targets/nrf52840-mdk-usb-dongle.json

@ -1,5 +1,5 @@
{
"inherits": ["nrf52840", "nrf52840-s140v6-uf2"],
"build-tags": ["nrf52840_mdk_usb_dongle"],
"msd-volume-name": "MDK-DONGLE"
"msd-volume-name": ["MDK-DONGLE"]
}

2
targets/pca10056.json

@ -4,7 +4,7 @@
"serial": "uart",
"flash-method": "command",
"flash-command": "nrfjprog -f nrf52 --sectorerase --program {hex} --reset",
"msd-volume-name": "JLINK",
"msd-volume-name": ["JLINK"],
"msd-firmware-name": "firmware.hex",
"openocd-interface": "jlink",
"openocd-transport": "swd"

2
targets/pybadge.json

@ -5,6 +5,6 @@
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["239a:8033"],
"msd-volume-name": "PYBADGEBOOT",
"msd-volume-name": ["PYBADGEBOOT"],
"msd-firmware-name": "arcade.uf2"
}

2
targets/pygamer.json

@ -5,6 +5,6 @@
"serial-port": ["239a:803d", "239a:803e"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "PYGAMERBOOT",
"msd-volume-name": ["PYGAMERBOOT"],
"msd-firmware-name": "arcade.uf2"
}

2
targets/pyportal.json

@ -5,6 +5,6 @@
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["239a:8035", "239a:8036"],
"msd-volume-name": "PORTALBOOT",
"msd-volume-name": ["PORTALBOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/qtpy.json

@ -5,6 +5,6 @@
"serial-port": ["239a:80cb"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "QTPY_BOOT",
"msd-volume-name": ["QTPY_BOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/reelboard.json

@ -3,7 +3,7 @@
"build-tags": ["reelboard"],
"serial": "uart",
"flash-method": "msd",
"msd-volume-name": "reel-board",
"msd-volume-name": ["reel-board"],
"msd-firmware-name": "firmware.hex",
"openocd-interface": "cmsis-dap"
}

2
targets/rp2040.json

@ -4,7 +4,7 @@
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial": "usb",
"msd-volume-name": "RPI-RP2",
"msd-volume-name": ["RPI-RP2"],
"msd-firmware-name": "firmware.uf2",
"binary-format": "uf2",
"uf2-family-id": "0xe48bff56",

2
targets/trinket-m0.json

@ -5,6 +5,6 @@
"serial-port": ["239a:801e"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "TRINKETBOOT",
"msd-volume-name": ["TRINKETBOOT"],
"msd-firmware-name": "firmware.uf2"
}

2
targets/wioterminal.json

@ -5,7 +5,7 @@
"serial-port": ["2886:802d"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "Arduino",
"msd-volume-name": ["Arduino"],
"msd-firmware-name": "firmware.uf2",
"openocd-verify": true
}

2
targets/xiao-ble.json

@ -2,5 +2,5 @@
"inherits": ["nrf52840", "nrf52840-s140v7-uf2"],
"build-tags": ["xiao_ble"],
"serial-port": ["2886:8045"],
"msd-volume-name": "XIAO-SENSE"
"msd-volume-name": ["XIAO-SENSE"]
}

2
targets/xiao.json

@ -5,6 +5,6 @@
"serial-port": ["2886:802f"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "Arduino",
"msd-volume-name": ["Arduino","Seeed XIAO"],
"msd-firmware-name": "firmware.uf2"
}

Loading…
Cancel
Save