Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[µTVM] Avoid listing links when probing serial ports #7265

Merged
merged 1 commit into from Jan 13, 2021

Conversation

gromero
Copy link
Contributor

@gromero gromero commented Jan 12, 2021

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.

Without that change the following error happens:

Traceback (most recent call last):
  File "./micro_tflite.py", line 255, in <module>
    with tvm.micro.Session(binary=micro_binary, flasher=flasher) as session:
  File "/home/gromero/git/tvm/python/tvm/micro/session.py ", line 127, in __enter__
    self.transport = TransportLogger(
  File "/home/gromero/git/tvm/python/tvm/micro/transport/base.py", line 79, in __enter__
    self.open()
  File "/home/gromero/git/tvm/python/tvm/micro/transport/base.py", line 207, in open
    self.child.open()
  File "/home/gromero/git/tvm/python/tvm/micro/transport/serial.py", line 72, in open
    raise SerialPortNotFoundError(
NameError: name 'SerialPortNotFoundError' is not defined

When ARM `STM32 STLink` is used by a board and the following device names are created:
gromero@gromero0:~/git/tvm$ ls -l /dev/{ttyACM0,stlinkv2-1_0}
lrwxrwxrwx 1 root root         7 Jan 12 16:10 /dev/stlinkv2-1_0 -> ttyACM0
crw-rw-rw- 1 root plugdev 166, 0 Jan 12 21:32 /dev/ttyACM0

Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.

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>
@gromero
Copy link
Contributor Author

gromero commented Jan 12, 2021

@areusch Could you please review? Thanks!

Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gromero thanks, I was trying to remember why I would have done this and I believe it was from when I was trying to use docker containers in place of the Reference VMs. I don't believe include_links is necessary now.

@tmoreau89 can you merge?

@tqchen tqchen merged commit 39ee8d5 into apache:main Jan 13, 2021
masahi pushed a commit to masahi/tvm that referenced this pull request Jan 14, 2021
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>
masahi pushed a commit to masahi/tvm that referenced this pull request Jan 18, 2021
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>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Jan 20, 2021
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>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jan 21, 2021
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>
electriclilies pushed a commit to electriclilies/tvm that referenced this pull request Feb 18, 2021
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants