Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Pages: 1 2 
Send Topic Print
How to configure new debugging (Read 1022 times)
Natsuki-chan
Junior Member
**
Offline



Posts: 16
How to configure new debugging
May 2nd, 2019 at 10:11am
 
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
 
Visual Micro
Administrator
*****
Offline



Posts: 10143
United Kingdom
Re: How to configure new debugging
Reply #1 - May 2nd, 2019 at 12:55pm
 
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

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



Posts: 16
Re: How to configure new debugging
Reply #2 - May 2nd, 2019 at 1:26pm
 
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
 
Visual Micro
Administrator
*****
Offline



Posts: 10143
United Kingdom
Re: How to configure new debugging
Reply #3 - May 2nd, 2019 at 1:44pm
 
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++):
"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.
Back to top
« Last Edit: May 2nd, 2019 at 2:01pm by Visual Micro »  
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline



Posts: 16
Re: How to configure new debugging
Reply #4 - May 2nd, 2019 at 2:40pm
 
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
 
Visual Micro
Administrator
*****
Offline



Posts: 10143
United Kingdom
Re: How to configure new debugging
Reply #5 - May 2nd, 2019 at 6:02pm
 
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


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



Posts: 16
Re: How to configure new debugging
Reply #6 - May 2nd, 2019 at 6:22pm
 
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
 
Visual Micro
Administrator
*****
Offline



Posts: 10143
United Kingdom
Re: How to configure new debugging
Reply #7 - May 3rd, 2019 at 2:20pm
 
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: 16
Re: How to configure new debugging
Reply #8 - May 3rd, 2019 at 2:24pm
 
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
 
Visual Micro
Administrator
*****
Offline



Posts: 10143
United Kingdom
Re: How to configure new debugging
Reply #9 - May 3rd, 2019 at 2:41pm
 
Great, yes docuuments\arduino\hardware defs also ok. Thanks
Back to top
 
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline



Posts: 16
Re: How to configure new debugging
Reply #10 - May 3rd, 2019 at 2:45pm
 
Yes, the command that I use is almost the same as the blackmagicprobe upload option
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10143
United Kingdom
Re: How to configure new debugging
Reply #11 - May 3rd, 2019 at 2:51pm
 
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++):
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.
Back to top
« Last Edit: May 3rd, 2019 at 2:53pm by Visual Micro »  
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline



Posts: 16
Re: How to configure new debugging
Reply #12 - May 3rd, 2019 at 2:56pm
 
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: 16
Re: How to configure new debugging
Reply #13 - May 3rd, 2019 at 7:06pm
 
I tried the board.txt code and it doesn't work. I get a error https://prnt.sc/nk1ah8
Output from debug output
Code:
=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:
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
F:\UserFiles\Documents\MEGA\Arduino\portable\packages\arduino\tools\arm-none-eabi-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 C:\Users\Natsuki\AppData\Local\Temp\VMBuilds\ARDUIN~2\ARDUIN~4\Debug\Arduino_TX.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 F:\UserFiles\Documents\MEGA\Arduino\portable\sketchbook\hardware\Arduino_STM32F1\STM32F1\cores\maple\main.cpp, line 38.
Starting program: C:\Users\Natsuki\AppData\Local\Temp\VMBuilds\ARDUIN~2\ARDUIN~4\Debug\Arduino_TX.ino.elf
Note: automatically using hardware breakpoints for read-only addresses.
Temporary breakpoint 1, main ()
    at F:\UserFiles\Documents\MEGA\Arduino\portable\sketchbook\hardware\Arduino_STM32F1\STM32F1\cores\maple\main.cpp:38
38	    setup();
	The upload process has finished.
# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: file:///F:/UserFiles/Documents/MEGA/Projects/ArduinoProjects/Arduino_RX_TX/Arduino_TX/Debug/
Upload finished!


# MI Debugger Properties
{
  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "ARM",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "",
  "cwd": "C:\\Users\\Natsuki\\AppData\\Local\\Temp\\VMBuilds\\Arduino_TX\\Arduino_STM32F1_genericSTM32F103C\\Debug",
  "MIDebuggerPath": "F:\\UserFiles\\Documents\\MEGA\\Arduino\\portable\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin\\arm-none-eabi-gdb.exe",
  "debugServerPath": "",
  "debugServerArgs": "",
  "program": "C:/Users/Natsuki/AppData/Local/Temp/VMBuilds/Arduino_TX/Arduino_STM32F1_genericSTM32F103C/Debug/Arduino_TX.ino.elf",
  "logging": {
    "moduleLoad": true,
    "trace": true,
    "engineLogging": true,
    "programOutput": true,
    "exceptions": true,
    "traceResponse": true
  },
  "setupCommands": [],
  "visualizerFile": "C:\\Users\\Natsuki\\AppData\\Local\\Temp\\VMBuilds\\Arduino_TX\\Arduino_STM32F1_genericSTM32F103C\\Debug\\debugger_tmp.natvis",
  "showDisplayString": true
} 

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



