nrfjprog nrf5340 programming error when rbp enabled

I am trying to program nrf5340 using this command: nrfjprog -f NRF53 --program merged_domains.hex --verify --recover -r

It works fine if readback protection is not enabled, but when readback protection is enabled, it gives this error:
[error] [ Client] - Encountered error -90: Command read_memory_descriptors executed for 15 milliseconds with result -90
[error] [ Worker] - Can't read memory descriptors, ap-protection is enabled.
[ ####################] 2.334s | Erase file - Done erasing
[ ####################] 6.855s | Program file - Done programming
[ ####################] 6.998s | Verify file - Done verifying
Applying system reset.
Run.

Then I tried each of the following before running the above command:
1. nrfjprog --recover --coprocessor CP_APPLICATION
    nrfjprog --recover --coprocessor CP_NETWORK

2. nrfjprog --recover
    nrfjprog --recover --coprocessor CP_APPLICATION

3. nrfjprog --recover

For all these cases, when I first try to run the programming command it gives an error

[ ####################] 2.371s | Erase file - Done erasing
[error] [ Client] - Encountered error -102: Command program_file executed for 5113 milliseconds with result -102
[error] [ nRF53] - The write access failed, but no cause could be determined.
[error] [ nRF53] - It may be due to an unaligned access, accessing a nonexistent memory, or a communication issue.
[error] [ nRF53] - Failed while performing 'Write' operation on target address 0x00014000.
-102: An unknown error.
[error] [ nRF53] - Failed while reading device information.
[error] [ Worker] - An unknown error.
ERROR: JLinkARM DLL reported an error. Try again. If error condition
ERROR: persists, run the same command again with argument --log, contact Nordic
ERROR: Semiconductor and provide the generated log.log file to them.
NOTE: For additional output, try running again with logging enabled (--log).
NOTE: Any generated log error messages will be displayed.

Afterwards when I run the command again, it works properly as expected 

So, for every alternate programming command I get that error, is there anything else that I need to do so the programming command works every time?

These are the versions that I'm using:
nrfjprog version: 10.24.0 external
JLinkARM.dll version: 7.94l

Related