Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: [1]  Send TopicPrint
Very Hot Topic (More than 25 Replies) How to debug with Black Magic Probe (BMP)? (Read 3138 times)
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
How to debug with Black Magic Probe (BMP)?
Sep 27th, 2020 at 8:24pm
Print Post  
Despite everything is set to Debug (see screenshot), using a BluePill-BMP to debug another BluePill board, the sketch is just uploaded but a breakpoint is not hit.
What is going wrong?

« Last Edit: Sep 27th, 2020 at 8:25pm by arduino1 »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #1 - Sep 28th, 2020 at 9:34am
Print Post  
Thanks for the report.

Would it be possible to attach the build log as shown at the top of the page (with Verbose and Show Build properties checked)?

If you could also attach the Micro Build log after trying to attach the debugger and any other debug output shown it will help us see what the problem is more clearly.
  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #2 - Sep 28th, 2020 at 4:02pm
Print Post  
In order to flash I have to set Boot0 to 1. Afterwards to run the sketch Boot0=0.
The Blink program runs after resetting.

Breakpoint is not hit.
Micro Build log in following message.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #3 - Sep 28th, 2020 at 4:03pm
Print Post  
Micro built log
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #4 - Sep 28th, 2020 at 4:37pm
Print Post  
Thanks, can you also enable the below options and re-send?

vMicro > Compiler > Show Build Properties
vMicro > Compiler > Verbose

Any output when using the debugger is also very helpful.
  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #5 - Sep 28th, 2020 at 7:34pm
Print Post  
This can't work for debugging because for flashing I have to set Boot0=1, then afterwards Boot0=0 and pressing reset button to run the program. 
The BMP is connected only to the 4-pin adapter of the target Blue Pill.
Are there additional connections required to avoid the need to switch the Boot0 jumper?
« Last Edit: Sep 28th, 2020 at 7:38pm by arduino1 »  
Back to top
 
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #6 - Sep 28th, 2020 at 8:39pm
Print Post  
After having added in the advanced configurations "HardwareSerial" to "Remote Transport" (maybe I had changed also something more) the propgram is uploaded and run with Boot0=0 permanently (no switching necessary anymore).
But the breakpoint is not hit.
In the Micro Build log there is the line
Temporary breakpoint 1 at 0x8002566: file 20.8.9\cores\maple\main.cpp, line 38.
Line 38 reads "setup();"
However, that file according to its date has not been changed for months. 
So, something seems to go wrong here.
  
Back to top
 
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #7 - Sep 29th, 2020 at 7:40am
Print Post  
I guess I have to give up.
Once the breakpoint was hit using "BMP" and "ARM".
But not working anymore.
Too many ununderstood options. Additionally there are those Jumpers on the Blue pill.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #8 - Sep 29th, 2020 at 10:20am
Print Post  
Thanks for the information so far.

Boot Jumpers - I am not aware of a workaround for this at present (but may depend on bootloader), so you have to perform the upload, move the jumper, reset the board, then press Debug > Attach to Process

20.8.9\cores\maple\main.cpp, line 38.
This implies you are trying to debug the core itself, if this is the case the optimization should be set to None on the vMicro > Debug Menu.  This file hasn't changed for a long time as it is part of the STM core.

The Remote Transport will have no effect on Hardware debugging as this is a setting reserved for the vMicro Serial Debugger.

To help us understand all of the environmental settings involved here, can you please supply:
1) Attach the logs requested previously
2) Confirm which BMP Firmware you have loaded onto the Blue-Pill acting as an BMP
3) Confirm which Bootloader Firmware you are using on the target Blue-Pill




  
Back to top
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #9 - Sep 29th, 2020 at 12:47pm
Print Post  
Off-Topic replies have been moved to this Topic.
  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #10 - Sep 30th, 2020 at 3:50pm
Print Post  
Simon, you have said:
"so you have to perform the upload, move the jumper, reset the board, then press Debug > Attach to Process"
Could you specify the jumper settings for upload and for debugging?
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #11 - Sep 30th, 2020 at 4:11pm
Print Post  
Its just the standard Boot0 Jumper settings (1 for upload, 0 and reset to run the code).
  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #12 - Oct 1st, 2020 at 4:03pm
Print Post  
I think I have a BMP running on a Bluepill, afrer all.
I can use it from the GDB command line, and the target starts blinking.
But in vmicro it does not work.
Attached is a sreenshot with the error blink.exe not found.
This is the output from the Debug log.
=thread-group-added,id="i1"
GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20140228-cvs
Copyright (C) 2013 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".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
=cmd-param-changed,param="pagination",value="off"
Das Programm "" wurde mit Code 42 (0x2a) beendet.

« Last Edit: Oct 1st, 2020 at 4:04pm by arduino1 »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #13 - Oct 1st, 2020 at 4:17pm
Print Post  
Thanks for the update.  To perform debugging in vMicro you need to set the Build Configuration to Debug (shown as Release at the top of your image)

