nrfutil flash with full erase breaks flashing

When we were using nrfjprog to flash, we used "west flash --erase" because it was quicker to erase entire flash then sector by sector. However, when we upgraded to SDK 3.0.0 and switched to nrfutil, we can only use "west flash --erase" once, and it works but then the subsequent commands fail. See log below:

> west flash --erase
-- west flash: rebuilding
[0/10] Performing build step for 'agmuster'
[0/14] Performing build step for 'tfm'
ninja: no work to do.
[2/3] Performing install step for 'tfm'
-- Install configuration: "MinSizeRel"
----- Installing platform NS -----
[3/3] Completed 'tfm'
[1/10] Performing build step for 'mcuboot'
ninja: no work to do.
[8/9] cd /workspace/build/_sysbuild && /opt/homebrew/bin/cmake -E true
-- west flash: using runner nrfutil
-- runners.nrfutil: mass erase requested
-- runners.nrfutil: reset after flashing requested
Using board 001051272415
-- runners.nrfutil: Flashing file: /workspace/build/merged.hex
-- runners.nrfutil: Erasing non-volatile memory (ERASEALL)
-- runners.nrfutil: Programming image
-- runners.nrfutil: Verifying image
-- runners.nrfutil: Reset
-- runners.nrfutil: Board with serial number 1051272415 flashed successfully.
> west flash
-- west flash: rebuilding
[0/10] Performing build step for 'agmuster'
[0/14] Performing build step for 'tfm'
ninja: no work to do.
[2/3] Performing install step for 'tfm'
-- Install configuration: "MinSizeRel"
----- Installing platform NS -----
[3/3] Completed 'tfm'
[1/10] Performing build step for 'mcuboot'
ninja: no work to do.
[8/9] cd /workspace/build/_sysbuild && /opt/homebrew/bin/cmake -E true
-- west flash: using runner nrfutil
-- runners.nrfutil: mass erase requested
-- runners.nrfutil: reset after flashing requested
Using board 001051272415
-- runners.nrfutil: Flashing file: /workspace/build/merged.hex
-- runners.nrfutil: Erasing non-volatile memory (ERASEALL)
Error: One or more batch tasks failed:
* 1051272415: Device error: NVMC wait for ready failed: Failed to read from memory address 0x50003100: Failed to write DebugPort register 0x08: Unknown Error in J-Link DLL (error code =-1) (Generic)

FATAL ERROR: command exited with status 1: nrfutil --json device x-execute-batch --batch-path /workspace/build/generated_nrfutil_batch.json --serial-number 1051272415

// subsequent runs result in

-- runners.nrfutil: Flashing file: /Users/kon/Workshop/GitHub/AgX/agmuster-workspace/agmuster/build/merged.hex
Error: One or more batch tasks failed:
* 1051272415: Failed to attach to target: The Application core access port is protected (All) (NotAvailableBecauseProtection)


The operation was unavailable for some of the devices because they had readback protection enabled. These devices might be possible to unlock using the `recover` subcommand. See `nrfutil device recover --help` for more information.

To get out of this state, we need to do a power reset and then "west flash --recover".  We're seeing similar issue with "west flash" if running multiple times in a row. 

If we recover the device, and then switch to "nrjprog" runner, these we can use "west flash --erase" consecutively with no issues. Something about nrfutil is not playing nice with JLink.

We're using JLink v8.30. Device: nRF9151_xxCA.

Parents Reply Children
No Data
Related