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

Parents
  • Where you able to solve wit the details provided in paul.landers reply?

  • No, actually from what i understood following its support case the situation is a bit different. It's not that i am not able to work, it's just that i have to write and erase everytime. If i don't erase, write failes and i get -nrfjprog error

  • So, in summary:

    1. If nrfjprog --program includes --sectorerase it may work if you time the operation to start after a reset just right. It seems like there could be something fixable in the nrfjprog DLL, or it might be in the underlying JLink software. The problem is reproducible with the JLink OB and JLink Base debuggers and on mac/PC and with NCS 1.7 thru 2.3.0.
    2. One could just always do a "flash then erase" operation, but this clears UICR.OTP, which we use for immutable device lifetime information that has to survive a firmware upgrade, so it's a nuisance to have to re-program that data with a user-flash-erase either in the Terminal, outside of VS Code, or binding a shell script to one of the two flash buttons.

    I think we''re experiencing the same problem. It may be related to how CTRL-AP is implemented in the nRF53 & nRF91 series. --sectorerase can usually be made to work after a reset and occasionally only after recycling power. JLink produces various errors and that's a clue that the cause of this longstanding issue may be at the intersection of secure flash protection / nrfjprog / JlinkExe.

    Jonathan, could the folks who did the nrfjprog DLL reproduce this problem?

  • Have asked the developers to have a look at this and will provide an update when ready.
    Regards,
    Jonathan

Reply Children
Related