blackmagic-debug / blackmagic

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

`load` works every second time #420

Closed nickray closed 2 years ago

nickray commented 5 years ago

Hi

I have converted one RobotDyn "Black Pill" to a BMP, and am flashing to a second same board. Everything works, but every other load fails:

(gdb) load
Error erasing flash with vFlashErase packet
(gdb) load
Loading section .vector_table, size 0x130 lma 0x8000000
Loading section .text, size 0x4ff2 lma 0x8000130
Loading section .rodata, size 0xf40 lma 0x8005140
Start address 0x8004fb2, load size 24674
Transfer rate: 18 KB/sec, 949 bytes/write.
(gdb) load
Error erasing flash with vFlashErase packet
(gdb) load
Loading section .vector_table, size 0x130 lma 0x8000000
Loading section .text, size 0x4ff2 lma 0x8000130
Loading section .rodata, size 0xf40 lma 0x8005140
Start address 0x8004fb2, load size 24674
Transfer rate: 18 KB/sec, 949 bytes/write.

Any ideas how I can debug this? I can workaround by just running the flashing twice, one of them will work :)

I'm using a simple gdb script:

target extended-remote /dev/ttyBmpGdb    
monitor swdp_scan    
attach 1    
load    
compare-sections    
kill    
quit 
UweBonnes commented 5 years ago

Compile with "make ENABLE_DEBUG=1 PROBEHOST=..." . Run the gdb command by hand. Before scan, enable DEBUG and open the second usbuart.

hydra commented 5 years ago

so I ran into this today after upgrading one of my probes to latest master, however when building as suggested above I get this:

platforms/stm32/usbuart.c: In function 'rdi_write':
platforms/stm32/usbuart.c:264:6: error: 'debug_bmp' undeclared (first use in this function)
  if (debug_bmp)
      ^~~~~~~~~
platforms/stm32/usbuart.c:264:6: note: each undeclared identifier is reported only once for each function it appears in
platforms/stm32/usbuart.c:265:16: error: implicit declaration of function 'usbuart_debug_write'; did you mean 'usbuart_usb_in_cb'? [-Werror=implicit-function-declaration]
   return len - usbuart_debug_write(buf, len);
                ^~~~~~~~~~~~~~~~~~~
                usbuart_usb_in_cb
platforms/stm32/usbuart.c: At top level:
cc1.exe: error: unrecognized command line option '-Wno-cast-function-type' [-Werror]
cc1.exe: all warnings being treated as errors
make[1]: *** [Makefile:75: usbuart.o] Error 1
make: *** [Makefile:9: all] Error 2
hydra commented 5 years ago

the missing debug_bmp was easily fixed in the code for the platform i'm using (baite).

then I got another error about incorrect print formatting, I'll raise a PR for that. was able to compile.

hydra commented 5 years ago

Managed to capture a failure.

I used the load command 4 times here, on the 3rd time it failed.

Using latest master + tasitgast baite patch + debug compilation fixes and an H750 CPU.

Console Log

$ arm-none-eabi-gdb -ex "target extended-remote COM5"
GNU gdb (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 8.1.0.20180315-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Remote debugging using COM5
(gdb) monitor debug_bmp enable
monitor swdp_scan
attach 1
Debug mode is enabled
(gdb) Target voltage: unknown
Available Targets:
No. Att Driver
 1      STM32H74x
(gdb) Attaching to Remote target
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x000002c6 in ?? ()
(gdb) load "build/SPRacingH7ZERO.elf"
Loading section .isr_vector, size 0x298 lma 0x8000000
Loading section .text, size 0x139e0 lma 0x8000298
Loading section .rodata, size 0x650 lma 0x8013c78
Loading section .ARM, size 0x8 lma 0x80142c8
Loading section .init_array, size 0x4 lma 0x80142d0
Loading section .fini_array, size 0x4 lma 0x80142d4
Loading section .data, size 0x170 lma 0x80142d8
Loading section .ram_d1_data, size 0x240 lma 0x8014448
Loading section .flash_xo, size 0x10c0 lma 0x8018000
Start address 0x80005d8, load size 87880
Transfer rate: 45 KB/sec, 915 bytes/write.
(gdb) load "build/SPRacingH7ZERO.elf"
Loading section .isr_vector, size 0x298 lma 0x8000000
Loading section .text, size 0x139e0 lma 0x8000298
Loading section .rodata, size 0x650 lma 0x8013c78
Loading section .ARM, size 0x8 lma 0x80142c8
Loading section .init_array, size 0x4 lma 0x80142d0
Loading section .fini_array, size 0x4 lma 0x80142d4
Loading section .data, size 0x170 lma 0x80142d8
Loading section .ram_d1_data, size 0x240 lma 0x8014448
Loading section .flash_xo, size 0x10c0 lma 0x8018000
Start address 0x80005d8, load size 87880
Transfer rate: 44 KB/sec, 915 bytes/write.
(gdb) load "build/SPRacingH7ZERO.elf"
Error erasing flash with vFlashErase packet
(gdb) load "build/SPRacingH7ZERO.elf"
Loading section .isr_vector, size 0x298 lma 0x8000000
Loading section .text, size 0x139e0 lma 0x8000298
Loading section .rodata, size 0x650 lma 0x8013c78
Loading section .ARM, size 0x8 lma 0x80142c8
Loading section .init_array, size 0x4 lma 0x80142d0
Loading section .fini_array, size 0x4 lma 0x80142d4
Loading section .data, size 0x170 lma 0x80142d8
Loading section .ram_d1_data, size 0x240 lma 0x8014448
Loading section .flash_xo, size 0x10c0 lma 0x8018000
Start address 0x80005d8, load size 87880
Transfer rate: 45 KB/sec, 915 bytes/write.
(gdb)

Debug log:

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2019.02.23 16:28:14 =~=~=~=~=~=~=~=~=~=~=~=
*** Unsupported packet: vMustReplyEmpty
*** Unsupported packet: Hg0
*** Unsupported packet: qTStatus
TARGETID 04500041
 AP   0: IDR=84770001 CFG=00000000 BASE=e00fe003 CSW=43800040
0xe000e000: Generic IP component - Cortex-M4 SCS (System Control Space)
-> cortexm_probe
0xe0001000: Generic IP component - Cortex-M3 DWT (Data Watchpoint and Trace)
0xe0002000: Generic IP component - Cortex-M7 FBP (Flash Patch and Breakpoint)
0xe0000000: Generic IP component - Cortex-M3 ITM (Instrumentation Trace Module)
0xe0041000: Debug component - Cortex-M7 ETM (Embedded Trace)
0xe0043000: Debug component - CoreSight CTI (Cross Trigger)
 AP   1: IDR=84770001 CFG=00000000 BASE=00000002 CSW=43800040
Fault reading ID registers
 AP   2: IDR=54770002 CFG=00000000 BASE=e00e0003 CSW=80000040
0xe00e3000: 0x0 <- does not match preamble (0xB105000D)
0xe00e4000: 0x0 <- does not match preamble (0xB105000D)
0xe00e5000: PrimeCell peripheral - Unknown (PIDR = 0x4001bb101)
0xe00f1000: Debug component - CoreSight CTI (Cross Trigger)
0xe00f3000: Debug component - CoreSight CSTF (Trace Funnel)
0xe00f4000: Debug component - CoreSight TMC (Trace Memory Controller)
0xe00f5000: Debug component - CoreSight TPIU (Trace Port Interface Unit)
*** Unsupported packet: qC
*** Unsupported packet: Hg0
*** Unsupported packet: qfThreadInfo
*** Unsupported packet: qL1200000000000000000
m packet: addr = 2c6, len = 4
m packet: addr = 2c6, len = 2
Flash Erase 08000000 00020000
 started cr 00000034 sr 00000005
Flash Write 08000000 00000298
Flash Write 08000298 000003C8
Flash Write 08000660 000003B0
Flash Write 08000A10 000003C0
Flash Write 08000DD0 000003C0
Flash Write 08001190 000003D0
Flash Write 08001560 000003D0
Flash Write 08001930 000003B0
Flash Write 08001CE0 000003D0
Flash Write 080020B0 000003C0
Flash Write 08002470 000003C0
Flash Write 08002830 000003C0
Flash Write 08002BF0 000003C0
Flash Write 08002FB0 000003D0
Flash Write 08003380 000003D0
Flash Write 08003750 000003E0
Flash Write 08003B30 000003D0
Flash Write 08003F00 000003C0
Flash Write 080042C0 000003C0
Flash Write 08004680 000003C0
Flash Write 08004A40 000003D0
Flash Write 08004E10 000003E0
Flash Write 080051F0 000003D0
Flash Write 080055C0 000003D0
Flash Write 08005990 000003C0
Flash Write 08005D50 000003D0
Flash Write 08006120 000003C0
Flash Write 080064E0 000003C0
Flash Write 080068A0 000003C0
Flash Write 08006C60 000003D0
Flash Write 08007030 000003B0
Flash Write 080073E0 000003C0
Flash Write 080077A0 000003B0
Flash Write 08007B50 000003C0
Flash Write 08007F10 000003C0
Flash Write 080082D0 000003D0
Flash Write 080086A0 000003C0
Flash Write 08008A60 000003C0
Flash Write 08008E20 000003D0
Flash Write 080091F0 000003D0
Flash Write 080095C0 000003E0
Flash Write 080099A0 000003D0
Flash Write 08009D70 000003D0
Flash Write 0800A140 000003C0
Flash Write 0800A500 000003D0
Flash Write 0800A8D0 000003E0
Flash Write 0800ACB0 000003D0
Flash Write 0800B080 000003D0
Flash Write 0800B450 000003D0
Flash Write 0800B820 000003E0
Flash Write 0800BC00 000003D0
Flash Write 0800BFD0 000003D0
Flash Write 0800C3A0 000003D0
Flash Write 0800C770 000003D0
Flash Write 0800CB40 000003C0
Flash Write 0800CF00 000003C0
Flash Write 0800D2C0 000003D0
Flash Write 0800D690 000003C0
Flash Write 0800DA50 000003B0
Flash Write 0800DE00 000003D0
Flash Write 0800E1D0 000003D0
Flash Write 0800E5A0 000003C0
Flash Write 0800E960 000003C0
Flash Write 0800ED20 000003C0
Flash Write 0800F0E0 000003D0
Flash Write 0800F4B0 000003D0
Flash Write 0800F880 000003D0
Flash Write 0800FC50 000003D0
Flash Write 08010020 000003D0
Flash Write 080103F0 000003E0
Flash Write 080107D0 000003C0
Flash Write 08010B90 000003B0
Flash Write 08010F40 000003B0
Flash Write 080112F0 00000390
Flash Write 08011680 000003D0
Flash Write 08011A50 000003D0
Flash Write 08011E20 000003D0
Flash Write 080121F0 000003D0
Flash Write 080125C0 000003E0
Flash Write 080129A0 000003E0
Flash Write 08012D80 000003E0
Flash Write 08013160 000003E0
Flash Write 08013540 000003D0
Flash Write 08013910 00000368
Flash Write 08013C78 000003D8
Flash Write 08014050 00000278
Flash Write 080142C8 00000008
Flash Write 080142D0 00000004
Flash Write 080142D4 00000004
Flash Write 080142D8 00000170
Flash Write 08014448 00000240
Flash Write 08018000 000003C0
Flash Write 080183C0 000003D0
Flash Write 08018790 000003D0
Flash Write 08018B60 000003D0
Flash Write 08018F30 00000190
*** Unsupported packet: Pf=d8050008
Flash Erase 08000000 00020000
 started cr 00000034 sr 00000005
Flash Write 08000000 00000298
Flash Write 08000298 000003C8
Flash Write 08000660 000003B0
Flash Write 08000A10 000003C0
Flash Write 08000DD0 000003C0
Flash Write 08001190 000003D0
Flash Write 08001560 000003D0
Flash Write 08001930 000003B0
Flash Write 08001CE0 000003D0
Flash Write 080020B0 000003C0
Flash Write 08002470 000003C0
Flash Write 08002830 000003C0
Flash Write 08002BF0 000003C0
Flash Write 08002FB0 000003D0
Flash Write 08003380 000003D0
Flash Write 08003750 000003E0
Flash Write 08003B30 000003D0
Flash Write 08003F00 000003C0
Flash Write 080042C0 000003C0
Flash Write 08004680 000003C0
Flash Write 08004A40 000003D0
Flash Write 08004E10 000003E0
Flash Write 080051F0 000003D0
Flash Write 080055C0 000003D0
Flash Write 08005990 000003C0
Flash Write 08005D50 000003D0
Flash Write 08006120 000003C0
Flash Write 080064E0 000003C0
Flash Write 080068A0 000003C0
Flash Write 08006C60 000003D0
Flash Write 08007030 000003B0
Flash Write 080073E0 000003C0
Flash Write 080077A0 000003B0
Flash Write 08007B50 000003C0
Flash Write 08007F10 000003C0
Flash Write 080082D0 000003D0
Flash Write 080086A0 000003C0
Flash Write 08008A60 000003C0
Flash Write 08008E20 000003D0
Flash Write 080091F0 000003D0
Flash Write 080095C0 000003E0
Flash Write 080099A0 000003D0
Flash Write 08009D70 000003D0
Flash Write 0800A140 000003C0
Flash Write 0800A500 000003D0
Flash Write 0800A8D0 000003E0
Flash Write 0800ACB0 000003D0
Flash Write 0800B080 000003D0
Flash Write 0800B450 000003D0
Flash Write 0800B820 000003E0
Flash Write 0800BC00 000003D0
Flash Write 0800BFD0 000003D0
Flash Write 0800C3A0 000003D0
Flash Write 0800C770 000003D0
Flash Write 0800CB40 000003C0
Flash Write 0800CF00 000003C0
Flash Write 0800D2C0 000003D0
Flash Write 0800D690 000003C0
Flash Write 0800DA50 000003B0
Flash Write 0800DE00 000003D0
Flash Write 0800E1D0 000003D0
Flash Write 0800E5A0 000003C0
Flash Write 0800E960 000003C0
Flash Write 0800ED20 000003C0
Flash Write 0800F0E0 000003D0
Flash Write 0800F4B0 000003D0
Flash Write 0800F880 000003D0
Flash Write 0800FC50 000003D0
Flash Write 08010020 000003D0
Flash Write 080103F0 000003E0
Flash Write 080107D0 000003C0
Flash Write 08010B90 000003B0
Flash Write 08010F40 000003B0
Flash Write 080112F0 00000390
Flash Write 08011680 000003D0
Flash Write 08011A50 000003D0
Flash Write 08011E20 000003D0
Flash Write 080121F0 000003D0
Flash Write 080125C0 000003E0
Flash Write 080129A0 000003E0
Flash Write 08012D80 000003E0
Flash Write 08013160 000003E0
Flash Write 08013540 000003D0
Flash Write 08013910 00000368
Flash Write 08013C78 000003D8
Flash Write 08014050 00000278
Flash Write 080142C8 00000008
Flash Write 080142D0 00000004
Flash Write 080142D4 00000004
Flash Write 080142D8 00000170
Flash Write 08014448 00000240
Flash Write 08018000 000003C0
Flash Write 080183C0 000003D0
Flash Write 08018790 000003D0
Flash Write 08018B60 000003D0
Flash Write 08018F30 00000190
Flash Erase 08000000 00020000
 started cr 00000000 sr 00000000
stm32h7_flash_erase: comm failed
Flash Erase 08000000 00020000
 started cr 00000034 sr 00000005
Flash Write 08000000 00000298
Flash Write 08000298 000003C8
Flash Write 08000660 000003B0
Flash Write 08000A10 000003C0
Flash Write 08000DD0 000003C0
Flash Write 08001190 000003D0
Flash Write 08001560 000003D0
Flash Write 08001930 000003B0
Flash Write 08001CE0 000003D0
Flash Write 080020B0 000003C0
Flash Write 08002470 000003C0
Flash Write 08002830 000003C0
Flash Write 08002BF0 000003C0
Flash Write 08002FB0 000003D0
Flash Write 08003380 000003D0
Flash Write 08003750 000003E0
Flash Write 08003B30 000003D0
Flash Write 08003F00 000003C0
Flash Write 080042C0 000003C0
Flash Write 08004680 000003C0
Flash Write 08004A40 000003D0
Flash Write 08004E10 000003E0
Flash Write 080051F0 000003D0
Flash Write 080055C0 000003D0
Flash Write 08005990 000003C0
Flash Write 08005D50 000003D0
Flash Write 08006120 000003C0
Flash Write 080064E0 000003C0
Flash Write 080068A0 000003C0
Flash Write 08006C60 000003D0
Flash Write 08007030 000003B0
Flash Write 080073E0 000003C0
Flash Write 080077A0 000003B0
Flash Write 08007B50 000003C0
Flash Write 08007F10 000003C0
Flash Write 080082D0 000003D0
Flash Write 080086A0 000003C0
Flash Write 08008A60 000003C0
Flash Write 08008E20 000003D0
Flash Write 080091F0 000003D0
Flash Write 080095C0 000003E0
Flash Write 080099A0 000003D0
Flash Write 08009D70 000003D0
Flash Write 0800A140 000003C0
Flash Write 0800A500 000003D0
Flash Write 0800A8D0 000003E0
Flash Write 0800ACB0 000003D0
Flash Write 0800B080 000003D0
Flash Write 0800B450 000003D0
Flash Write 0800B820 000003E0
Flash Write 0800BC00 000003D0
Flash Write 0800BFD0 000003D0
Flash Write 0800C3A0 000003D0
Flash Write 0800C770 000003D0
Flash Write 0800CB40 000003C0
Flash Write 0800CF00 000003C0
Flash Write 0800D2C0 000003D0
Flash Write 0800D690 000003C0
Flash Write 0800DA50 000003B0
Flash Write 0800DE00 000003D0
Flash Write 0800E1D0 000003D0
Flash Write 0800E5A0 000003C0
Flash Write 0800E960 000003C0
Flash Write 0800ED20 000003C0
Flash Write 0800F0E0 000003D0
Flash Write 0800F4B0 000003D0
Flash Write 0800F880 000003D0
Flash Write 0800FC50 000003D0
Flash Write 08010020 000003D0
Flash Write 080103F0 000003E0
Flash Write 080107D0 000003C0
Flash Write 08010B90 000003B0
Flash Write 08010F40 000003B0
Flash Write 080112F0 00000390
Flash Write 08011680 000003D0
Flash Write 08011A50 000003D0
Flash Write 08011E20 000003D0
Flash Write 080121F0 000003D0
Flash Write 080125C0 000003E0
Flash Write 080129A0 000003E0
Flash Write 08012D80 000003E0
Flash Write 08013160 000003E0
Flash Write 08013540 000003D0
Flash Write 08013910 00000368
Flash Write 08013C78 000003D8
Flash Write 08014050 00000278
Flash Write 080142C8 00000008
Flash Write 080142D0 00000004
Flash Write 080142D4 00000004
Flash Write 080142D8 00000170
Flash Write 08014448 00000240
Flash Write 08018000 000003C0
Flash Write 080183C0 000003D0
Flash Write 08018790 000003D0
Flash Write 08018B60 000003D0
Flash Write 08018F30 00000190
UweBonnes commented 5 years ago

There is no baite platform in our master tree. What code base do you refer to?

hydra commented 5 years ago

The one from #274

@nickray was using a different one to me so not sure if it's probe specific.

esden commented 2 years ago

Is this still an issue? Any clues of what is going on? Maybe it is a marginal connection issue? This could also lead to intermittent programming issues.

hydra commented 2 years ago

@esden I've not seen this issue recently, and I've flashed a bunch of H750/H730 boards. The code I'm running on my BMP is built from commit f9414d58265093bf8a4ae59d45c3d1ac441d6ed2 from (master) which Baite support was also added into the STLINK probe_host.

esden commented 2 years ago

Thank you very much @hydra. In that case I will close this issue for now. If the problem comes back feel free to open a new issue and we can work on figuring it out. :)