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

Unable to recover nrf52832 after writing into APPROTECT register

I am using nrf52832_xxaa with SDK v11.0.I tried writing into the APPROTECT register by using the code below

sd_softdevice_disable();

NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}

NRF_UICR->APPROTECT = 0xFFFFFF00;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}

NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}

sd_softdevice_enable(p_clock_lf_cfg, softdevice_assert_callback);

But when I tried to use the recover option I'm getting the following error

ERROR: Recover failed. Please make sure that the correct device family is given
ERROR: and try again.

and log

--------------------------------------------------------------------------------
nrfjprog -f nrf52 --recover --log
nrfjprog verion 9.7.1
--------------------------------------------------------------------------------
FUNCTION: open_dll.
FUNCTION: open_dll.
FUNCTION: enum_emu_snr.
FUNCTION: enum_emu_snr.
FUNCTION: enum_emu_snr.
FUNCTION: enum_emu_snr.
FUNCTION: connect_to_emu_with_snr.
FUNCTION: connect_to_emu_with_snr.
FUNCTION: connect_to_emu_without_snr.
FUNCTION: enum_emu_snr.
Device "NRF52832_XXAA" selected.
FUNCTION: recover.
FUNCTION: recover.
Not supported by current CPU + target interface combination.
JLinkARM.dll CORESIGHT_WriteAPDPReg returned error -2.
JLinkARM.dll CORESIGHT_WriteAPDPReg returned error -102.
FUNCTION: close_dll.
FUNCTION: close_dll.

How can I rectify this ? and recover the device?

Parents
  • First of all you shouldn't write into such register blindly in your code. It almost looks like at certain point you write into it on every occasion! It would be much better to just read the value first and write into it only if the value isn't the one you need.

    To the issue itself: what SEGGER J-Link probe do you use? Is it running the latest SEGGER J-Link firmware and the same for SEGGER J-Link SW pack on our PC? Could you try to recover the chip through nRFgo Studio instead of nrfjprog?

  • And one more btw.: it's kind of logical to enforce chip read-back protection at the start-up if it is not done through the external SWD programmer before even running the FW for the first time. However your code snippet suggests that you run some code including enabling BLE stack, then you disable it again because you want to write to UICR (it could be done through SD API as well - at least I believe so) and then you enable the stack again. Why so complicated????

Reply
  • And one more btw.: it's kind of logical to enforce chip read-back protection at the start-up if it is not done through the external SWD programmer before even running the FW for the first time. However your code snippet suggests that you run some code including enabling BLE stack, then you disable it again because you want to write to UICR (it could be done through SD API as well - at least I believe so) and then you enable the stack again. Why so complicated????

Children
No Data
Related