nrf5340 memory gets erased after readback in J-Flash

Target: nrf5340

debugger j-link base (or ultra+, same result)

SW: J-Flash, J-Flash Lite, versions tested v7.80, v7.86, .7.88 - same result

Hi,

I am having trouble with programming nrf5340. 

1. Manual programming with J-Flash Lite:

I flash the net core, then the app core. If I want to read out the data in the J-Flash I get the following message in log:

Any ideas why is this happening? I need to debug this first, because then I want to create the python script to automate the flashing. Thank you!

  • Thank you for reply.

    Is this special hexfile available? What I tried after flash FW:
    - write 0x50fa50fa to the 0xff8000 for the app core

    - write 0x50fa50fa to the 0x1ff8000 for the net core

    - power on reset

    then if I connect to the device it is protected. Is something what I am missing? Thanks!

  • Hi,

    vojtech265 said:
    Is this special hexfile available?

    No, it is part of the nrfjprog binary. But you can build a nRF Connect SDK project yourself and flash it and it would do the same by default, which is to enable debugger access.

    vojtech265 said:
    then if I connect to the device it is protected. Is something what I am missing?

    Yes, that is expected. In order to access the debugger interface either an erase all operation has to be performed in that debug session (which is how you can recover a device and program and empty device), or what is relevant in this case: Both have the magic word in APPROTECT register in UICR and the running firmware must write to APPROTECT.DISABLE. If you have not flashed any firmware, that does not happen, and therefor debugger access is blocked.

    Summing up: To unlock the debug port, you you must both have the magic word in UICR.APPROTECT and firmware must write the magic word to APPROTECT.DISABLE on every boot. Both this happens automatically with nrfjprog --recover from the command line. If you use other tools, you need to handle it yourself, which means writing to UICR and programming your firmware).

    PS: To build a firmware that does not open the debugger, you need to enable  NRF_APPROTECT_LOCK and CONFIG_NRF_SECURE_APPROTECT_LOCK if you want that at a later stage.

Related