Skip to content

Commit

Permalink
[tools] Improvements to BlackMagicProbe tool
Browse files Browse the repository at this point in the history
- Added a missing import to `modm_tools/bmp.py`
- Changed `guess_serial_port()` to use `/dev/ttyBmpGdb` when guessing a BMP port
  • Loading branch information
kapacuk committed Mar 26, 2024
1 parent c43be03 commit d72efc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions tools/modm_tools/bmp.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def add_subparser(subparser):
# -----------------------------------------------------------------------------
if __name__ == "__main__":
import argparse
import os.path

parser = argparse.ArgumentParser(
description='Program ELF file or reset device via Black Magic Probe')
Expand Down
13 changes: 12 additions & 1 deletion tools/modm_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,18 @@ def guess_serial_port(port_hint=None):
else:
ports = glob.glob('/dev/tty.usb*')
else:
ports = glob.glob('/dev/tty[A-Za-z]*')
if port_hint == 'bmp':
import os.path
# Symlink created by BMP udev rules
# https://github.com/blackmagic-debug/blackmagic/blob/main/driver/99-blackmagic-plugdev.rules
if os.path.exists('/dev/ttyBmpGdb'):
ports = ['/dev/ttyBmpGdb']
elif os.path.exists('/dev/ttyACM0'):
ports = ['/dev/ttyACM0']
else:
ports = [None]
else:
ports = glob.glob('/dev/tty[A-Za-z]*')
return next(iter(ports), None)


Expand Down

0 comments on commit d72efc7

Please sign in to comment.