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] 2  Send TopicPrint
Very Hot Topic (More than 25 Replies) How to configure new debugging (Read 11034 times)
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
How to configure new debugging
May 2nd, 2019 at 9:11am
Print Post  
Now that we have gdb build-in I want to know how to configure it. I have searched for it but cannot find it. I want to debug my project using a Black Magic Probe(Build in gdb server and uart). How can I configure it.
Also how does this debug implementation work? Can I set breakpoints while the program is running or do I need to pause it like with gdb itself and does hovering over variables while the program is paused shows the value?

I am using Visual Studio 2019 with the latest Visual Micro version
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to configure new debugging
Reply #1 - May 2nd, 2019 at 11:55am
Print Post  
Many boards will have preconfigured gdb but it's easy to add your own. Do you know the ocd/gdb program command for your board with black magic? If not then which board do want to debug?


note:

We have some docs coming over the next few weeks. There will also be some enhancements over the next week so switch on notifications for https://www.visualmicro.com/forums/YaBB.pl?board=VS_ARDUINO_EXT_RELEASES

« Last Edit: May 2nd, 2019 at 12:30pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #2 - May 2nd, 2019 at 12:26pm
Print Post  
Yes. I do know the exact command that is used to start debugging. It needs the folder to the compiled .ino.elf file, the .ino.elf file name and a comport.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to configure new debugging
Reply #3 - May 2nd, 2019 at 12:44pm
Print Post  
This is an advanced hard coded example to get you going quickly...

1)
If you click "vMicro>Add Code" there is an option for "Customer MI Debugger". This simply adds a .json file to your project.

However the only properties you might need are to set the MIDebugger to the full path of your gdb.exe and if you need OpenOCD set that in debugServer.Path The arguments for OpenOCD such as -s and -f .cfg do in the debugServerArgs

Then you set your port, normally localhost:3333 into the MIDebuggerAddress

Code (C++)
Select All
"MIDebuggerServerAddress": "localhost: 3333",
  "MIDebuggerPath": "c:\\mygdb\\gdb.exe",
  "debugServerPath": "c:\\myopenocd\\bin\\openocd.exe",
  "debugServerArgs": "-s \"c:\\myopenocd\\scripts\" -f\"c:\\myopenocd\\scripts\\boards\\myboard.cfg\"" ,
 



2)
If you switch on "vMicro>Uploader>Verbose build messages" the "Micro Build" output window will show you your final json output before the debugger launches.

3)
For some boards, click the project name in the solution explorer and set the "extra flags" to -O0 which switches off compiler code optimization. nb: In visual micro there will shortly be separate optimization settings for:- project, libraries and core (currently this one setting affects all three types).


Note: a fix due today or tomorrow allows non-ino code in the actual project to be debugged more easily. Currently gdb will think the cpp code in the project is located in the build folder instead of the project folder. This confuses the debugger. This current version should debug ino code, libraries and core okay so it's 80% there.

As I have said, this is the quick solution which means you have to provide paths and args yourself. The final solution will be easier but this advanced route will still be supported.
« Last Edit: May 2nd, 2019 at 1:01pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #4 - May 2nd, 2019 at 1:40pm
Print Post  
The example you gave me does use openocd and I only use gdb with "target extended-remote \\.\{COMPORT}"
I cannot figure out how to use it.
The arguments to GDB that I use are these
{Path to GDB EXE} -cd "{Path to compiled files}"  -ex "file {fileName.ino.elf}" -nh -b 115200 -ex "target extended-remote \\.\{ComPort}" -ex "monitor swdp_scan" -ex "attach 1" -ex "set confirm off" -ex "stop" -ex "mon erase_mass" -ex "load"  -ex "tbreak setup" -ex "run"
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to configure new debugging
Reply #5 - May 2nd, 2019 at 5:02pm
Print Post  
We will document com port access over the coming week.

The Microsoft MI debugger does most of the stuff for you. You probably only need {Path to GDB EXE}

Now that I know you have a black magic probe that is useful but you did not answer my question about which board and/or mcu you are using.

There is a link at the top of the example debugger .json that takes you to the Microsoft MI documentation


« Last Edit: May 2nd, 2019 at 5:11pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #6 - May 2nd, 2019 at 5:22pm
Print Post  
The boards I use are Bluepills(STM32F103C8T6) and some other STM32F1 and F4 boards. All use the command from above and they all work fine. 
I will try to config it tonight with the links provided and will wait for the documentation. Could you reply to this when the documentation is far enough for my case?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to configure new debugging
Reply #7 - May 3rd, 2019 at 1:20pm
Print Post  
I think we have a simple solution for you but for a simple example I need to know which stm32 core (bsp) you have installed?

What is the .json url to the package you are using for the stm boards?
  
