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: additional improvements to auto-detection #21128

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

basilfx
Copy link
Member

@basilfx basilfx commented Jan 11, 2025

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.

found following Black Magic GDB servers:
        [/dev/cu.usbmodem81C986981] Serial: 81C98698 Firmware: 2.0.0 <- default 
connecting to [/dev/cu.usbmodem81C986981]...
auto-detected firmware version 2.0.0
GDB EXECUTABLE NOT FOUND! FALLING BACK TO /opt/homebrew/bin/arm-none-eabi-gdb
connecting successful.

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 ***:

(gdb) mon swd_scan
Target voltage: 3.3V
Please report unknown device with Designer 0x673 Part ID 0x801
Available Targets:
No. Att Driver
*** 1   Unknown ARM Cortex-M Designer 0x673 Part ID 0x801 M4

The improvement will detect this, and report back. If the user tries attach to the chosen target, a proper error will occur.

found following Black Magic GDB servers:
        [/dev/cu.usbmodem81C986981] Serial: 81C98698 Firmware: 2.0.0 <- default 
connecting to [/dev/cu.usbmodem81C986981]...
auto-detected firmware version 2.0.0
GDB EXECUTABLE NOT FOUND! FALLING BACK TO /opt/homebrew/bin/arm-none-eabi-gdb
connecting successful.
scanning using SWD...
found following targets:
        Unknown ARM Cortex-M Designer 0x673 Part ID 0x801 M4 (unsupported)

Traceback (most recent call last):
  File "/Users/basilfx/Desktop/Projecten/RIOT/RIOT_bmp/dist/tools/bmp/./bmp.py", line 376, in <module>
    main()
    ~~~~^^
  File "/Users/basilfx/Desktop/Projecten/RIOT/RIOT_bmp/dist/tools/bmp/./bmp.py", line 348, in main
    assert targets[args.attach - 1][0], "target unsupported by probe"

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.

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.
@basilfx basilfx requested a review from jia200x as a code owner January 11, 2025 22:45
@basilfx basilfx requested review from maribu and removed request for jia200x January 11, 2025 22:45
@github-actions github-actions bot added Area: doc Area: Documentation Area: tools Area: Supplementary tools labels Jan 11, 2025
Copy link
Member

@maribu maribu left a 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 Show resolved Hide resolved
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! Thanks a lot :)

@maribu maribu enabled auto-merge January 23, 2025 15:20
@maribu maribu disabled auto-merge January 23, 2025 15:20
@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 23, 2025
@maribu
Copy link
Member

maribu commented Jan 23, 2025

Let's squash, then we can merge :)

squash player dancing with racket in his hand

@riot-ci
Copy link

riot-ci commented Jan 23, 2025

Murdock results

✔️ PASSED

ab1f48c fixup! dist/tools/bmp: set argument type

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

Artifacts

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