nRF Connect for VSCode - How to make jlink the default runner for flashing a device

Hello,

I've been trying to bind a custom task to an action so that flashing a device defaults to using "jlink" runner whenever I flash from "Action > Flash" in nRF for VSCode.

I've followed the instructions at  https://nrfconnect.github.io/vscode-nrf-connect/guides/build_bind_tasks.html but without any success. 


Below is the nRF Connect Workspace Tasks file relevant to the action.

I've added a task "jlink flash" and made an entry in "nrf-connect.taskbindings" for it.

I have verified that the script  "${workspaceFolder}/jlink_flash.sh" executes correctly from a macOS Terminal window.

It appears that the taskName "jlink flash" is recognized but the flashing still uses "pyocd"

What am I doing incorrectly? Please review the changes in the Workspace ".  Thank you.

I understand that tasks/actions is a great feature but for ease of use and less confusion, it would be very useful to have an option in the nRF extension settings to select a flash "runner" type (e.g. pyocd, jlink).



Parents
  • Hi Ravi,

    I have asked internally regarding this and will get back to you with a response, soon.

    Best Regards,

    Priyanka

  • Hi Ravi,
    The "tasks" entry should be an array. Also there does not seem to be any proof that his script is actually called or what the content of that script is.


    Instead of calling a custom script in the task, it is simpler to call west flash, like:
    "command": "west", "args": ["flash", "--runner", ...] .


    In order to confirm that the task is called correctly. please share the output of the terminal window that executed the flash task.


    -Priyanka

  • Hi Priyanka,

    Thanks.
    I can now execute a shell command from a binded task. However, "west flash --runner jlink" doesn't flash the hex file for the current project, see error below.

    How can I resolve the issue so that "jlink flash" task uses the current project and Zephyr environment? 

    From within the VSCode terminal window for the current project, I can use "west flash --runner jlink" to flash device fine. 
    Executing task in folder nRF_Connect_Projects: west flash --runner jlink

    usage: west [-h] [-z ZEPHYR_BASE] [-v] [-V] <command> ...
    west: error: argument <command>: invalid choice: 'flash' (choose from 'init', 'update', 'list', 'manifest', 'diff', 'status', 'forall', 'help', 'config', 'topdir', 'selfupdate')

    * The terminal process "/usr/local/bin/bash '-c', 'west flash --runner jlink'" terminated with exit code: 2.
    * Terminal will be reused by tasks, press any key to close it.

  • Thanks for the update. I will get back to you soon.

    -Priyanka

  • This is an environment issue.
    You can set
    "options": {"env": {"ZEPHYR_BASE": "/path/to/zephyr"}} for the task, pointing to your own zephyr installation.
    Unfortunately, the ${nrf-connect.sdk} shorthand only works in the settings.
  • Hi Priyanka,

    With your suggestion above and assistance from  , I'm able to flash a device with jlink as the runner.

    Here's in full the task and binding sections.

    <project>.code-workspace file > "settings:" > ""nrf-connect.taskBindings:",  add


    	"flash": [
    	    { 	"taskName": "jlink flash" ,
    			"buildConfigs":[
    			"${workspaceFolder}/<YOUR-APP-FOLDER>/build"
    			]
    		}
    	]
    



    <project>.code-workspace file, add the following. I'm using NCS 2.3 as "/path/to/zephyr".

        "tasks": {
            "version": "2.0.0",
            "tasks": [
                {
                    "label": "jlink flash",
                    "options":{"env": {"ZEPHYR_BASE": "/opt/nordic/ncs/v2.3.0/zephyr"}},
                    "command": "west flash --runner=jlink --dev-id YOUR_DEVICE_ID -d ${workspaceFolder}/<YOUR-APP-FOLDER>/build",
                    "type": "shell",
                    "args": [],
                    "presentation": {
                        "clear": true,
                        "reveal": "always"
                    },
                    "group": "build"
                }
            ]
        },

    The above task and action works fine. However, as it stands, I would have to create a separate task/bind for each of my projects in the nRF Connect Workspace.

    It would be preferable to have the "Flash" action run the jlink as runner for all the projects in the nRF Connect Workspace and remove the need for  "<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 explicit task/bind actions for all my projects in the workspace. I would think nRF Connect would know the build path of the currently selected project.


    The best option would be an enhancement to  "nRF Connect for VSCode" extension, i.e. select a 
     "runner" of choice in the nRF Connect extension (pyocd, jlink).

    I'm quite surprised that such an option doesn't already exist. I'm sure quite a lot of nRF Connect developers utilize jlink.

    How can I submit an enhancement request for nRF Connect for VSCode? Or is this something that you can raise?

    Please consider the proposed enhancement request. Thank you. Your assistance is much appreciated. 



  • Hi,

    Glad to hear that you got it running. I will forward your concerns and suggestions to the internal team. Slight smile

    Have a nice weekend.

    -Priyanka

Reply Children
Related