Skip to content

Commit d72efc7

Browse files
authored
[tools] Improvements to BlackMagicProbe tool
- Added a missing import to `modm_tools/bmp.py` - Changed `guess_serial_port()` to use `/dev/ttyBmpGdb` when guessing a BMP port
1 parent c43be03 commit d72efc7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tools/modm_tools/bmp.py

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def add_subparser(subparser):
7373
# -----------------------------------------------------------------------------
7474
if __name__ == "__main__":
7575
import argparse
76+
import os.path
7677

7778
parser = argparse.ArgumentParser(
7879
description='Program ELF file or reset device via Black Magic Probe')

tools/modm_tools/utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,18 @@ def guess_serial_port(port_hint=None):
5050
else:
5151
ports = glob.glob('/dev/tty.usb*')
5252
else:
53-
ports = glob.glob('/dev/tty[A-Za-z]*')
53+
if port_hint == 'bmp':
54+
import os.path
55+
# Symlink created by BMP udev rules
56+
# https://github.com/blackmagic-debug/blackmagic/blob/main/driver/99-blackmagic-plugdev.rules
57+
if os.path.exists('/dev/ttyBmpGdb'):
58+
ports = ['/dev/ttyBmpGdb']
59+
elif os.path.exists('/dev/ttyACM0'):
60+
ports = ['/dev/ttyACM0']
61+
else:
62+
ports = [None]
63+
else:
64+
ports = glob.glob('/dev/tty[A-Za-z]*')
5465
return next(iter(ports), None)
5566

5667

0 commit comments

Comments
 (0)