Please attach:
1) The command line you launched this with manually
2) Set the vMicro > Upload > Verbose to ON, and try attaching in vMicro.  Then attach the output from the Output > Micro Build Window

  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #14 - Oct 1st, 2020 at 5:29pm
Print Post  
(GDB) output (Vmicro built output attached. When I switch the Boot0 Jumper and attach, the .exe file not found error pops up): 
H:\blackmagic>arm-none-eabi-gdb J:\temp\arduino_build_982994\Blink.ino.elf
H:\dev_tools\gcc-arm-8\bin\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 8.3.0.20190709-git
Copyright (C) 2019 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"...
Reading symbols from J:\temp\arduino_build_982994\Blink.ino.elf...
(gdb) target extended-remote COM6
Remote debugging using COM6
(gdb) mon s
Target voltage: 1.97V
Available Targets:
No. Att Driver
1      STM32F1 (clone) medium density M3
(gdb) att 1
Attaching to program: J:\temp\arduino_build_982994\Blink.ino.elf, Remote target
0x1ffff3b6 in ?? ()
(gdb) att 2
A program is being debugged already.  Kill it? (y or n) n
Not killed.
(gdb) att 1
A program is being debugged already.  Kill it? (y or n) n
Not killed.
(gdb) load
Loading section .text, size 0x25b0 lma 0x8000000
Loading section .ARM.exidx, size 0x8 lma 0x80025b0
Loading section .data, size 0x830 lma 0x80025b8
Loading section .rodata, size 0x354 lma 0x8002de8
Start address 0x8000170, load size 12604
Transfer rate: 30 KB/sec, 840 bytes/write.
(gdb) b main
Breakpoint 1 at 0x8001da8: file M:\Arduino_Sketchbook\hardware\Arduino_STM32\STM32F1\cores\maple\main.cpp, line 38.
(gdb) continue
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, main () at M:\Arduino_Sketchbook\hardware\Arduino_STM32\STM32F1\cores\maple\main.cpp:38
38          setup();
(gdb) continue
Continuing.

Program received signal SIGINT, Interrupt.
0x08001e76 in micros () at 8
58          do {
(gdb)
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #15 - Oct 2nd, 2020 at 11:00am
Print Post  
Thanks for the output, and it says it failed to upload the code to the target board at the end of the output.

I have checked my setup with 2 x STM Blue Pills:-
1) BMP Firmware as described in this Article
2) The Roger Clarke Core + Blink Sketch uploaded via Serial to the second board (checked this ran before adding debugging complexity)
3) Both Boards Boot0 Jumper set to 0
4) Once both connected and powered up, I used Debug > Attach To Process to begin the debugging session.

It all works as expected on my machines.

