Select runner for Flash Command in nRF Connect

Hi!

In nRF Connect Extension for VSCode, how can I set a (non-default) runner for the Flash Action in the Actions View?

Specifically, I've got my Adafruit Feather nrf52840 connected via USB and SEGGER JLink and would like to use jlink as a flasher. Clicking on "Flash" in the Action View will however hard code "nrfprog" as flasher to the command line (althout I configured the correct flasher via CMakeLists.txt, i.e. "board_set_flasher(jlink)".

Parents Reply
  • Hi zpm1066,

    AFAICS there is no way to make jlink the default runner of the nRF Connect extension, which only seems to co-operate with the Nordic tools ootb. There is however a recommended workaround which is what I'm pointing to in my previous post.

    Before you can link a task you have to create one in the tasks section of your app.workspace file (or alternatively in the tasks.json file - depending on how you set up your workspace):

      "tasks": {
        "version": "2.0.0",
        "tasks": [
          {
            "label": "JLink Flash",
            "type": "shell",
            "command": "west flash --runner=jlink --dev-id YOUR-DEVICE-ID -d ${workspaceFolder:YOUR-APP-FOLDER}/build",
            "presentation": {
              "clear": true,
              "reveal": "always"
            }
          }
        ]
      },
    

    VSCode has some kind of wizard to add tasks if you don't want to add them manually. You may want to test the west command first. And you have to ensure that VSCode sees the west command in its environment.

    if you then follow the documentation linked in my previous post you should end up with something like the following entry in your VSCode workspace settings file:

        "nrf-connect.taskBindings": {
          "flash": [
            {
              "taskName": "JLink Flash",
              "buildConfigs": [
                "${workspaceFolder:YOUR-APP-FOLDER-HERE}/build"
              ]
            }
          ]
        },

    These two entries combined should link your "Flash" Action to the given west command which is then used in lieu of the native action.

Children
  •   
    Hello Florian,

    Thank you!. It's much appreciated!

    The two items I was missing were

    1. "options" key to set ZEPHYR_BASE so that VSCode sees the west command in its environment. I was expecting this to be handled automatically as the action is from within VSCode.

    2. Build directory as part of the "command" in "tasks". Also, specify the Segger Edu Mini device-id.

    The action execution is a bit slow but at least it works now.

    What I really would like is to have the "Flash" action run the jlink as runner for all the projects in my workspace, so that I don't have to specify  "<YOUR-APP-FOLDER>"  in the path "${workspaceFolder}/<YOUR-APP-FOLDER>/build".

    Is there a way to use the currently selected build path to avoid specifying "<YOUR-APP-FOLDER>" explicitly? I don't want to have separate flash actions for all my projects in the workspace.

    Of course, a "nRF Connect for VSCode" enhancement to add an option to select a "runner" of choice in the nRF Connect extension would be the easiest and best option. 

    Once again, Thank you for the very quick response.

  • You're welcome. Unfortunately, I don't have an answer to your last question, although I'd be interested myself. That's probably something one of the Nordic engineers present on the network could/should answer.

Related