-
Notifications
You must be signed in to change notification settings - Fork 2k
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: additional improvements to auto-detection #21128
base: master
Are you sure you want to change the base?
Conversation
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, looks good to me. I'll do a bit of testing later today
dist/tools/bmp/bmp.py
Outdated
@@ -258,9 +304,9 @@ def parse_args(): | |||
parser.add_argument('--tpwr', action='store_true', help='enable target power') | |||
parser.add_argument('--serial', help='choose specific probe by serial number') | |||
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', type=int, default='1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser.add_argument('--attach', help='choose specific target by number', type=int, default='1') | |
parser.add_argument('--attach', help='choose specific target by number', type=int, default=1) |
As the type is int
, we can provide the default also as int
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a fixup commit to address this.
Contribution description
This extends the auto-detection logic by parsing the firmware version number from the device descriptor as returned by PySerial. For stable releases, this should return a proper version number, and restores out-of-the-box compatibility with older firmware versions.
The second improvements is to detect unsupported targets. The former message was a bit misleading. At least in v1.10.2 and v2.0.0 of the BMP, unsupported targets are prefixed with ***:
The improvement will detect this, and report back. If the user tries attach to the chosen target, a proper error will occur.
Lastly, some code improvements are added as well. Most of them were suggested by @maribu in a patch that laid the groundwork for auto-detection.
Testing procedure
Use the tool with firmware versions 1.8.0 - 2.0.0-rc1.
Issues/PRs references
Follow-up of #21107.