Nrfjprog error

Hello,

i'm developing a firmware for nrf5340dk from 4-5 months using VS Code and Nrf Connect SDK v.2.3.0. Everything went smoothly until now but about a week ago i started to have an annoying nrfjprog error. More in details this is what happens:

1) Connect nrf5340dk to the PC and start VS Code;

2) Run the first "Flash" of the session and everything goes fine;

3) From the second "Flash" of the session nrfjprog start to fail over and over.

I noticed the following things:

a) The issue is related to the code. If i apply the same sequence using the "Hello_world" sample everything goes fine

b) As a workaround, if i run "Erase and Flash" and not just "Flash", everything goes fine

c) If i unplug the USB cable, re-plug and "Flash" everything goes fine (only for the first Flash);

Finally, this is the output of the process:

-- west flash: using runner nrfjprog
-- runners.nrfjprog: Flashing file: C:\nrf5340dk_projects\test_vsCode\hello_world\build\zephyr\merged.hex
[ #################### ]   1.816s | Erase file - Done erasing                                                          
[error] [SeggerBackend] - JLinkARM.dll reported "-1", "An unknown error.".                                             
[error] [SeggerBackend] - JLinkARM.dll reported "-1", "An unknown error.".
[error] [SeggerBackend] - JLinkARM.dll reported "-1", "An unknown error.".
[error] [SeggerBackend] - JLinkARM.dll reported "-1", "An unknown error.".
[error] [SeggerBackend] - JLinkARM.dll reported "-1", "An unknown error.".
[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 writing to code!
[error] [  nRF53] - Failed to program flash
[error] [  nRF53] - Failed while programming file C:\nrf5340dk_projects\test_vsCode\hello_world\build\zephyr\merged.hex.
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.
FATAL ERROR: command exited with status 33: nrfjprog --program 'C:\nrf5340dk_projects\test_vsCode\hello_world\build\zephyr\merged.hex' --sectorerase --verify -f NRF53 --snr 1050023124 --coprocessor CP_APPLICATION

 *  The terminal process terminated with exit code: 33. 
 *  Terminal will be reused by tasks, press any key to close it.

Providing you my code is not practical because is a state machine with tens of source files and libraries, but, considering the lists above, i'm thinking that the issue could be related to the use of NVS. In fact, when i flash my code, i'm writing some struct in the NVS (sensor calibration parameters). Moreover, the error log states that the error could be due to an "unaligned access", providing another hint to a memory issue.

I'm attaching here the file log.log obtained running nrfjprog command with "--log" option enabled.

0624.log.log

Related