This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Failure to eraseall via NVMC access from segger JLink

I am working on some production scripting and as I want this to be able to run under both windows and linux I have been trying to erase all the NRF52840 using NVMC accesses rather than nrfjprog;.

Till now I have always used nrfjprog to do this eraseall and it works fine.

I write the NVMC config with erase enable followed by erase to the eraseall register; but on reset of go the device just comes up like nothing has been erased.
What Am I doing wrong?

J-Link>halt
PC = 0003E5BE, CycleCnt = C91BFE9B
R0 = 00000000, R1 = 20002D88, R2 = 00000273, R3 = 00000000
R4 = 20001380, R5 = 00001000, R6 = 10001000, R7 = 000FE000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 20003A50
SP(R13)= 2003FE50, MSP= 2003FE50, PSP= 00000000, R14(LR) = 00027169
XPSR = 61000000: APSR = nZCvq, EPSR = 01000000, IPSR = E7805800000000 (d±Å)
CFBP = 04000000, CONTROL = 04, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00

FPS0 = 41C80000, FPS1 = 00000000, FPS2 = 00000000, FPS3 = 00000000
FPS4 = 00000000, FPS5 = 00000000, FPS6 = 00000000, FPS7 = 00000000
FPS8 = 00000000, FPS9 = 00000000, FPS10= 00000000, FPS11= 00000000
FPS12= 00000000, FPS13= 41C80000, FPS14= 00000000, FPS15= 00000000
FPS16= 00000000, FPS17= 00000000, FPS18= 00000000, FPS19= 00000000
FPS20= 00000000, FPS21= 00000000, FPS22= 00000000, FPS23= 00000000
FPS24= 00000000, FPS25= 00000000, FPS26= 00000000, FPS27= 00000000
FPS28= 00000000, FPS29= 00000000, FPS30= 00000000, FPS31= 00000000
FPSCR= 00000000
J-Link>w4 4001e504 2
Writing 00000002 -> 4001E504
J-Link>w4 4001e50c 1
Writing 00000001 -> 4001E50C
J-Link>go
J-Link>

Parents
  • Hi,

     

    This sequence should work:

    halt
    w4 4001e504 2
    w4 4001e50c 1
    r

    Here's my JLink Commander screenshot of the progress:

     

    An alternative is to run the "recover" mechanism, which is for nrf9160, posted here: https://devzone.nordicsemi.com/f/nordic-q-a/60813/nrf9160-ctrl-ap-access-using-j-link-commander-gdb

    This is the "ported" to nRF52 (Access port only changed) :

    SWDSelect   // Activate SWD
    SWDWriteDP 1 0x50000000  // Enable debug power
    SWDWriteDP 2 0x01000000  // Selects the 0x01XXXXXX Access Port and 0xXXXX00XX Register bank in the access port
    SWDWriteAP 1 0x00000001  // CTRL-AP Bank 0, register offset 1 (ERASEALL 0x004): Erase all command
    
    SWDReadAP 2 // CTRL-AP Bank 0, register offset 2 (ERASEALLSTATUS 0x008): Erase all command status
    SWDReadAP 2 // Must read twice to get the value.
    
    // Wait a good amount of time, so eraseall process is done.
    sleep 500
    
    // Perform a pin reset
    r0
    sleep 10
    r1
    sleep 10
    
    SWDSelect   // Activate SWD
    SWDWriteDP 1 0x50000000  // Enable debug power
    SWDWriteDP 2 0x01000000  // Selects the 0x01XXXXXX Access Port and 0xXXXX00XX Register bank in the access port
    
    SWDReadAP 3 // CTRL-AP Bank 0, register offset 3 (APPROTECTSTATUS 0x00C): Access port protection status
    SWDReadAP 3 // //Second read returns the value: 0: enabled 1: not enabled
    
    exit

     

    Here's a screenshot of the above recover script sequence (note: device is power cycled after nrfjprog --rbp is called):

     

    Kind regards,

    Håkon

  • Hi Hakon; I ran recovery script on a working unit; it erased fine. But that unit did not erase using the straight NVMC accesses.

    So it looks as if only the accesses to NVMC indirectly via SWD in your recovery script work.

    All effofts to erase via w4 command to NVMC didn't work either for my one unit playing up or for functional units.

  • Hi,

     

    This is very unusual. While I'm glad to hear that it worked using the recovery script, it is strange that writing to the NVMC directly didn't work.

    Have you tried this with different debuggers, and on different computers to see if the behavior is the same?

     

    Note: if you're running it as a script, try adding "sleep 100" before the reset cmd.

     

    Kind regards,

    Håkon

Reply Children
No Data
Related