Back to top
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #8 - May 3rd, 2019 at 1:24pm
Print Post  
I do not use a .json url I use the core from https://github.com/rogerclarkmelbourne/Arduino_STM32 for all STM32F1 related things.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to configure new debugging
Reply #9 - May 3rd, 2019 at 1:41pm
Print Post  
Great, yes docuuments\arduino\hardware defs also ok. Thanks
  
Back to top
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #10 - May 3rd, 2019 at 1:45pm
Print Post  
Yes, the command that I use is almost the same as the blackmagicprobe upload option
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to configure new debugging
Reply #11 - May 3rd, 2019 at 1:51pm
Print Post  
if you grab 1905.3 from the new releasessection of this forum then put this in a board.txt within the project folder.

Change the ComPort= to match your port.

Code (C++)
Select All
debug.tool=BlackMagic
tools.BlackMagic.ComPort=COM11
tools.BlackMagic.cmd=arm-none-eabi-gdb.exe
tools.BlackMagic.path={runtime.tools.arm-none-eabi-gcc.path}/bin
tools.BlackMagic.args= -cd "{build.project_path}"  -ex "file {{{build.path}/{build.project_name}.elf}}" -nh -b 115200 -ex "target extended-remote \\.\{ComPort}" -ex "monitor swdp_scan" -ex "attach 1"
 




That does too much but should work. In future releases, enabling the debugger will be simple menu options.
« Last Edit: May 3rd, 2019 at 1:53pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #12 - May 3rd, 2019 at 1:56pm
Print Post  
When I get home I will directly test it. It looks good. The only thing I need to to to debug it is to select my board and upload method? Or do I need to do some more things?
  
Back to top
 
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #13 - May 3rd, 2019 at 6:06pm
Print Post  
I tried the board.txt code and it doesn't work. I get a error https://prnt.sc/nk1ah8
Output from debug output
Code
Select All
=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"
The program '' has exited with code 42 (0x2a).
 



Output from micro build
Code
Select All
Uploading 'Arduino_TX' to 'Generic STM32F103C series' using 'COM21'
Uploader started for board Generic STM32F103C series
Upload method will be: bootloader
Uploading via Bootloader
Resetting to bootloader via Serial
Serial reset
Reset via USB Serial completed
i-gcc\4.8.3-2014q1\bin\arm-none-eabi-gdb -cd "C:\Users\Natsuki\AppData\Local\Temp\VMBuilds\ARDUIN~2\ARDUIN~4\Debug" -b 230400 -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 60" -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "set height 0" -ex "target extended-remote \\.\COM21" -ex "monitor swdp_scan" -ex "attach 1" -ex "x/wx 0x8000004" -ex "monitor erase_mass" -ex "echo 0x8000004 expect 0xffffffff after erase\n" -ex "x/wx 0x8000004" -ex "file Arduino_TX.ino.elf" -ex "load" -ex "x/wx 0x08000004" -ex "tbreak main" -ex "run" -ex "echo \n\n\nUpload finished!" -ex "quit"
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>
Target voltage: unknown
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/>.
Available Targets:
No. Att Driver
Remote debugging using \\.\COM21
 1      STM32F1 medium density
Attaching to Remote target
0x080006a4 in ?? ()
0x8000004:	0x08001dfd
0x8000004 expect 0xffffffff after erase
0x8000004:	0xffffffff
Reading symbols from ino.elf...done.
Loading section .text, size 0x6d1c lma 0x8000000
Loading section .ARM.exidx, size 0x8 lma 0x8006d20
Loading section .data, size 0xd60 lma 0x8006d28
Loading section .rodata, size 0x664 lma 0x8007a88
Start address 0x8002068, load size 33000
Transfer rate: 18 KB/sec, 916 bytes/write.
0x8000004 <__stm32_vector_table+4>:	0x08002069
Temporary breakpoint 1 at 0x8004c5e: file \STM32F1\cores\maple\main.cpp, line 38.
Starting program: ino.elf
Note: automatically using hardware breakpoints for read-only addresses.
Temporary breakpoint 1, main ()
    at \STM32F1\cores\maple\main.cpp:38
38	    setup();
	The upload process has finished.
# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: no_TX/Debug/
Upload finished!


# MI Debugger Properties
{
  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "ARM",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "",
  "cwd": _genericSTM32F103C\\Debug",
  "MIDebuggerPath": m-none-eabi-gcc\\4.8.3-2014q1/bin\\arm-none-eabi-gdb.exe",
  "debugServerPath": "",
  "debugServerArgs": "",
  "program": STM32F103C/Debug/Arduino_TX.ino.elf",
  "logging": {
    "moduleLoad": true,
    "trace": true,
    "engineLogging": true,
    "programOutput": true,
    "exceptions": true,
    "traceResponse": true
  },
  "setupCommands": [],
  "visualizerFile": _genericSTM32F103C\\Debug\\debugger_tmp.natvis",
  "showDisplayString": true
} 

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to configure new debugging
Reply #14 - May 3rd, 2019 at 6:55pm
Print Post  
That looks okay I just forgot to tell you to grab the last visual micro update which passed the .args

