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

BlackMagicProbe does not recognize nRF52 device #20604

Closed
chrysn opened this issue Apr 21, 2024 · 2 comments · Fixed by #20661
Closed

BlackMagicProbe does not recognize nRF52 device #20604

chrysn opened this issue Apr 21, 2024 · 2 comments · Fixed by #20661
Labels
Area: tools Area: Supplementary tools Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@chrysn
Copy link
Member

chrysn commented Apr 21, 2024

Description

Something in the bmp.py script goes wrong and can not enumerate the targets.

Steps to show that all relevant hardware works

  • Connect a BlackMagicProbe (I use v2.3 with the latest firmware v1.10.2) to a thingy:52
  • in examples/saul
$ make BOARD=thingy52 all
[...]
$ gdb-multiarch bin/thingy52/saul_example.elf
[...]
(gdb) target extended-remote /dev/ttyACM0
[...]
(gdb) monitor swdp_scan
Target voltage: 3.3V
Available Targets:
No. Att Driver
 1      Nordic nRF52 M4
 2      Nordic nRF52 Access Port 
(gdb) attach 1
[...]
(gdb) load
Loading section .text, size 0x6460 lma 0x0
Loading section .ARM.exidx, size 0x8 lma 0x6460
Loading section .eh_frame, size 0x88 lma 0x6468
Loading section .relocate, size 0xc0 lma 0x64f0
Start address 0x0000082c, load size 26032
Transfer rate: 41 KB/sec, 867 bytes/write.

So connectivity is there and all is fine.

Steps to reproduce the issue

In the same examples/saul,

$ make BOARD=thingy52 all flash term PROGRAMMER=bmp
[...]
/home/chrysn/git/RIOT/dist/tools/bmp/bmp.py  flash /home/chrysn/git/RIOT/examples/saul/bin/thingy52/saul_example.elf
found following Black Magic GDB servers:
        [/dev/ttyACM0] Serial: 81D6649A <- default 
connecting to [/dev/ttyACM0]...
connecting successful.
scanning using SWD...
Traceback (most recent call last):
  File "/home/chrysn/git/RIOT/dist/tools/bmp/bmp.py", line 270, in <module>
    gdbmi = connect_to_target(port)
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chrysn/git/RIOT/dist/tools/bmp/bmp.py", line 243, in connect_to_target
    assert len(targets) > 0, "no targets found"
           ^^^^^^^^^^^^^^^^
AssertionError: no targets found
make: *** [/home/chrysn/git/RIOT/examples/saul/../../Makefile.include:849: flash] Error 1

Expected results

BMP support is there, so it should just work.

Versions

Current RIOT HEAD, all requirements of bmp installed in a fresh venv.

Next steps

I'm a bit at a loss. Pinging @maz3max and @maribu who might have more insights.

@chrysn chrysn added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: tools Area: Supplementary tools labels Apr 21, 2024
@maribu
Copy link
Member

maribu commented Apr 21, 2024

To be honest, I have not used SWD boards without an integrated debugger for some time, so I didn't have the need to use BMP for ages.

Chances are good that this regression has been introduced some time ago. My first guess would be checking if it is a breaking API change in pygdbmi. In 9 out of 10 cases of a python script starting to fail at runtime and versions not being pinned, it is a breaking API change in one of the modules.

@crasbe
Copy link
Contributor

crasbe commented Apr 21, 2024

I don't have a BMP, but I have an idea how we could debug this:
Simply add a "print(res)" after this line: https://github.com/RIOT-OS/RIOT/blob/master/dist/tools/bmp/bmp.py#L238 and post the console output here.

This prints pygdbmi's interpretation of the gdp response. This should let us isolate if the fault lies in pygdbmi or in the bmp.py script.

maribu added a commit to maribu/RIOT that referenced this issue May 9, 2024
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: RIOT-OS#20604
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: tools Area: Supplementary tools Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants