VSCode Plugin Erase and Flash without erasing external flash. west flash --erase without erasing QSPI flash

Since a while back (github.com/.../999b6a14a4556f16d2f535207a84ceb2cca54f8a) the west flash command with --erase was changed so that --erase would also erase external flash. It adds options to override that also by adding new arguments --erase-mode and --ext-erase-mode

There are two issues.

1. (Bug) Combining those two only works on nRF54L15, which is a bug, as that should be allowed on other MCUs also, such as nRF5340 and others, just no one thought of this use case I think. 

west flash -d my_build_dir --erase-mode=all --ext-erase-mode=none

FATAL ERROR: Option --erase-mode can only be used with the nRF54L family.

2. (Feature request) There is no way in VSCode Plugin to in a generic way add this. (when above is fixed)

I want to use the vscode task type "nrf-connect-flash" as it automatically knows the active app, build dir. etc. So as far as I know there is not way to manually create shell command that calls west flash manually with those arguments that work for any application in the plugin.

This is what I want:

{
"type": "nrf-connect-flash",
"label": "Custom Flash with Erase",
"config": "${activeConfig}",
"erase": true,
"softreset": false,
"args": ["-erase-mode=all", "--ext-erase-mode=none"], //<- Appends extra args to west flash, not supported by plugin today
"problemMatcher": []
}

Alternatively adding the external flash config to the VSCode Plugin such as "erase" and "softreset" already are. Probably the better way.

The reason this is important i that for us is we want to flash with --erase as it's much faster as we use pretty much whole nRF5340 flash. Doing a sector erase is much slower ~30 seconds compare to chip erase ~few seconds only. So without --erase each flash during development adds like ~25 seconds. 

Now since the change (commit referenced earlier) --erase also wipes the full external flash, which takes 2 minutes for us and also all content is gone. We save resources on external flash that takes ~60 seconds to upload there. 

  • Fantastic :) Now just need to be able to feed those arguments from VSCode Plugin :)

  • Hi Jakob

    Just wanted to give you an updated on this. There is no immediate release coming to the VS Code plugin for this feature I'm afraid, so for now you will be restricted to using the command line west flash tool.

    Please contact the Nordic sales rep. of your region to get information on when it can be expected in the VS Code plugin.

    Best regards,

    Simon

  • Ok got it. Feel free to close the ticket. 

  • Not sure if useful to you, but due to the extreme flakiness of flashing and debugging in the nrf connect VS Code extension, I wrote a few lines to allow use of custom build & flash etc scripts:

    ...
    
    "nrf-connect.taskBindings": {
             "eraseAndFlash": [
                {
                   "taskName": "Monkey Script"
                }
             ]
          }
       },
       "tasks": {
          "version": "2.0.0",
          "tasks": [
             {
                "type": "nrf-connect-shell",
                "label": "Monkey Script",
                "command": "base=$(cygpath '${workspaceFolder}') && bash \"${base}/z-prod-utils/scripts/monkey_flash.bash\"",
                "cwd": "${activeConfig}",
                "problemMatcher": []
             }
          ]
       },

    and then in the script (just a bash script) - you can do whatever the hell you like. 

    ## Get 
    build_folder=$(dirname $(pwd))
    domain_name=$(basename $(pwd))
    build_folder_name=$(basename ${build_folder})
    
    
    echo "========================================="
    echo "Monkey Flash Script"
    echo "========================================="
    echo ""
    echo "App build Location  : $(pwd)"
    echo "App domain_name     : ${domain_name}"
    echo "build_folder        : ${build_folder_name}"
    echo ""
    
    
    echo "========================================="
    echo "Flashing to nRF9151DK"
    echo "========================================="
    echo "std command = west flash -d ${build_folder} --domain ${domain_name} --dev-id 1051278334"
    echo "========================================="
    echo ""
    echo "our command = west flash -d ${build_folder} --domain ${domain_name} --recover"
    echo "========================================="
    echo ""
    west flash -d ${build_folder} --domain ${domain_name} --recover
    echo ""

Related