nRF52 DK bricked after enabling code protection in firmware

This is a project using nRF52832.

On nRF connect SDK, we want to ensure that firmware does not get shipped without read-back protection enabled. During development I have CONFIG_NRF_APPROTECT_LOCK=n in prj.conf, as otherwise debugging isn't possible. This is a risk, as we have to ensure it's rebuilt with prj.conf changed. I added the following to my code which gets called if 

NRF_UICR->APPROTECT isn't 0xff:

 
    volatile uint32_t *reg;
    reg = &NRF_NVMC->CONFIG;
    *reg = 0x1;
    reg = &NRF_UICR->APPROTECT;
    *reg = 0xffffff00;
    reg = &NRF_NVMC->CONFIG;
    *reg = 0;
Originally I didn't write to NRF_NVMC->CONFIG, but then the write to NRF_UICR->APPROTECT had no effect.
Since doing this, it's not possible to unprotect the code, either using nrfjprog --recover in VSCode, or nRF Connect for desktop Erase all.
I'm using Windows 10 Pro version 22H2
The toolchain is v2.4.1
nRF connect desktop is v4.3.0
Parents Reply Children
No Data
Related