blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.3k stars 775 forks source link

BMP_Hosted crashes on Windows; Segmentation Fault when using blackmagic -t #998

Closed sthwithelectronics closed 2 years ago

sthwithelectronics commented 2 years ago

I compiled current firmware (commit:e82d4f2) under mingw64 with make PROBE_HOST=hosted HOSTED_BMP_ONLY=0

Running blackmagic -t crashes with following output: $ ./blackmagic -t Segmentation fault

The command blackmagic runs until gdb client connects and the 'run s' command is send. Then it crashes with Segmentation fault.

On the recommendation of the discord I ran blackmagic -t in gdb producing this output.

Reading symbols from ./blackmagic.exe...
(gdb) r
Starting program: C:\msys64\home\#######\001_BlackMagicProbe\blackmagic\src\blackmagic.exe -t
[New Thread 19360.0x7cc4]
[New Thread 19360.0x3d84]
[New Thread 19360.0x4978]
[New Thread 19360.0x581c]

Thread 1 received signal SIGSEGV, Segmentation fault.
send_recv (link=0x2a5fae1e7d0, txbuf=txbuf@entry=0xcbf8bff840 "▒<\001", txsize=txsize@entry=16, rxbuf=rxbuf@entry=0xcbf8bff83e "", rxsize=rxsize@entry=2) at platforms/hosted/bmp_libusb.c:395
395                     libusb_fill_bulk_transfer(link->req_trans,
(gdb) bt
#0  send_recv (link=0x2a5fae1e7d0, txbuf=txbuf@entry=0xcbf8bff840 "▒<\001",
    txsize=txsize@entry=16, rxbuf=rxbuf@entry=0xcbf8bff83e "",
    rxsize=rxsize@entry=2) at platforms/hosted/bmp_libusb.c:395
#1  0x00007ff7e3d4f148 in stlink_srst_set_val (
    info=info@entry=0x7ff7e3d7a160 <info>, assert=<optimized out>)
    at platforms/hosted/stlinkv2.c:625
#2  0x00007ff7e3d3e779 in platform_srst_set_val (assert=<optimized out>)
    at platforms/hosted/platform.c:288
#3  0x00007ff7e3d4b41f in cl_execute (opt=opt@entry=0x7ff7e3d7a5e0 <cl_opts>)
    at platforms/pc/cl_utils.c:372
#4  0x00007ff7e3d3e5ae in platform_init (argc=argc@entry=2,
    argv=argv@entry=0x2a5fae14bc0) at platforms/hosted/platform.c:112
#5  0x00007ff7e3d61523 in main (argc=2, argv=0x2a5fae14bc0) at main.c:37
(gdb) 

Going back to the stable release v.1.7.1 resolved the problem Running blackmagic -t outputs:

./blackmagic -t
INFO: Open USB 0424:5807 failed
V2J39M27
Leaving MASS Mode
Running in Test Mode
Target voltage: 3.24V Volt
Leaving MASS Mode
Enter SWD
Read Core ID: 0x0bc11477
RESET_SEQ failed
AP   0: IDR=04770031 CFG=00000000 BASE=f0000003 CSW=03000040
ROM: Table BASE=0xf0000000 SYSMEM=0x1, PIDR 0x00000a0460
ROM: Table BASE=0xe00ff000 SYSMEM=0x1, PIDR 0x04000bb4c0
 0 0xe000e000: Generic IP component - Cortex-M0 SCS (System Control Space) (PIDR = 0x04000bb008  DEVTYPE = 0x00 ARCHID = 0x0000) -> cortexm_probe
 1 0xe0001000: Generic IP component - Cortex-M0 DWT (Data Watchpoint and Trace) (PIDR = 0x04000bb00a  DEVTYPE = 0x00 ARCHID = 0x0000)
 2 0xe0002000: Generic IP component - Cortex-M0 BPU (Breakpoint Unit) (PIDR = 0x04000bb00b  DEVTYPE = 0x00 ARCHID = 0x0000)
 ROM: Table END
1 Entry 0x200002 -> Not present
2 Entry 0x10000002 -> Not present
3 Entry 0x10000002 -> Not present
ROM: Table END
***  1      STM32G07 M0+
Ram   Start: 0x20000000, length    0x9000
Flash Start: 0x08000000, length   0x20000, blocksize    0x800
Using 0483:374b 0667FF383337554E43194125 STMicroelectronics STM32 STLink
dragonmux commented 2 years ago

We've started putting a branch together that attempts to fix this. Please let us know @sthwithelectronics if what we've done still shows an issue or if even what we did fixes it. Also, could you reply with what debug dongle you are using and the output of lsusb -vd <vid>:<pid> on it? Starting to suspect that some of the code doing dongle detection is off and might be causing additional problems here.