You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/02/22 21:24:50 UTC

[GitHub] [tvm] gromero commented on a change in pull request #10346: [microTVM] Zephyr: refactor _find_openocd_serial_port

gromero commented on a change in pull request #10346:
URL: https://github.com/apache/tvm/pull/10346#discussion_r812370126



##########
File path: apps/microtvm/zephyr/template_project/microtvm_api_server.py
##########
@@ -165,38 +165,6 @@ def _get_device_args(options):
     )
 
 
-# kwargs passed to usb.core.find to find attached boards for the openocd flash runner.
-BOARD_USB_FIND_KW = {
-    "nucleo_l4r5zi": {"idVendor": 0x0483, "idProduct": 0x374B},
-    "nucleo_f746zg": {"idVendor": 0x0483, "idProduct": 0x374B},
-    "stm32f746g_disco": {"idVendor": 0x0483, "idProduct": 0x374B},
-    "mimxrt1050_evk": {"idVendor": 0x1366, "idProduct": 0x0105},
-}
-
-
-def openocd_serial(options):
-    """Find the serial port to use for a board with OpenOCD flash strategy."""
-    if "openocd_serial" in options:
-        return options["openocd_serial"]
-
-    import usb  # pylint: disable=import-outside-toplevel
-
-    find_kw = BOARD_USB_FIND_KW[CMAKE_CACHE["BOARD"]]
-    boards = usb.core.find(find_all=True, **find_kw)
-    serials = []
-    for b in boards:
-        serials.append(b.serial_number)
-
-    if len(serials) == 0:
-        raise BoardAutodetectFailed(f"No attached USB devices matching: {find_kw!r}")
-    serials.sort()
-
-    autodetected_openocd_serial = serials[0]
-    _LOG.debug("zephyr openocd driver: autodetected serial %s", serials[0])
-
-    return autodetected_openocd_serial
-
-
 def _get_openocd_device_args(options):
     return ["--serial", openocd_serial(options)]

Review comment:
       @mehrdadh Thanks for catching it! I'll promote `_generic_find_serial_port()` to a module method so it can be used in `_get_openocd_device_args`. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org