mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 10:03:50 +01:00
dist/tools/bmp: support newer firmware versions
Some commands have been renamed since version 1.9.0 and 1.10.0. To still provide compatibility with older debuggers, allow one to override the firmware version assumed. A dependency for packaging was added for comparing version numbers.
This commit is contained in:
parent
96dbd33507
commit
9efc41dbf4
8
dist/tools/bmp/README.md
vendored
8
dist/tools/bmp/README.md
vendored
@ -32,6 +32,8 @@ options:
|
|||||||
selection)
|
selection)
|
||||||
--attach ATTACH choose specific target by number
|
--attach ATTACH choose specific target by number
|
||||||
--gdb-path GDB_PATH path to GDB
|
--gdb-path GDB_PATH path to GDB
|
||||||
|
--bmp-version BMP_VERSION
|
||||||
|
choose specific firmware version
|
||||||
--term-cmd TERM_CMD serial terminal command
|
--term-cmd TERM_CMD serial terminal command
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -51,6 +53,12 @@ The probe is auto discovered based on the USB VID (0x1D50) and PID (0x6018,
|
|||||||
If `--port` is provided, then that port will be used as the GDB port for all
|
If `--port` is provided, then that port will be used as the GDB port for all
|
||||||
actions, except for the `term` action.
|
actions, except for the `term` action.
|
||||||
|
|
||||||
|
## Supported firmwares
|
||||||
|
This tool assumes firmware version 1.10 of the Black Magic debugger.
|
||||||
|
|
||||||
|
Compatibility for older versions is limited, but can be selected by providing
|
||||||
|
`--bmp-version x.y.z`.
|
||||||
|
|
||||||
## Examples (tested with BluePill STM32F103F8C6)
|
## Examples (tested with BluePill STM32F103F8C6)
|
||||||
* test connection:
|
* test connection:
|
||||||
```
|
```
|
||||||
|
|||||||
28
dist/tools/bmp/bmp.py
vendored
28
dist/tools/bmp/bmp.py
vendored
@ -19,6 +19,7 @@ import sys
|
|||||||
|
|
||||||
import humanize
|
import humanize
|
||||||
import serial.tools.list_ports
|
import serial.tools.list_ports
|
||||||
|
from packaging.version import Version
|
||||||
from progressbar import Bar, Percentage, ProgressBar
|
from progressbar import Bar, Percentage, ProgressBar
|
||||||
from pygdbmi.gdbcontroller import GdbController
|
from pygdbmi.gdbcontroller import GdbController
|
||||||
|
|
||||||
@ -195,11 +196,17 @@ def debug_mode(args, port):
|
|||||||
if args.tpwr:
|
if args.tpwr:
|
||||||
gdb_args.append('-ex \'monitor tpwr enable\'')
|
gdb_args.append('-ex \'monitor tpwr enable\'')
|
||||||
if args.connect_srst:
|
if args.connect_srst:
|
||||||
gdb_args.append('-ex \'monitor connect_srst enable\'')
|
if args.bmp_version >= Version('1.9.0'):
|
||||||
|
gdb_args.append('-ex \'monitor connect_rst enable\'')
|
||||||
|
else:
|
||||||
|
gdb_args.append('-ex \'monitor connect_srst enable\'')
|
||||||
if args.jtag:
|
if args.jtag:
|
||||||
gdb_args.append('-ex \'monitor jtag_scan\'')
|
gdb_args.append('-ex \'monitor jtag_scan\'')
|
||||||
else:
|
else:
|
||||||
gdb_args.append('-ex \'monitor swdp_scan\'')
|
if args.bmp_version >= Version('1.10.0'):
|
||||||
|
gdb_args.append('-ex \'monitor swd_scan\'')
|
||||||
|
else:
|
||||||
|
gdb_args.append('-ex \'monitor swdp_scan\'')
|
||||||
gdb_args.append('-ex \'attach %s\'' % args.attach)
|
gdb_args.append('-ex \'attach %s\'' % args.attach)
|
||||||
os.system(" ".join(['\"' + args.gdb_path + '\"'] + gdb_args + [args.file]))
|
os.system(" ".join(['\"' + args.gdb_path + '\"'] + gdb_args + [args.file]))
|
||||||
|
|
||||||
@ -216,13 +223,19 @@ def connect_to_target(args, port):
|
|||||||
expected_result='connected')
|
expected_result='connected')
|
||||||
# set options
|
# set options
|
||||||
if args.connect_srst:
|
if args.connect_srst:
|
||||||
gdbmi.write('monitor connect_srst enable', timeout_sec=TIMEOUT)
|
if args.bmp_version >= Version('1.9.0'):
|
||||||
|
gdbmi.write('monitor connect_rst enable', timeout_sec=TIMEOUT)
|
||||||
|
else:
|
||||||
|
gdbmi.write('monitor connect_srst enable', timeout_sec=TIMEOUT)
|
||||||
if args.tpwr:
|
if args.tpwr:
|
||||||
gdbmi.write('monitor tpwr enable', timeout_sec=TIMEOUT)
|
gdbmi.write('monitor tpwr enable', timeout_sec=TIMEOUT)
|
||||||
# scan for targets
|
# scan for targets
|
||||||
if not args.jtag:
|
if not args.jtag:
|
||||||
print("scanning using SWD...")
|
print("scanning using SWD...")
|
||||||
res = gdbmi.write('monitor swdp_scan', timeout_sec=TIMEOUT)
|
if args.bmp_version >= Version('1.10.0'):
|
||||||
|
res = gdbmi.write('monitor swd_scan', timeout_sec=TIMEOUT)
|
||||||
|
else:
|
||||||
|
res = gdbmi.write('monitor swdp_scan', timeout_sec=TIMEOUT)
|
||||||
else:
|
else:
|
||||||
print("scanning using JTAG...")
|
print("scanning using JTAG...")
|
||||||
res = gdbmi.write('monitor jtag_scan', timeout_sec=TIMEOUT)
|
res = gdbmi.write('monitor jtag_scan', timeout_sec=TIMEOUT)
|
||||||
@ -246,6 +259,7 @@ def parse_args():
|
|||||||
parser.add_argument('--port', help='choose specific probe by port (overrides auto selection)')
|
parser.add_argument('--port', help='choose specific probe by port (overrides auto selection)')
|
||||||
parser.add_argument('--attach', help='choose specific target by number', default='1')
|
parser.add_argument('--attach', help='choose specific target by number', default='1')
|
||||||
parser.add_argument('--gdb-path', help='path to GDB', default='gdb-multiarch')
|
parser.add_argument('--gdb-path', help='path to GDB', default='gdb-multiarch')
|
||||||
|
parser.add_argument('--bmp-version', help='choose specific firmware version', default='1.10.0')
|
||||||
parser.add_argument('--term-cmd', help='serial terminal command',
|
parser.add_argument('--term-cmd', help='serial terminal command',
|
||||||
default='picocom --nolock --imap lfcrlf --baud 115200 %s')
|
default='picocom --nolock --imap lfcrlf --baud 115200 %s')
|
||||||
|
|
||||||
@ -271,6 +285,7 @@ def main():
|
|||||||
port = choose_port(args, g)
|
port = choose_port(args, g)
|
||||||
|
|
||||||
args.file = args.file if args.file else ''
|
args.file = args.file if args.file else ''
|
||||||
|
args.bmp_version = Version(args.bmp_version)
|
||||||
args.gdb_path = find_suitable_gdb(args.gdb_path)
|
args.gdb_path = find_suitable_gdb(args.gdb_path)
|
||||||
|
|
||||||
if args.action == 'debug':
|
if args.action == 'debug':
|
||||||
@ -287,7 +302,10 @@ def main():
|
|||||||
# reset mode: reset device using reset pin
|
# reset mode: reset device using reset pin
|
||||||
if args.action == 'reset':
|
if args.action == 'reset':
|
||||||
print('resetting...')
|
print('resetting...')
|
||||||
assert gdb_write_and_wait_for_result(gdbmi, 'monitor hard_srst', 'resetting target')
|
if args.bmp_version >= Version('1.9.0'):
|
||||||
|
assert gdb_write_and_wait_for_result(gdbmi, 'monitor reset', 'resetting target')
|
||||||
|
else:
|
||||||
|
assert gdb_write_and_wait_for_result(gdbmi, 'monitor hard_srst', 'resetting target')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
# erase mode
|
# erase mode
|
||||||
elif args.action == 'erase':
|
elif args.action == 'erase':
|
||||||
|
|||||||
1
dist/tools/bmp/requirements.txt
vendored
1
dist/tools/bmp/requirements.txt
vendored
@ -1,4 +1,5 @@
|
|||||||
humanize
|
humanize
|
||||||
|
packaging
|
||||||
pygdbmi
|
pygdbmi
|
||||||
pyserial
|
pyserial
|
||||||
progressbar
|
progressbar
|
||||||
Loading…
x
Reference in New Issue
Block a user