VS Arduino | |
Visual Micro >> Hardware Debugging (GDB, GDB WiFi, GDB Stub) >> How to configure new debugging
https://www.visualmicro.com/forums/YaBB.pl?num=1556788318 Message started by Natsuki-chan on May 2nd, 2019 at 9:11am |
Title: How to configure new debugging Post by Natsuki-chan on May 2nd, 2019 at 9: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 |
Title: Re: How to configure new debugging Post by Visual Micro on May 2nd, 2019 at 11:55am
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 |
Title: Re: How to configure new debugging Post by Natsuki-chan on May 2nd, 2019 at 12: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.
|
Title: Re: How to configure new debugging Post by Visual Micro on May 2nd, 2019 at 12: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++):
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. |
Title: Re: How to configure new debugging Post by Natsuki-chan on May 2nd, 2019 at 1: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" |
Title: Re: How to configure new debugging Post by Visual Micro on May 2nd, 2019 at 5: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 |
Title: Re: How to configure new debugging Post by Natsuki-chan on May 2nd, 2019 at 5: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? |
Title: Re: How to configure new debugging Post by Visual Micro on May 3rd, 2019 at 1: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? |
Title: Re: How to configure new debugging Post by Natsuki-chan on May 3rd, 2019 at 1:24pm
I do not use a .json url I use the core from https://github.com/rogerclarkmelbourne/Arduino_STM32 for all STM32F1 related things.
|
Title: Re: How to configure new debugging Post by Visual Micro on May 3rd, 2019 at 1:41pm
Great, yes docuuments\arduino\hardware defs also ok. Thanks
|
Title: Re: How to configure new debugging Post by Natsuki-chan on May 3rd, 2019 at 1:45pm
Yes, the command that I use is almost the same as the blackmagicprobe upload option
|
Title: Re: How to configure new debugging Post by Visual Micro on May 3rd, 2019 at 1: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++):
That does too much but should work. In future releases, enabling the debugger will be simple menu options. |
Title: Re: How to configure new debugging Post by Natsuki-chan on May 3rd, 2019 at 1: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?
|
Title: Re: How to configure new debugging Post by Natsuki-chan on May 3rd, 2019 at 6: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). [/code):
|
Title: Re: How to configure new debugging Post by Visual Micro on May 3rd, 2019 at 6: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 |
Title: Re: How to configure new debugging Post by Natsuki-chan on May 4th, 2019 at 10:57am
You did mention it that I need to install the new version and I did install it.
|
Title: Re: How to configure new debugging Post by Visual Micro on May 4th, 2019 at 3: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" |
Title: Re: How to configure new debugging Post by Natsuki-chan on May 4th, 2019 at 7: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" [/code):
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": [):
|
Title: Re: How to configure new debugging Post by Visual Micro on May 4th, 2019 at 7:08pm
Thanks, please use windows explorer to config that you do not have a debugger_launch.json in the project folder.
|
Title: Re: How to configure new debugging Post by Natsuki-chan on May 4th, 2019 at 7: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 }[/code] |
Title: Re: How to configure new debugging Post by Visual Micro on May 4th, 2019 at 7:38pm
Excellent that's a good start now. Any testing or feedback is great thanks.
We will be documenting and adding easier config menus over the coming few weeks. There will be quite a few options and also a difference in "launch" between "debug>start", "debug>step into" and "debug>attach" I think many of your "args" are not needed and others will be handled differently depending on the type of launch that is being used. I think first job would be to strip the args back as much as possible. The microsoft debugger already does a lot of it for us. such as:- Code (]tools.BlackMagic.args= -nh -b 115200 -ex "target extended-remote \\.\{ComPort}"[/code):
or [code]tools.BlackMagic.args= -nh -b 115200 -ex "target extended-remote \\.\{ComPort}" -ex "monitor swdp_scan" -ex "attach 1" [/code] I don't know what the -nh switch is. Maybe not required. |
Title: Re: How to configure new debugging Post by Visual Micro on May 4th, 2019 at 7:50pm
Also, for some boards you can try to add F4 Project Properties > extraflags=-O0
|
Title: Re: How to configure new debugging Post by Natsuki-chan on May 6th, 2019 at 6:51am
-nh switch is not really important I think. When searching it said this about the case "-nh Do not execute commands from ~/.gdbinit."
-ex "monitor swdp_scan" can be important. Some people might use JTAG instead of SWD -ex "target extended-remote \\.\{ComPort}" can be hard coded when using a blackmagic probe since it is required. I am not really sure about the baudrate. I think the upload script uses a higher one. It could be usefull to set a different comport for the included UART of the blackmagic probe and that when you start debugging that it opens the serial monitor with configured serialport. |
Title: Re: How to configure new debugging Post by Natsuki-chan on May 7th, 2019 at 6:43pm
After using debugging for a while I am seeing some pitfalls. I am used to debugging Java or C# and that I can pause and set breakpoints when I want. That is not the case here. If I pause or stop debugging VS2019 just freezes and setting breakpoints renders them as not active.
|
Title: Re: How to configure new debugging Post by Visual Micro on May 7th, 2019 at 6:51pm
This is not expected or what we have encountered. The tests we have made give 99% stable debug. However hardware debug does have limits on the number of break points.
I think it is best to wait for us to publish our release over the coming weeks that can handle the args and startup settings for you in a more flexible way and one that should give you a solid environment. I certainly don;t think the startup settings you used are correct for this type of environment. I am sure they are fine for manual debug but probably not for MI. If you would like us to look into your particular issue then please always provide full build output with "compiler>verbose, compiler>show build properties and uploader>verbose" otherwise we have to guess which doesn't help you :) |
Title: Re: How to configure new debugging Post by Natsuki-chan on May 7th, 2019 at 6:56pm
I will wait then. For now it work well enough considering it is still sort of beta. Can't wait for this feature to be more fleshed out.
|
Title: Re: How to configure new debugging Post by Visual Micro on May 7th, 2019 at 7:19pm
Great, yes we are looking forward to everyone enjoying it.
A few other points I am not sure if I made but you have not mentioned so I will mention them again because they might affect things. 1) set extraflags to -O0 in the Project Properties (F4 on project) 2) switch off vMicro>Compiler>Shared Cache for Cores 3) Ensure the tool bar is set to Debug and not Release |
VS Arduino » Powered by YaBB 2.6.12! YaBB Forum Software © 2000-2024. All Rights Reserved. |