Settings and commands - nRF Connect for VS Code
Skip to content

Settings and commands

Each of the extensions included in the nRF Connect for VS Code Extension Pack offer a variety of settings and commands that let you customize the extension behavior.

Overview of all settings and commands

For a full overview of settings and commands, click the Extensions icon from the Activity Bar. Then, click the extension's name and open the Feature Contributions tab.

nRF Connect commands in Feature Contributions

Access to commands

You can access all of the commands from Visual Studio Code's Command Palette. To open the Command Palette, click on View > Command Palette from the top menu bar.

Command Palette

Access to settings

You can access all of the settings from Visual Studio Code's Settings editor. To open Settings, click on File > Preferences > Settings from the top menu bar.

Settings editor

nRF Connect settings and commands

The section provides more details about a selection of useful settings for the nRF Connect extension.

Useful nRF Connect settings

To view all of the nRF Connect extension's settings, open the Settings editor and type nrf-connect.

nrf-connect.activeAppFollowActiveEditor

This configuration setting controls whether the extension will automatically switch to the application (and build configuration, if applicable) that the open file belongs to. Switching is the default behavior. When this setting is disabled, the active application will never change automatically.

nrf-connect.applicationOptions

This configuration setting handles the following additional options for the application:

Option Description
softreset If true, it applies the --softreset argument using reset instead of pin reset.
skipBuild If true, it skips the build step before flashing to the device.

For information about how to set these options, read How to add application-specific flash options.

nrf-connect.applications

This is one of the application sources for the extension.

Within the workspace options, this configuration setting controls which applications are listed in the Applications View. When a new application location is added to that setting, the extension checks the application directory for build directories and adds them to the Applications View.

To remove an application from this setting, use the Remove Application action in the Applications View. This action will not remove the application files from your machine.

nrf-connect.boardRoots

This configuration setting is used to track and find custom board folders. When you add a new board, its folder is automatically added as an entry to this setting. Entries from this list are then used to populate the Custom boards list in the Add Build Configuration page.

nrf-connect.debugging.justMyCode

You can use this configuration setting when debugging to show or hide internal functions of Zephyr and the nRF Connect SDK in Call Stack. The default setting is true, which hides the internal functions.

nrf-connect.defaultOpenAction

Use this setting to define the default action to take when Visual Studio Code asks you if you want to open an application. This can happen for example after you create a new application or when you open an application using the Browse samples action.

nrf-connect.deviceProvider

You can use this configuration setting to control which utility is used for device enumeration in the Connected Devices View. The extension allows you to choose between the following options:

  • nRF Util (nrfutil) - The default device provider, bundled with the extension. This is the recommended setting. The utility runs in the background and updates the list of devices automatically.
  • nrfjprog - An alternative to nRF Util, included in the nRF Command Line Tools.

nrf-connect.enableTelemetry

This setting enables collecting diagnostic data, as described in Telemetry. The setting depends on the Visual Studio Code's Telemetry Level setting (telemetry.telemetryLevel) being enabled.

nrf-connect.flash

The following settings are available for the flashing process:

  • nrf-connect.flash.erase - This setting triggers erasing of the entire flash before flashing, if available. It determines the default behavior of all flash tasks.
  • nrf-connect.flash.recover - This setting triggers using the --recover argument when flashing, if available. --recover erases all user available non-volatile memory and disables the read back protection mechanism, if enabled.
  • nrf-connect.flash.softreset - This setting triggers soft reset instead of full reset when flashing, if available. It adds the --softreset argument to the flashing command.

Each of these settings can be overridden by the respective custom flash task binding parameter. nrf-connect.flash.erase and nrf-connect.flash.softreset can be overridden by application-specific flash settings.

nrf-connect.nrfutil.home

This setting points to the home directory of the nRF Util tool, a modular command line tool that enables users to manage Nordic Semiconductor devices and support automation. Use it when you have custom installations of nrfutil-device and nrfutil-toolchain-manager and you do not want to use the bundled binaries of these tools.

nrf-connect.taskBindings

This property stores configuration for custom tasks that are executed in place of the standard Build, Pristine Build, Flash, and Erase and Flash To Board actions after you bind custom tasks to these actions. This property is stored in either the settings.json file or under the settings key in your workspace file, depending on the structure of your project. For information on the exact syntax to use and examples of possible bindings, see Binding custom tasks to actions.

nrf-connect.thirdpartyIntegration

This property maps the IDs of extensions that the nRF Connect for VS Code extension is integrated with, for example SonarLint.

nrf-connect.toolchain.path

This setting specifies the path of the toolchain installed by the Toolchain Manager and it overrides {nrf-connect.topdir}/toolchain. If neither is set, the toolchain will be expected to be located on PATH.

The nrf-connect.toolchain.path setting is automatically set to the ${nrf-connect.toolchain:VER} variable when a released version of the nRF Connect SDK Toolchain is installed and set to active in Manage toolchains, or through the nRF Connect: Select nRF Connect SDK Toolchain command. The variable is not used when the toolchain path is expected to be present on the system path (PATH).

For more information, see nRF Connect Toolchain path resolution.

nrf-connect.toolchainManager.indexURL

This setting specifies alternative toolchain indexes. Use this setting to manually define a custom toolchain index for your development case.

Tip

You can also specify the index URL using the wrench button when installing the toolchain.

nrf-connect.toolchainManager.installDirectory

This setting specifies alternative toolchain installation locations. Use this setting to manually set a custom toolchain install path when you Manage toolchains. This setting has no effect on macOS.

Tip

You can also specify the install path using the directory button when installing the toolchain.

nrf-connect.topdir

This setting points to the west workspace path. It is relevant only for building freestanding applications and is the final fallback to Zephyr's ZEPHYR_BASE environment variable.

The nrf-connect.topdir setting is automatically set to the ${nrf-connect.sdk:VER} variable when a released version of the nRF Connect SDK is installed and set to active in Manage SDKs, or through the nRF Connect: Select nRF Connect SDK command. The variable is not used when the unreleased, latest version of the nRF Connect SDK is selected (that is, when the main branch has the x.y.99 version).

The nrf-connect.topdir setting can be overridden if you have a workspace open. A notification in the Status Bar will appear in such cases.

nrf-connect.west.env

This configuration setting specifies in which environment west is executed. The setting contains an object that will replace the west environment variables in your system, with the special key $base for determining the initial environment.

{
  "$base": "terminal",
}

The following table lists possible values for $base.

Value for $base Description
"terminal" The default value. With this value set, the extension picks up the platform-specific terminal environment. On Windows, this is equivalent to "process", while on Linux and macOS, this is the output of the bash -c printenv command.
"process" With this value set, the extension picks the default Visual Studio Code environment, which corresponds to the operating system variables.
null With this value set, the extension starts a new environment from scratch.

Note

$base can also be used as a keyword inside variables. In such cases, it is replaced with the value of the variable at the base environment location.

You can add other fields into this object. These will be added as environment variables, overriding any corresponding variables in the base environment.

{
  "$base": "terminal",
  "CUSTOM_ENV_VAR": "custom value",
  "OTHER_ENV_VAR": "another value",
}

Useful nRF Connect commands

The following table lists a selection of useful nRF Connect commands, available from the Command Palette:

Command Description
nRF Connect: Check nRF Command Line Tools Update Checks for available updates of nRF Command Line Tools.
nRF Connect: Install Toolchain Lets you choose a specific version of the nRF Connect Toolchain from Command Palette and install it.
nRF Connect: Uninstall Toolchain Lets you uninstall a specific version of the nRF Connect Toolchain from Command Palette.
nRF Connect: West Init Initializes a west repository based on the provided paths to nrfconnect.topdir and to the folder where you want to initialize a west workspace.
nRF Connect: West Update Updates the west repository based on the revisions provided in the west manifest file for the currently selected west workspace.

To view all the nRF Connect extension's commands, open the Command Palette and type nRF Connect.

nRF DeviceTree settings and commands

The section provides more details about a selection of useful settings and commands for the nRF DeviceTree extension.

To view all of the nRF DeviceTree extension's commands, open the Command Palette and type nRF DeviceTree.

To view all of the nRF DeviceTree extension's settings, open the Settings editor and type nrf-devicetree.

devicetree.modules

This setting lists paths to board and binding files. The nRF DeviceTree extension checks these files and includes them in the binding indexing for the devicetree support.

nRF Terminal settings and commands

The section provides more details about a selection of useful settings and commands for the nRF Terminal extension.

The extension adds several nRF Terminal profile actions to the Visual Studio Code terminal. You can customize the operating mode and the connection values of these profiles.

nrf-terminal.terminalMode

To customize the operating mode for nRF Terminal profile actions, open the Settings editor and type nrf-terminal.terminalMode.

The nRF Terminal profiles can work in one of the following modes:

Mode Description
character (default) In this mode, every key-press is sent directly to the connected device. This is useful for interacting with device shells, such as the Zephyr Shell.
line In this mode, the terminal displays the characters typed and then submits them to the device as a single message when you click Enter. This is useful for AT sessions and other non-shell interactions.

nrf-terminal.startTerminal

The nrf-terminal.startTerminal command is invoked when connecting to a device.

Using a third-party extension, you can provide predefined arguments for the terminal connection command.

RTT arguments

The following table describes the available arguments for the RTT connection type.

Argument Description
connectionType Type of the connection you want to customize. For the RTT connection, use rtt.
serialNumber The serial number of the device to connect to. Can be used to obtain the value of device.
device The device version you want to connect to. This is the return value of the nrfjprog --snr <serialNumber> --deviceversion without the last _REV part.
memoryAddress The memory address to connect to. Use auto or "0x01234567" as direct address.

