Skip to content

Commit

Permalink
[µTVM] Avoid listing links when probing serial ports (apache#7265)
Browse files Browse the repository at this point in the history
SerialTransport.open() probes automatically the device name based upon a
grep regex if a device name is not provided. The code expects to find only
a single device. Currently when it probes for the available serial ports it
includes in the list the device names that are also symbolic links.

Since _find_openocd_serial_port() always returns a serial number for a
given serial port (not the device name path) the available device names
are always probed when the openocd flash runner is used.

It's not uncommon that device drivers create symbolic links for certain
kinds of serial devices, specially those that provide a serial port plus
an additional endpoint to program the device attached, like a ST-Link
interface, etc.

As a consequence the current code fails to select the correct device name
when symbolic links exist and the openocd flash runner is used.

That commit changes the probe behavior to avoid listing symbolic links when
probing the device name for the target serial port.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
  • Loading branch information
gromero authored and electriclilies committed Feb 18, 2021
1 parent 16669d1 commit 5117201
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/tvm/micro/transport/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def open(self):
if self._port_path is not None:
port_path = self._port_path
else:
ports = list(serial.tools.list_ports.grep(self._grep, include_links=True))
ports = list(serial.tools.list_ports.grep(self._grep))
if len(ports) != 1:
raise SerialPortNotFoundError(
f"grep expression should find 1 serial port; found {ports!r}"
Expand Down

0 comments on commit 5117201

Please sign in to comment.