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
base: master
Choose a base branch
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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant