Debugging Using Custom Hardware

You may want to alter the existing Hardware Debugger settings, or try out a completely new setup which isnt pre-configured in Visual Micro.

All steps are below, and this is added into your local project via the "debugger_launch.json" file, so is not lost via updates to Visual Micro / Visual Studio.

 

Further Information on Microsoft MI: https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md#customlaunchsetupcommands

 

VSCode Style Configuration 

Warning 16Warning:
This is the most intricate layer of configuration and will require setting paths to debugging tools.

Warning 16Warning:
This will override the debugger selections until the debugger_launch.json file is removed

 

 

Add debugger_launch.json

Right Click on the Project in Solution Explorer > Add > Custom GDB Debugger (Advanced)

This will create a [variant].[configuration_name][.]debugger_launch.json file which is the launch command passed to the Microsoft MI Debugger which powers the debugging in Visual Studio.

 

NOTE - All parameters are defaulted to the global parameters supplied by vMicro using the merge syntax $(optionName)

 

JSON NOTES -
  • GDB Paths can be obtained from another board, for the appropriate debuggers' location (review Micro Build output when attaching debugger to view final launch JSON)
  • COM Port is the port of the Black Magic Probe, not your Arduino DUE
  • JSON escaping for '\' > '\\' and '"' > '\"' (Visual Studio will perform this for you when pasting)
  • $(progam) and $(buildpath) will be automatically populated by vMicro


JSON Example - Setup Arduino Due on Black Magic with GDB

For this configuration we only need to launch GDB, so do not need to complete the debugServer properties.

{
 "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "arm",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "",
  "cwd": "$(buildPath)",
  "MIDebuggerPath": "C:\\Users\\vMicro\\AppData\\Local\\arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1\\bin\\arm-none-eabi-gdb.exe",
  "MIDebuggerArgs": "-nh -b 115200 -ex \"target extended-remote \\\\.\\COM52\" -ex \"monitor swdp_scan\" -ex \"attach 1\"",
  "debugServerPath": "",
  "debugServerArgs": "",
  "program": "$(program)",
  "logging": {
    "moduleLoad": false,
    "trace": false,
    "engineLogging": false,
    "programOutput": false,
    "exceptions": false,
    "traceResponse": false
  }
}

 

This results in the below command:- 

C:\Users\vMicro\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\bin\arm-none-eabi-gdb.exe -nh -b 115200 -ex \"target extended-remote \\.\COM52\" -ex \"monitor swdp_scan\" -ex \"attach 1\"

 

NOTE - GDB will be passed the ELF file automatically, from the program parameter.

 

 

JSON Example - Setup Arduino Due on Atmel ICE with OpenOCD + GDB

In this setup we need to run OpenOCD to interface with the debugger, and then GDB to interface with OpenOCD and MI.

 

# MI Debugger Properties
{
  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "arm",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "localhost:3333",
  "cwd": "$(buildPath)",
  "MIDebuggerPath": "C:\\Users\\Simon\\AppData\\Local\\arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin\\arm-none-eabi-gdb.exe",
  "MIDebuggerArgs": "",
  "debugServerPath": "C:\\ProgramData\\vmicro\\tools\\openocd-0.10.0.1\\bin/openocd.exe",
  "debugServerArgs": "-d2 -s \"C:\\ProgramData\\vmicro\\tools\\openocd-0.10.0.1/share/openocd/scripts/\" -c \"interface cmsis-dap\" -c \"cmsis_dap_vid_pid 0x03eb 0x2141\" -c \"set CHIPNAME at91sam3X8E\" -c \"source [find target/at91sam3ax_8x.cfg]\" -c \"init; reset halt\"",
  "program": "$(program)",
  "logging": {
    "moduleLoad": false,
    "trace": false,
    "engineLogging": false,
    "programOutput": false,
    "exceptions": false,
    "traceResponse": false
  }
}

This results in two commands running, one for the debugServer and one for the GDB Debugger

"C:\ProgramData\vmicro\tools\openocd-0.10.0.1\bin/openocd.exe" -d2 -s "C:\ProgramData\vmicro\tools\openocd-0.10.0.1/share/openocd/scripts/" -c "interface cmsis-dap" -c "cmsis_dap_vid_pid 0x03eb 0x2141" -c "set CHIPNAME at91sam3X8E" -c "source [find target/at91sam3ax_8x.cfg]" -c "init; reset halt"

"C:\Users\Simon\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin\arm-none-eabi-gdb.exe" --interpreter=mi

NOTE - GDB will be passed the ELF file automatically, from the program parameter, as well as targeted to the MIDebuggerServerAddress to connect to OpenOCD

 

Got One Working?

Please Click here to Email us if you have built a working configuration you would like to see in Visual Micro!