main: detect specific serial port IDs based on USB vid/pid

This makes it possible to flash a board even when there are multiple
different kinds of boards attached, e.g. an Arduino Uno and a Circuit
Playground Express. You can find the VID/PID pair in several ways:

 1. By running `lsusb` before and after attaching the board and looking
    at the new USB device.
 2. By grepping for `usb_PID` and `usb_VID` in the TinyGo source code.
 3. By checking the Arduino IDE boards.txt from the vendor.

Note that one board may have multiple VID/PID pairs:

  * The bootloader and main program may have a different PID, so far
    I've seen that the main program generally has the bootloader PID
    with 0x8000 added.
  * The software running on the board may have an erroneous PID, for
    example from a different board. I've seen this happen a few times.
  * A single board may have had some revisions which changed the PID.
    This is particularly true for the Arduino Uno.

As a fallback, if the given VID/PID pair isn't found, the whole set of
serial ports will be used.

There are many boards which I haven't included yet simply because I
couldn't test them.
This commit is contained in:
Ayke van Laethem
2021-06-17 17:12:05 +02:00
committed by Ron Evans
parent 8e33f1c9eb
commit e107efa63f
10 changed files with 75 additions and 7 deletions
+1
View File
@@ -2,5 +2,6 @@
"inherits": ["atsamd21g18a"],
"build-tags": ["arduino_nano33"],
"flash-command": "bossac -i -e -w -v -R -U --port={port} --offset=0x2000 {bin}",
"serial-port": ["acm:2341:8057", "acm:2341:0057"],
"flash-1200-bps-reset": "true"
}
+1
View File
@@ -6,5 +6,6 @@
"-Wl,--defsym=_stack_size=512"
],
"flash-command": "avrdude -c arduino -p atmega328p -P {port} -U flash:w:{hex}:i",
"serial-port": ["acm:2341:0043", "acm:2341:0001", "acm:2a03:0043", "acm:2341:0243"],
"emulator": ["simavr", "-m", "atmega328p", "-f", "16000000"]
}
+1
View File
@@ -3,6 +3,7 @@
"build-tags": ["circuitplay_bluefruit","nrf52840_reset_uf2", "softdevice", "s140v6"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["acm:239a:8045", "acm:239a:45"],
"msd-volume-name": "CPLAYBTBOOT",
"msd-firmware-name": "firmware.uf2",
"uf2-family-id": "0xADA52840",
+1
View File
@@ -3,6 +3,7 @@
"build-tags": ["circuitplay_express"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["acm:239a:8018", "acm:239a:18"],
"msd-volume-name": "CPLAYBOOT",
"msd-firmware-name": "firmware.uf2"
}
+1
View File
@@ -3,6 +3,7 @@
"build-tags": ["itsybitsy_m4"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["acm:239a:802b", "acm:239a:002b"],
"msd-volume-name": "ITSYM4BOOT",
"msd-firmware-name": "firmware.uf2"
}
+1
View File
@@ -2,6 +2,7 @@
"inherits": ["nrf52840"],
"build-tags": ["nano_33_ble", "nrf52840_reset_bossa"],
"flash-command": "bossac_arduino2 -d -i -e -w -v -R --port={port} {bin}",
"serial-port": ["acm:2341:805a", "acm:2341:005a"],
"flash-1200-bps-reset": "true",
"linkerscript": "targets/nano-33-ble.ld"
}
+1
View File
@@ -3,6 +3,7 @@
"build-tags": ["pybadge"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["acm:239a:8033", "acm:239a:33"],
"msd-volume-name": "PYBADGEBOOT",
"msd-firmware-name": "arcade.uf2"
}
+1
View File
@@ -3,6 +3,7 @@
"build-tags": ["pyportal"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["acm:239a:8035", "acm:239a:35", "acm:239a:8036"],
"msd-volume-name": "PORTALBOOT",
"msd-firmware-name": "firmware.uf2"
}