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. 

  • Hello,

    Sorry for the delay in responding to this issue. I wanted to check internally before getting back to you.

    (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. 

    We are already working on this, and you can expect the feature in an upcoming release, although I don’t have a clear timeline to share at the moment.

    I will also get back to you regarding the other question you asked.

    Kind Regards,

    Abhijith

  • Hello,

    Until the upcoming release, a possible workaround is to create a task of type nrf-connect-shell instead of nrf-connect-flash, specify the full west flash command with the required arguments, and then bind that task to the build configuration.

    {
       "label": "My Custom Flash Task",
       "command": "west flash --erase-mode=all --ext-erase-mode=none",
       "type": "nrf-connect-shell"
    }

    "nrf-connect.taskBindings": {
          "flash": [
            {
              "taskName": "My Custom Flash Task",
              "buildConfigs": ["${workspaceFolder}/build"]
            }
          ]
        }

    Kind Regards,

    Abhijith

  • Hi, yes this I tried before, but AFAIK I can't get the actual selected build folder there hence not a good solution.
    I need to dynamically the folder and device id like this, I do not want to hard code it.
    west flash -d build_folder --dev-id dev_id_corresponding_to_this_build_folder

    Anyway I patched Zephyr to not do erase of external flash for now so we are good until both VSCode (1. (Bug)) and west flash (2. (Feature request)) are fixed.

  • Hello,

    We are working on this and I have created an internal ticket to track the bug you reported. I will keep you updated here. Apologies for any inconvenience this may have caused.

    Kind regards,
    Abhijith

  • Hello,

    See this commit for the issue you have reported.

    Kind Regards,

    Abhijith

Related