Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dist/tools/bmp: improve compatibility #21107

Open
wants to merge 6 commits into from

Conversation

basilfx
Copy link
Member

@basilfx basilfx commented Dec 23, 2024

Contribution description

The Black Magic Probe is a great debugger. Current implementation does not work with more modern firmware versions, because some commands have been renamed. Further more, Python 3.12 deprecated the distutils package (removed in 3.13), so this tool did not work on my machine.

Compatibility with older firmware versions has been maintained (or at least, I tried). I first wanted to implement auto--detection of the firmware version, but that does not work with debug mode in the current state.

I also cleaned up the code a tiny bit, and made things a bit more logical (IMHO).

Before, port detection would always throw an exception if no debugger was found, even if --port was provided. I relaxed this check, which gives me the possibility to provide any port. In my particular use-case, I run the debugger via ser2net, so local detection would not work.

Created separate commits with all changes. Will squash once approved.

Testing procedure

I tested this as follows:

  • Locally: BOARD=some-board PROGRAMMER=bmp make flash|reset|debug|erase
  • Remotely: BOARD=some-board PROGRAMMER=bmp BMP_OPTIONS="--port 10.0.0.192:2000" make flash|reset|debug|erase.

Issues/PRs references

None

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.
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.
Print action to console for reset and flash action, similar to the
erase action.
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.
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.
@basilfx basilfx requested a review from maribu December 23, 2024 22:11
@basilfx basilfx requested a review from jia200x as a code owner December 23, 2024 22:11
@basilfx basilfx changed the title dist/tools/bmp: improve compatibility with Python 3.12+ and BMP 1.10+ dist/tools/bmp: improve compatibility with Python 3.12 and BMP 1.10 Dec 23, 2024
@basilfx basilfx changed the title dist/tools/bmp: improve compatibility with Python 3.12 and BMP 1.10 dist/tools/bmp: improve compatibility Dec 23, 2024
@github-actions github-actions bot added Area: doc Area: Documentation Area: tools Area: Supplementary tools labels Dec 23, 2024
@maribu
Copy link
Member

maribu commented Jan 10, 2025

Thx. This sadly adds a bit more overhead for the Jeff Probe, which is a very affordable but sadly uses an outdated downstream version of the BMP firmware.

I think I can add a best effort auto-detection of the firmware version that will work when pyudev is available (so only on Linux systems) and when the firmware is an actual release and not a dev snapshot. But that should restore the "just works" behavior for most users.

@maribu maribu enabled auto-merge January 10, 2025 14:58
@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 10, 2025
@riot-ci
Copy link

riot-ci commented Jan 10, 2025

Murdock results

✔️ PASSED

a96a439 dist/tools/bmp: add as author

Success Failures Total Runtime
1 0 1 01m:48s

Artifacts

@maribu maribu added this pull request to the merge queue Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: doc Area: Documentation Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants