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.