Posts: 10143
United Kingdom
Re: How to configure new debugging
Reply #14 - May 3rd, 2019 at 7:55pm
 
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
Back to top
« Last Edit: May 3rd, 2019 at 7:56pm by Visual Micro »  
WWW  
IP Logged
 
Natsuki-chan
Junior Member
**
Offline



Posts: 16
Re: How to configure new debugging
Reply #15 - May 4th, 2019 at 11:57am
 
You did mention it that I need to install the new version and I did install it.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10143
United Kingdom
Re: How to configure new debugging
Reply #16 - May 4th, 2019 at 4:30pm
 
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: 16
Re: How to configure new debugging
Reply #17 - May 4th, 2019 at 8:04pm
 
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:
# 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:
=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:
Using project build property overrides from F:\UserFiles\Documents\MEGA\Projects\ArduinoProjects\Arduino_RX_TX\Arduino_TX\board.txt

# MI Debugger Properties
{
  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "ARM",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "",
  "cwd": "C:\\Users\\Natsuki\\AppData\\Local\\Temp\\VMBuilds\\Arduino_TX\\Arduino_STM32F1_genericSTM32F103C\\Debug",
  "MIDebuggerPath": "F:\\UserFiles\\Documents\\MEGA\\Arduino\\portable\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin\\arm-none-eabi-gdb.exe",
  "debugServerPath": "",
  "debugServerArgs": "",
  "program": "C:/Users/Natsuki/AppData/Local/Temp/VMBuilds/Arduino_TX/Arduino_STM32F1_genericSTM32F103C/Debug/Arduino_TX.ino.elf",
  "logging": {
    "moduleLoad": true,
    "trace": true,
    "engineLogging": true,
    "programOutput": true,
    "exceptions": true,
    "traceResponse": true
  },
  "setupCommands": [],
  "visualizerFile": "C:\\Users\\Natsuki\\AppData\\Local\\Temp\\VMBuilds\\Arduino_TX\\Arduino_STM32F1_genericSTM32F103C\\Debug\\debugger_tmp.natvis",
  "showDisplayString": true
}
 

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



Posts: 10143
United Kingdom
Re: How to configure new debugging
Reply #18 - May 4th, 2019 at 8:08pm
 
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: 16
Re: How to configure new debugging
Reply #19 - May 4th, 2019 at 8:19pm
 
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:
# MI Debugger Properties
{
  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "arm",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "",
  "cwd": "C:\\Users\\Natsuki\\AppData\\Local\\Temp\\VMBuilds\\Arduino_TX\\Arduino_STM32F1_genericSTM32F103C\\Debug",
  "MIDebuggerPath": "F:\\UserFiles\\Documents\\MEGA\\Arduino\\portable\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin\\arm-none-eabi-gdb.exe",
  "MIDebuggerArgs": "-cd \"F:\\UserFiles\\Documents\\MEGA\\Projects\\ArduinoProjects\\Arduino_RX_TX\\Arduino_TX\" -ex \"file {{C:\\Users\\Natsuki\\AppData\\Local\\Temp\\VMBuilds\\Arduino_TX\\Arduino_STM32F1_genericSTM32F103C\\Debug/Arduino_TX.ino.elf}}\" -nh -b 115200 -ex \"target extended-remote \\\\.\\COM21\" -ex \"monitor swdp_scan\" -ex \"attach 1\"",
  "debugServerPath": "",
  "debugServerArgs": "",
  "program": "C:/Users/Natsuki/AppData/Local/Temp/VMBuilds/Arduino_TX/Arduino_STM32F1_genericSTM32F103C/Debug/Arduino_TX.ino.elf",
  "logging": {
    "moduleLoad": false,
    "trace": false,
    "engineLogging": false,
    "programOutput": false,
    "exceptions": false,
    "traceResponse": false
  },
  "visualizerFile": "C:\\Users\\Natsuki\\AppData\\Local\\Temp\\VMBuilds\\Arduino_TX\\Arduino_STM32F1_genericSTM32F103C\\Debug\\debugger_tmp.natvis",
  "showDisplayString": true
} 

Back to top
« Last Edit: May 4th, 2019 at 8:22pm by Natsuki-chan »  
 
IP Logged
 
Pages: 1 2 
Send Topic Print