work in progress v 1905.3.0

https://www.visualmicro.com/forums/YaBB.pl?board=VS_ARDUINO_EXT_RELEASES
« Last Edit: May 3rd, 2019 at 6:56pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #15 - May 4th, 2019 at 10:57am
Print Post  
You did mention it that I need to install the new version and I did install it.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to configure new debugging
Reply #16 - May 4th, 2019 at 3:30pm
Print Post  
We need to see the output after debug>start or debug>attach is clicked. Last time is was clear the .args were not passed to the json (shown at the end of the build output)

We also need to know what version shows in "tools>extensions and updates>arduino ide for visual studio"
  
Back to top
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #17 - May 4th, 2019 at 7:04pm
Print Post  
I am now on version 1905.3.5 hoping that it worked but still the same error. Outputs are captured from debug>attach

Boards.txt content
Code
Select All
# Arduino_TX build property overrides
#




## GDB:     Example...
##          Arduino compatible GDB build variables can be used in conjunction with an optional debugger_launch.json
##		    vNicro supports these settings as variables using the same as the microsoft mi json spec.
##				for example:- $(debugServerPath) is the full ocd exe file name and path
##			Remove the # to activate these settings. This one variation of gdb + opencd as an example
##			Actual settings might differ for the various hardware.
##          Use 'vMicro>Compiler>Show Build Properties' to see existing build properties to assist
##

debug.tool=BlackMagic
tools.BlackMagic.ComPort=COM21
tools.BlackMagic.cmd=arm-none-eabi-gdb.exe
tools.BlackMagic.path={runtime.tools.arm-none-eabi-gcc.path}/bin
tools.BlackMagic.args= -cd "{build.project_path}"  -ex "file {{{build.path}/{build.project_name}.elf}}" -nh -b 115200 -ex "target extended-remote \\.\{ComPort}" -ex "monitor swdp_scan" -ex "attach 1"

 



The output of debug:
Code
Select All
=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"
The program '' has exited with code 42 (0x2a).
 



Output from micro-build:
Code
Select All
Using project build property overrides from ard.txt

# MI Debugger Properties
{
  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "ARM",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "",
  "cwd": _genericSTM32F103C\\Debug",
  "MIDebuggerPath": m-none-eabi-gcc\\4.8.3-2014q1/bin\\arm-none-eabi-gdb.exe",
  "debugServerPath": "",
  "debugServerArgs": "",
  "program": STM32F103C/Debug/Arduino_TX.ino.elf",
  "logging": {
    "moduleLoad": true,
    "trace": true,
    "engineLogging": true,
    "programOutput": true,
    "exceptions": true,
    "traceResponse": true
  },
  "setupCommands": [],
  "visualizerFile": _genericSTM32F103C\\Debug\\debugger_tmp.natvis",
  "showDisplayString": true
}
 

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to configure new debugging
Reply #18 - May 4th, 2019 at 7:08pm
Print Post  
Thanks, please use windows explorer to config that you do not have a debugger_launch.json in the project folder.
  
Back to top
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline


Posts: 25
Joined: Jan 18th, 2017
Re: How to configure new debugging
Reply #19 - May 4th, 2019 at 7:19pm
Print Post  
I did have a debugger_launch in my folder. When I deleted it debugging works sometimes. I will try to test debugging  but for now I am happy that I can test debugging in VS2019.

new output of microbuild:
Code
Select All
# MI Debugger Properties
{
  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "arm",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "",
  "cwd": _genericSTM32F103C\\Debug",
  "MIDebuggerPath": m-none-eabi-gcc\\4.8.3-2014q1/bin\\arm-none-eabi-gdb.exe",
  "MIDebuggerArgs": "-cd ino_TX\" -ex \"file 1_genericSTM32F103C\\Debug/Arduino_TX.ino.elf}}\" -nh -b 115200 -ex \"target extended-remote \\\\.\\COM21\" -ex \"monitor swdp_scan\" -ex \"attach 1\"",
  "debugServerPath": "",
  "debugServerArgs": "",
  "program": STM32F103C/Debug/Arduino_TX.ino.elf",
  "logging": {
    "moduleLoad": false,
    "trace": false,
    "engineLogging": false,
    "programOutput": false,
    "exceptions": false,
    "traceResponse": false
  },
  "visualizerFile": _genericSTM32F103C\\Debug\\debugger_tmp.natvis",
  "showDisplayString": true
} 

« Last Edit: May 4th, 2019 at 7:22pm by Natsuki-chan »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint