1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

16 Commits

Author SHA1 Message Date
Bas Stottelaar
8c61fa97f3 dist/tools/bmp: in-line dependencies using PEP 723
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
2025-06-10 14:58:38 +02:00
Bas Stottelaar
b27eb50a19 dist/tools/bmp: detect unsupported targets
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.
2025-02-02 23:10:23 +01:00
Bas Stottelaar
b07f32d2ab dist/tools/bmp: improve auto-detection of firmware
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.
2025-02-02 23:10:23 +01:00
Bas Stottelaar
7a1128fb4a dist/tools/bmp: use f-strings in stead of interpolation 2025-02-02 23:10:22 +01:00
Bas Stottelaar
3d3f0f9623 dist/tools/bmp: set argument type 2025-02-02 23:10:22 +01:00
Bas Stottelaar
a96a43908e dist/tools/bmp: add as author 2024-12-23 23:03:54 +01:00
Bas Stottelaar
9efc41dbf4 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.
2024-12-23 23:00:14 +01:00
Bas Stottelaar
96dbd33507 dist/tools/bmp: revisit probe detection
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.
2024-12-23 23:00:14 +01:00
Bas Stottelaar
e55da6ad82 dist/tools/bmp: add logging
Print action to console for reset and flash action, similar to the
erase action.
2024-12-23 22:58:20 +01:00
Bas Stottelaar
c57fe9bd79 dist/tools/bmp: restructure to meet conventions
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.
2024-12-23 22:58:20 +01:00
Bas Stottelaar
7c36145eea dist/tools/bmp: replace distutils with shutil
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.
2024-12-23 22:58:20 +01:00
Marian Buschsieweke
c56f50a2eb
dist/tools/bmp: fix target parsing
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
2024-05-09 12:56:01 +02:00
Alain Péteut
25df307ea1 dist/tools: Use /usr/bin/env to lookup Python.
Fixes some Python scripts which didn't use `/usr/bin/env`.
2023-04-10 14:39:42 +02:00
Alexandre Abadie
438464b5fa
dist/tools/bmp: fix flake8 issue E741
E741: ambiguous variable name
2021-01-07 19:11:20 +01:00
Marian Buschsieweke
71b2860322
dist/tools/bmp: Fix flashing with pygdbmi 0.10.0
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.
2020-11-03 16:33:46 +01:00
Maximilian Deubel
30f12c9058 Add helper script for Black Magic Probe
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.
2019-10-15 12:58:24 +02:00