Actions

EmSys

Difference between revisions of "VSCode Cortex-Debug Launch Configurations"

From EdWiki

m (OpenOCD GDB Server ("servertype": "openocd"))
m (OpenOCD GDB Server (servertype : openocd))
Line 21: Line 21:
 
There is one [http://openocd.org/ OpenOCD] specific parameter that must be supplied. The configFiles property takes an arrays of strings that are used to load openocd configuration files. These can either be a files in the openocd search path (like in this example), or a full path to your own configuration file. If you are using OpenOCD supplied files you typically will have either one file from the board section, or a file from the interface section and a file from the target section.
 
There is one [http://openocd.org/ OpenOCD] specific parameter that must be supplied. The configFiles property takes an arrays of strings that are used to load openocd configuration files. These can either be a files in the openocd search path (like in this example), or a full path to your own configuration file. If you are using OpenOCD supplied files you typically will have either one file from the board section, or a file from the interface section and a file from the target section.
  
* Open the VSCode launch configuration file ''launch.json'': '''Debug → Add Configuration...'''
+
* Open the VSCode launch configuration file ''launch.json'': '''Run → Add Configuration...'''
 
* Copy the following code
 
* Copy the following code
  

Revision as of 06:53, 23 March 2022

VSCode Cortex-Debug Launch Configurations

Cortex-Debug is an extension for Visual Studio Code to streamline your debug process when working with ARM Cortex-M microcontrollers. This document covers writing launch configurations (launch.json).

  • Open the VSCode user settings file settings.json: File → Preferences → Settings
  • Select User settings:
    Enter "json" in the search bar (with or without double quotes). Locate a link "Edit in settings.json" and click on it. This will open the file ~/.config/Code/User/settings.json
  • Add the following line to the settings.json file, between the curly braces {}:

"cortex-debug.armToolchainPath": "/opt/toolchains/gcc-arm-none-eabi-10.3-2021.10/bin/",


Please note: The paths on your system might be different. Make sure the path matches your actual file locations.

  • Save the file settings.json

OpenOCD GDB Server (servertype : openocd)

To the right is an example of a basic launch configuration using the OpenOCD GDB server.

In this configuration the device parameter is not required - but can be supplied to allow auto-selecting an appropriate SVD file if possible.

There is one OpenOCD specific parameter that must be supplied. The configFiles property takes an arrays of strings that are used to load openocd configuration files. These can either be a files in the openocd search path (like in this example), or a full path to your own configuration file. If you are using OpenOCD supplied files you typically will have either one file from the board section, or a file from the interface section and a file from the target section.

  • Open the VSCode launch configuration file launch.json: Run → Add Configuration...
  • Copy the following code
    "version": "0.2.0",
    "configurations": [
	{
	    "name": "Debug (OpenOCD)",
	    "cwd": "${workspaceRoot}",
	    "executable": "${workspaceRoot}/build/blinky.elf",
            "request": "launch",
	    "type": "cortex-debug",
	    "servertype": "openocd",
            "device": "TM4C123GH6PM",
            "runToMain": true,
            "svdFile": "${workspaceRoot}/svd/TM4C123GH6PM.svd",
	    "configFiles": [
		"board/ek-tm4c123gxl.cfg"
            ]
	}
    ]


  • Change "executable", "svdFile", and "device" parameter as appropriate and save it