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 Reply Children
  • 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,

    Yes, I can call "west flash" from a command line or use "-DBOARD_FLASH_RUNNER" compile flag to get the runner to be jlink. What I'm looking for is a less cumbersome option.

    It would be much easier, if the nRF extension had a setting to select the a "runner" of choice. It's something that Nordic should consider. 

    It looks like that binding a task to the "Flash" action is the next best option and offers high customization.

    I've reviewed https://nrfconnect.github.io/vscode-nrf-connect/guides/build_bind_tasks.html, where you have an example of how to bind a task to an action.

    Here's what I tried. However, when I click "Flash", the default runner "pyocd" gets invoked.

    		"nrf-connect.taskBindings": {
    			"pristineBuild": [
    				{
    					"taskName": "Build [pristine]: ble/build",
    					"buildConfigs": [
    						"${workspaceFolder}/ble/build",
    						"${workspaceFolder}/ethernet_hub_ble/build"
    					]
    				}
    			],
    			"flash": [{ "taskName": "jlink flash" }]
    		}
    	},
    
    ...
    ...
    ...
    
     {
        "tasks": [``
        {
    		"version": "2.0.0",
    		"label": "jlink flash",
    		"command": "${workspaceFolder}/jlink_flash.sh",
    		"args": ["--build", "--erase", "--nrf52"],
    		"presentation": {
    			"echo": true,
    			"reveal": "never",
    			"clear": true,
            }
        }
    		]
     },


     The "${workspaceFolder}/jlink_flash.sh" script below simply runs the jlink runner and works fine from a command line.


    west flash --runner jlink


    I'm trying to bind a task to "Flash" action but it's not working. Obviously, I'm doing something incorrect and the fix is mostly likely quite simple.


    Please review and let me know what I'm doing wrong. Thank you.

  • Thank you for sharing the snippet. I will discuss this with experts and get back to you soon.

    -Priyanka

  • Hi Ravi,

    Apologies for the delay as it was the weekend, but I am yet to hear back from the team. I will let you know as soon as I get a response.

Related