The reason VS may not be starting the debugging could be the wiring between the two boards, or power supply to either board in the first instances.
(If VS doesn't "see" the target through the debugger it will fail, unlike the command line which only needs to see the debugger to start)

Can you confirm you have them wired together as in the diagram below? (I had a similar error when the SWD connections were reversed)


NOTE: To get it to land on the breakpoint in the main.cpp, I had to Attach the debugger, set the breakpoint, then reset the target board.
  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #16 - Oct 2nd, 2020 at 1:23pm
Print Post  
It worked. I had to used that core before (but meanwhile also did other installations like Mingw32). I have not tested yet with the Maple core that I would need.
Remark: One does not need to press Reset nor Attach to process after uploading. It smoothly runs through without that.
Question: Is there a SWO communications pin?
Other BMP compilations do have that, but so far I had no luck with SWO output....
This keeps me up for a week now... paid Vmicro since it stopped working.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #17 - Oct 2nd, 2020 at 1:41pm
Print Post  
Glad to hear its working, and thanks for the feedback about the jumpers, and your support.

Reviewing the STM32F1 Pinout it appears to be on Pin PB3 (39):
https://components101.com/sites/default/files/component_pin/STM32-Blue-Pill-Deve...
« Last Edit: Oct 2nd, 2020 at 1:41pm by Simon@Visual Micro »  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #18 - Oct 2nd, 2020 at 2:52pm
Print Post  
Great! The LA shows output from the PB3 port, but where to connect that one to the BMP? When I connect to PA2 of the BMP, I see "raw" output on the BMP-UART interface port. But how to see the decoded output? 
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #19 - Oct 2nd, 2020 at 3:35pm
Print Post  
Reviewing the BMP Firmware configuration for the STLink Firmware (in use in this case):

Code
Select All
/* On F103, only USART1 is on AHB2 and can reach 4.5 MBaud at 72 MHz.*/
#define SWO_UART				USART1
#define SWO_UART_DR				USART1_DR
#define SWO_UART_CLK			RCC_USART1
#define SWO_UART_PORT			GPIOA
#define SWO_UART_RX_PIN			GPIO10
 



From my understanding this means it is on Port A (GPIOA register), Pin 10 (GPIO10), so A10 labelled on the board, or PA10 on this image:
https://components101.com/sites/default/files/component_pin/STM32-Blue-Pill-Deve...

Could you confirm for us what software you are using to read the SWO information? (the STLink Utility?)
  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #20 - Oct 2nd, 2020 at 4:04pm
Print Post  
Reading the SWO information via Serial Monitor plugin in Visual Studio. 
Is that the complete information?
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #21 - Oct 2nd, 2020 at 4:15pm
Print Post  
I see, thanks for the information and I'll look into this element further so we can update our documentation and tutorial videos.

Just one more question, are you using the SerialWireOutput Library to write to SWO or another method?
« Last Edit: Oct 2nd, 2020 at 4:29pm by Simon@Visual Micro »  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #22 - Oct 2nd, 2020 at 8:41pm
Print Post  
In order not to loose the whole stuff I spent hours to reproduce which BMP compilation I had used.
The only one that worked like I described above is this:
https://github.com/blacksphere/blackmagic/releases/tag/v1.7.1
I managed using Mingw32 to compile to a single blackmagic file and uploaded to the Blue pill using Cubeprogrammer. (I changed the Com port after upload and USB connection to that small number but that was not necessary, I had read that that also could be an issue)
Connections:
BMP: PA3-->Target BP: PB3
         A5                    SWCLK
         A14                  SWO
Does this answer your "one more Question"?
« Last Edit: Oct 2nd, 2020 at 8:43pm by arduino1 »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #23 - Oct 2nd, 2020 at 9:00pm
Print Post  
Understood, I thought you had used the pre-compiled BMP firmware we show in our tutorial on Arduino ProjectHub / YouTube.

I wanted to know what code you are using to initialise / write to SWO from your Arduino Sketch using the Roger Clarke Core?
(as from what I can see the SerialWireOutput Library I mentioned is only for the official STM32 Core.....)
  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #24 - Oct 3rd, 2020 at 7:45am
Print Post  
Using the BMP bin files you refer to doesn't work!!!
Blink in Arduino always yields mismatch at some address. 
That BMP.bin I finally used (see my link above) runs smoothly also in Vmicro.... 
Will be sticking to that, of course.
I used Generic STM32F1 series with submenue and the SerialWireOutput library with the example provided.

Is it possible to access the CPU registers?

Does BMP only work with that core? My application needs the Maple core.

  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #25 - Oct 3rd, 2020 at 10:03am
Print Post  
Thanks for the clarification, however I'm missing something as the two BIN files on our tutorial still work well for me (re-built my STM-BMP yesterday following these instructions).

I used the Roger Clarke core on the target as well, the BMP does work with both cores (though always recommend only one of the cores is installed at any one time, not both together).

Thanks for confirming the SWO element is with the official core.

The CPU Registers should be viewable once the Debug Session has started, from the VS Debug > Windows > Registers (at the bottom of the window list).
  
Back to top
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #26 - Oct 3rd, 2020 at 1:01pm
Print Post  
Anyway, do you need shuffling the Boot0 jumper and "attaching to process" with those BMP binaries? 
With my compilation it runs through fine (debugging) when leaving Boot0=0.

Main question: How to view the GPIO (Port) registers?
In CubeMXIDE they are called "SFR's" if I remember correctly.

Furthermore, on a fresh installed Win10 notebook neither Arduino IDE works  nor vmicro using the BMP with the same settings as in the main PC.
"Com10 port (being the GDB Server port) not found" -

Update: On the notebook PC I installed Mingw64 (don't know if essential for this issue).
Uninstalled Arduino. Loaded Arduino (portable). 
Deleted Arduino15. Started Arduino. Installed Due from Boardmanager. Installed STM32F1 boards (STMduino).
Result: Blink compiles with BMP and runs in Arduino and in vmicro without needing the reset button.

But, what about port register viewing in vmicro? Visual GDB needed?

« Last Edit: Oct 4th, 2020 at 1:14pm by arduino1 »  
Back to top
 
IP Logged
 
arduino1
Junior Member
**
Offline


Posts: 75
Joined: Feb 12th, 2015
Re: How to debug with Black Magic Probe (BMP)?
Reply #27 - Oct 5th, 2020 at 1:42pm
Print Post  
Can the port registers (STM32f103xx) be shown (and edited) in vmicro?
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: How to debug with Black Magic Probe (BMP)?
Reply #28 - Oct 5th, 2020 at 2:01pm
Print Post  
There is nothing specifically for this purpose in the hardware debugging at present, and we will look further into this.

To my knowledge the e.g. GPIOC register is resolved to a memory address at compile time, so this can be viewed in GDB, once the address is known using 'x'

There is a Digital / Analog Pin Viewer built into the vMicro Serial Debugger which allows the digital pin states to be altered, and analog pins graphed.
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to debug with Black Magic Probe (BMP)?
Reply #29 - Oct 14th, 2020 at 5:10pm
Print Post  
This Topic was moved here from Hardware Debugging (GDB, GDB WiFi, GDB Stub) [move by] Visual Micro.
  
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 
Send TopicPrint