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
Normal Topic Arduino Due & Black magic probe - Unable to start debugging (Read 1635 times)
vud
Newbies
*
Offline


Posts: 3
Joined: Dec 31st, 2022
Arduino Due & Black magic probe - Unable to start debugging
Jan 19th, 2023 at 2:13am
Print Post  
I'm using an Arduino Due board and a Black Magic probe v2.3b. Both "start" and "attach to process" methods do not work, but "attach to process" seems like it's close to working.

The BMP is running SW v1.9.0-rc0, HW revision 6. I am able to connect to it and attach to the Due through the command line using the commands:
"target extended-remote //./COM9"
"monitor swdp_scan"
[displays the Due]
"attach 1"
And I've been able to manually load the program's .elf to the debugger and attach to the Due that way.

In the Debug output (shown in the attached .txt file) it lists off several GDB commands. I've interacted with GDB through the command line (the same arm-none-eabi-gdb.exe Visual Micro uses), and I didn't run into any problems when I tried the same commands. COM9 is the correct port.

When I start debugging using "Start", it either displays the same thing as "Attach to process" (see .txt) or it says something like "debugging is not configured for this build" (it is, and it's a tossup as to which message it displays). "Attach to process" consistently shows what is seen in the .txt. 

This is when the optimization is set to "default optimizations" and the optimizations are disabled in the project's properties (Project -> Project Properties -> Configuration Properties -> C/C++ -> Optimization). 

"No optimizations" doesn't compile and gives me the error:
"core.a(UARTClass.cpp.o)*: In function HardwareSerial::HardwareSerial()
HardwareSerial.h:26: undefined reference to vtable for HardwareSerial"
The "No project" and "No project + libraries" optimization modes compiler, but they cause a popup box that says the same thing, regardless of if I try using "Start" or "Attach to process": 
"Unable to start debugging. Unexpected GDB output from command "-exec-run". Don't know how to run. Try "help target". 

I made sure to clean the solution when changing optimization levels. I've also tried every combination of restarting the Due and the black magic probe and starting them up in different orders.

I wanted to try everything I could before asking for help so I wouldn't waste anyone's time, but I'm stumped. Let me know if I missed anything.

I'm using Visual Micro Version 2.2022.1128, version minor 25 (the latest as of 18 Jan 2023). Windows 11 22H2 build 22621.1105. Visual Studio 2022 version 17.4.4. Using Arduino 2.
  

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


Posts: 2370
Joined: Feb 13th, 2019
Re: Arduino Due & Black magic probe - Unable to start debugging
Reply #1 - Jan 19th, 2023 at 12:48pm
Print Post  
Thanks for the report and the great detail.

Optimization: No Optimization
This is not supported on all cores and from the error it causes an issue with the HardwareSerial for this core, so optimization can only be disabled for Project/Libraries.  Optimization has no effect on the ability of the debugger to attach to the probe and target, and is best left as "Default".

"Debug > Start" vs "Debug > Attach to Process"
As you have already uploaded the code to your board via bootloader, "Debug > Attach to Process" should be all that is required.
"Debug > Start" will perform the code upload, and then try to attach the debugger in a single click.

BMP Firmware
From the BMP Firmware Releases, the version you have is a Release Candidate but not yet marked as stable.  This may be irrelevant but worth noting in case rolling this back improves the situation.

Proven CommandLine
The command we currently run in vMicro has a few more commands contained, it is noted in the attached file on the "# ORIG:" line.
If you use "vMicro > Add Code > Add Local Board.txt" and paste the contents of the attached file in, and save it, you can then use Debug > Attach to Process to run the same command you have used in CMD.exe in Visual Micro.

NOTE: Ensure there are no orphaned arm-none-eabi-gdb.exe processes before trying to attach in vMicro
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
vud
Newbies
*
Offline


Posts: 3
Joined: Dec 31st, 2022
Re: Arduino Due & Black magic probe - Unable to start debugging
Reply #2 - Jan 20th, 2023 at 4:13am
Print Post  
Thanks for the reply, but I'm still getting the same problem. I tried the shorter list of commands and that didn't change the output (but I did notice it was using the shorter set of commands that you attached). The commands work fine outside of Visual Studio/micro, and I mainly brought that up to show that my debugger is functional.

"Attach to process" does not work as it should. Check the text file attached to my original post for the output. I made sure there were no stray gdb processes running.

I've been messing around with it to try to figure anything out. I was able to load the .elf to the probe and view variables and functions by name via command line (one command at a time), but I had no way of controlling the program, so it wasn't very helpful. The breakpoints set in Visual Studio don't do anything and including them does not change the output file, which I confirmed by comparing hashes.

The only things I found that might be helpful is that the "start" command returns "Can't kill process" and then causes the probe to disconnect, and breakpoints (using the BKPT <imm8> instruction) cause the Due to hard fault, which I can tell by the PSR. Whether or not it's relevant, that's all I got.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2370
Joined: Feb 13th, 2019
Re: Arduino Due & Black magic probe - Unable to start debugging
Reply #3 - Jan 20th, 2023 at 11:26am
Print Post  
Thanks for the update.

The breakpoints are not stored in the ELF/BIN files, they are applied by VS when it connects to the debugging session as they would be setting them manually in a CMD session.

All VS > GDB Conversation can be revealed using the VS > View > Other Windows > Command Window, and then entering the command Debug.MIDebugLog /On /OutputWindow.  This should be the same as running via CMD, ensuring you load the ELF Symbols, and issuing the e.g. break loop() command once connected.

I have got my setup up and running again in Visual Micro, and it works as expected in vMicro with the default commands, and the shortened ones:
  • Win 11 22H2 Build 22621.1105
  • VS2022 (Version 17.5.0 Preview 2.0)
  • BMP Native Firmware: v1.7.1with usbser.sys driver 
  • BMP Hardware: Black Magic Probe Mini V2.1 (BMP21)
  • Arduino SAM Core 1.6.12 with Arduino 2 configuration
  • vMicro 2.2022.1128.25


I have tried various BMP Firmware's on my probe (loaded with DFU-Util) and found that 1.7.1 was the last one which would work in VS fully for some reason:
v1.8.2 - Fails in VS, OK via CMD
1.9.0-rc0 - Fails in VS, OK via CMD
If we can find out why this is we will update this thread.

Could you try downgrading your BMP firmware to v1.7.1, and also confirm if you are using an official probe or an alternative (STLINK/ESP8266/STM32F0 etc)?




« Last Edit: Jan 20th, 2023 at 11:28am by Simon@Visual Micro »  
Back to top
 
IP Logged
 
vud
Newbies
*
Offline


Posts: 3
Joined: Dec 31st, 2022
Re: Arduino Due & Black magic probe - Unable to start debugging
Reply #4 - Jan 20th, 2023 at 10:06pm
Print Post  
Thanks again, for all the info and the help. I'm new to debuggers and I couldn't do this without help. 

I forgot to try rolling back the firmware, but I got around to it today. The probe I'm using is v2.3b, which got supported in 1.8.0. I didn't realize it until after I flashed 1.7.1, which caused it to not respond when attached to the board. The latest stables are 1.8.0 and 1.8.2.

I've tried a few different firmware versions. I made a fresh project with an unmodified board.txt when testing these. All loaded with DFU-util:
1.7.1 - Doesn't work
1.8.0/1.8.2 - Fails in VS, iffy in CMD. They behave the same, and I've attached the output from "Attach to process". The error is different than the one I posted when I was on 1.9.0rc0. I want to add that, when interfacing with it via CLI, the probe had a 50/50 chance as to whether or not it was able to find the board with "monitor swdp_scan", or just outright freeze at "Target voltage 3.3v".
1.9.0-rc1 - Fails in VS, almost working in CMD. Similar result to 1.9.0-rc0. Output file attached. This firmware works well in the command line, more of the functions/commands work, it's very consistent, the only problem I'm having over CLI is I cannot add breakpoints. When I try to add a breakpoint to setup/main/loop I get this error, even after I deleted all breakpoints (and it shows no breakpoints):

"Warning:
Cannot insert hardware breakpoint [number].
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints."

I couldn't even get that far in 1.9.0rc0, for what it's worth. I'd like the convenience of debugging in VS if possible, but for the project I'm working on right now, just getting it set up in CLI would be huge.

I bought my board off of Adafruit's website. Here's the store link I used:
https://www.adafruit.com/product/3839

I'm going to test my ribbon cable connections later today, and I think I can get access to another PC, to see if it's something with my computer.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2370
Joined: Feb 13th, 2019
Re: Arduino Due & Black magic probe - Unable to start debugging
Reply #5 - Jan 31st, 2023 at 11:01am
Print Post  
Thanks for the update and detail.

The v1.9.0 release has now been stabilized and released, can you try flashing your probe with that version and see how it works in both CMD and VS?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint