PEP 723 is an accepted proposal to in-line script metadata. One such
use cases is to put script dependencies inside the script, which makes
the requirements.txt redundant [1].
With the correct shebang, it becomes even possible to run the script
directly, without creating a virtual environment and installing
dependencies in advance.
Combining both makes the execution of single-file scripts within RIOT
much easier and friendlier.
PEP 723 metadata can be used by `pipx` [2] and can be easily
installed when `pip` is available.
[1] `pip install` still requires a requirements.txt, which is
generally accepted during development. An open issue exists to
add support for reading dependencies from PEP 723 as well. See
https://github.com/pypa/pip/issues/12891
[2] https://github.com/pypa/pipx
Instead of listing 'no targets found', detect unsupported targets as
well. Once we need to attach, assert that the target is supported.
Starting with firmware 2.0.0 of the BMP, not all targets are supported
by defaults (depends on the firmware flavor). Adding support for this
case therefore makes sense.
Parse the version number from the product description as returned by
libusb. This works for stable firmware releases, and ensures that
older firmwares work out of the box.
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.
The tool would always exit if no probes are detected, even if `--port`
was provided. By making this assertion conditional, it becomes
possible to override the port in any case.
Use cases for this is running the BMP externally, and connecto to it
via ser2net, for example.
Per conventions:
- Put main code in a function.
- Move argument parsing to separate function to not pollute global
scope. This does mean that all invocations now need `args` as an
additional argument.
Python 3.12 removed the `distutils` package, which is only used for
checking if GDB is available on PATH.
The `shutil.which` method does the same, and is available since
Python 3.3.
Either GDB or pygdbmi changed behavior to trim off whitespace following
the message, resulting in the `\\n` at the end of the regex no longer
matching. This replaces the `\\n` with `\s*` to match both old and new
output.
Fixes: https://github.com/RIOT-OS/RIOT/issues/20604
The flashing script for the black magic probe stopped working with pygdbmi in
version 0.10.0 due to an API change. This adapts the code to first try
initialization with the old pygdbmi API (as before), but tries again with the
new API if that fails.
This script can detect [Black Magic Probes](https://github.com/blacksphere/blackmagic/wiki) and act as a flashloader (and more).
It is compatible with Linux and macOS.
All important options that can be set via the monitor command are available as arguments.
Makefiles for using `make flash`, `make erase`, `make debug` and `make term` with the script are included.