Serial port arguments

The following table describes the available arguments for the serial port connection type.

Argument Description
connectionType Type of the connection you want to customize. For the serial port connection, use serialport.
devicePath The serial port to connect to. Use the COM port on Windows.
baudRate Desired baud rate setting.
dataBits Desired data bits setting.
stopBits Desired stop bits setting.
parity Desired parity setting.
rtscts Desired RTS/CTS setting.

See the preset section below for the default preset values for some of these arguments.

Serial port preset configuration values

When connecting to a device using the serial port nRF Terminal profile action, you will be prompted from the Command Palette to either use a preset for the configuration values or to select the values individually. The current 115200 8n1 configuration has the following preset values:

Argument Value
baudRate 115200
dataBits 8
stopBits 1
parity none
rtscts false

nRF Terminal commands

The following table lists the nRF Terminal commands available from the Command Palette:

Command Description
nRF Terminal: Start terminal Starts the terminal, prompts for settings, and connects to the serial port.
nRF Terminal: Start Terminal With Previous Configuration Starts the terminal with the configuration of the last serial connection performed.
nRF Terminal: Stop terminal Stops the terminal and disconnects from the serial port.
nRF Terminal: Switch to line mode Switches the terminal to the line mode.
nRF Terminal: Switch to character mode Switches the terminal to the character mode.
nRF Terminal: Clear Clears the contents of the terminal.

Task binding parameters

When you are manually adding and customizing tasks, you can use several parameters in the tasks.json file you are editing. The following table lists parameters added by the extension for nrf-connect-build and nrf-connect-flash task types, in addition to the parameters provided by Visual Studio Code (see VS Code tasks documentation).

Parameter Task type Description
config nrf-connect-build and nrf-connect-flash Path of the configuration to build, or ${activeConfig}. Leave blank to select the configuration from a list.
clean nrf-connect-build A boolean that cleans the build artifacts (equivalent of west build --clean). Set to false by default.
runCmake nrf-connect-build A boolean that triggers CMake to run before building (equivalent of west build --pristine). Set to true by default.
erase nrf-connect-flash A boolean that triggers erasing of the entire flash before flashing. Set to true by default.
snr nrf-connect-flash If provided with a string number value, it selects the device with the provided serial number for flashing. In case more than one match the provided number, a list of matching devices will be displayed. Accepts * wildcards.
recover nrf-connect-flash A boolean that triggers using --recover when flashing, which erases user available non-volatile memory and disables the read back protection mechanism, if enabled. Set to false by default.
runner nrf-connect-flash If provided with a string word value, it overrides the runner used for flashing. Among the available Zephyr west runners, the recommended runners for Nordic Semiconductor devices are nrfjprog, jlink, or nrfutil.
softreset nrf-connect-flash A boolean that triggers using soft reset instead of the full reset when flashing, if available. Set to false by default.

Predefined extension variables

You can use several predefined variables in your configuration. The following tables list all available substitutions added by the extension for different scopes. For the list of the substitutions supported natively by Visual Studio Code, see Variable Reference in the Visual Studio Code documentation.

Configuration variables

The following table lists all available substitutions added by the extension for the configuration scope.

Variable Description
${nrf-connect.sdk:x.y.z} The path to the first nRF Connect SDK that can be identified by version x.y.z.
${nrf-connect.toolchain:x.y.z} The path to the first nRF Connect SDK Toolchain that can be identified by version x.y.z.
${nrf-connect.zephyrsdk:x.y.z} The path to the first Zephyr SDK toolchain that can be identified by version x.y.z.

CMake preset file variables

The following table lists all available substitutions added by the extension for the CMake preset file scope.

Variable Description
${sourceDir} The path to the application's source directory.
${sourceParentDir} The path to the parent directory of the application source.
${zephyrBase} Equivalent to ${env:ZEPHYR_BASE}.

Debug configuration variables

The following table lists all available substitutions added by the extension for the debug configurations for miDebuggerServerAddress and debugServerArgs.

Variable Description
${device} Substitutes the device type.
${port} Provides random available port.
${snr} Substitutes the serial number.
${rtosPlugin} The path to the Zephyr RTOS plugin.

Task definition variables

The following table lists all available substitutions added by the extension for nrf-connect-build and nrf-connect-flash task types.

Variable Description
${activeConfig} The path of the user's active build folder.

Telemetry

When you open the extension for the first time, you will be asked whether or not you give consent to provide telemetry data.

Accepting to send diagnostic data will provide Nordic Semiconductor with information about how the extension is used, how it is performing, and where improvements need to be made. You can check what type of data is sent and when it is sent by running the Visual Studio Code's --telemetry event flag.

After you accept or decline the telemetry request, the telemetry notification will not appear again. To change the telemetry settings, use the nRF Connect's nrf-connect.enableTelemetry setting.