How to work with boards and devices - nRF Connect for VS Code
Skip to content

How to work with boards and devices

The extension provides a variety of GUI options to interact with connected boards and devices. These options cover all required actions, from adding a new device, linking boards to a build configuration, to flashing.

How to choose a board

You set the board for your application when you create or edit a build configuration.

Board selection on the Add Build Configuration page

Boards can have different revisions, which can sometimes be found printed on the physical board.

The list of available boards is automatically populated by the extension.

How to add a new board

If you have a custom board, complete the following steps to add it to the list of the boards:

  1. Click Create a new board from the Welcome View.
    The Create New Board wizard opens.
  2. Enter a human-readable name for the board.
  3. Enter a machine-readable board ID that includes letters, numbers, -, or _.
  4. Set board root directory.
  5. Enter the name of the company that made the board.

The board files are added to the board root folder path you provided.

After the board is created, you can select it from the Add Build Configuration screen when you build an application.

The extension finds the new board entries using the nrf-connect.boardRoots configuration setting.

To link a connected board to a build configuration, click on the button next to your selected build configuration. Once the device is linked, the icon of the button changes to indicate the link.

Link device

Performing actions such as Flash on a build configuration with a linked device will always perform the action on that linked device.

How to connect to a device

The nRF Connect extension pack includes an integrated serial port and RTT terminal, which allows you to connect and flash a board using either method.

Tip

If you lose your serial connection, for example when your device loses power, it will be automatically restored when the cause of the interruption is solved, as long as you do not close the connection window. This functionality is not available for the RTT terminal, which has to be reconnected manually.

How to connect using serial port

To connect to a device using a serial connection:

  1. Plug the device into the same machine you are using to run the extension.
    The device appears as an entry in the Connected Device View.
  2. Expand the device entry.
  3. Click the Connect to Serial Port button to the right of the serial port entry to start a serial connection.

    Connect to Serial Port

    You will be prompted for configuration settings for the given connection type.

  4. Select one of the following options for the connection from the Command Palette:

    Note

    Only customize the connection values if you have changed the default UART driver settings, to make sure both sets of values are matching.

  5. Optionally, if you chose Other in the previous step, select the custom baud rate, data bits, and stop bits for the connection.

After the connection is established, a new terminal entry is added in the Panel View, with its name corresponding to the name of your device if you renamed the device.

Tip

The extension saves the serial port connection settings for future use. Next time you connect, you can select the previous connection settings from the quick pick menu or change them using the Change port settings button.

Change port settings

How to connect using RTT

Selecting this option frees a UART port that the serial port would use. However, you always need a SEGGER J-Link debugger connected for RTT to work.

To connect to a device using RTT:

  1. Plug the device into the same machine you are using to run the extension.
    The device appears as an entry in the Connected Device View.
  2. Expand the device entry.
  3. Click the Connect to RTT button to the right of the RTT entry to start an RTT connection.

    Connect to RTT

    You will be prompted for configuration settings for the given connection type.

  4. If you are using a multi-core device, select the core to connect to.

  5. Select the device to connect to.
  6. Select one of the following memory address strategies:

    • Search for RTT memory address automatically - This option scans the device memory for the control block.
    • Choose from predefined options - This option scans the build configuration for predefined memory address. (This option is not available when you connect using the nRF RTT Terminal launch profile.)
    • Specify RTT memory address - This option lets you type in the memory address.

After the connection is established, a new terminal entry is added in the Panel View, with its name corresponding to the name of your device if you renamed the device.

Tip

The extension saves the RTT connection settings for future use for each device. Next time you connect, you can select the previous connection settings from the quick pick menu or change them using the Change port settings button.

Change port settings

How to provide predefined arguments for connection command

You can predefine the arguments for the nrf-terminal.startTerminal command to save time and avoid providing these arguments every time. This sort of customization can be used with the serial port and the RTT connection actions and requires installing and using a third-party extension for Visual Studio Code, for example Commands.

To see the list of arguments for which you can provide values, see the [nrf-terminal.startTerminal] reference section. The steps to predefine these arguments depend on the extension you decide to use and are outside of the scope of this documentation.

How to flash boards

To flash a build configuration onto one device, complete the following steps:

  1. Make sure your board is connected to your machine.
  2. Click on the Flash option from the Actions View.

    Tip

    In some cases, for example when you want to erase UICR, you can use Erase and Flash to Board.

  3. If you have multiple boards connected, pick a device to flash when a prompt appears at the top of the screen.

Once the flashing starts, a small notification banner appears in the bottom right corner of VS Code to display the progress and confirm when the flashing is complete.

How to flash boards after changing an application

If you make any modification to your application, use one of the following options to flash your board:

  1. Depending on the type of changes:

    • If you only changed some code in your application, use Build from the Actions View.
    • If you have added or removed configuration files, use the Pristine Build option to the right of Build.

    Both these actions will rebuild the configuration.

  2. Click on Flash to flash to the board again.

How to flash multiple build configurations

To flash multiple build configurations in parallel, use one of the following methods:

  • Use the nRF Connect: Flash All Linked Devices command.
  • Click the icon located in the Applications View Actions.

This will flash all linked build configurations. This feature is not available if a board is linked to more than one build configuration.

Flash all build configurations

How to customize flashing actions

You can use the following customization options with the flashing action: