APProtect is being enabled after power cycle - nrf52840

We are using SDK 17.0.2, which does not support the rev 3 APProtect features.

We would like to update the SDK in the future, but are looking for a shorter-term solution now.

We'd like to maintain the behavior we had previously, which is as follows:

1) Upon assembly, the board is booted and firmware is flashed. It is expected that APProtect is disabled.

2) Upon end of manufacturing process, firmware enables APProtect.

I have read the latest product spec and seen the steps needed for this:
Step #1: after loading firmware, write UICR->APPROTECT to HwDisabled (5A). Then, upon each reset, firmware is to write APPROTECT.DISABLE to HwDisabled (5A).

Step #2: firmware should write ICR->APPROTECT to enabled and NRF_APPROTECT->FORCEPROTECT to APPROTECT_FORCE (00).

I looked through the latest SDK and saw that the main line I was to emulate was

NRF_APPROTECT->DISABLE = NRF_UICR->APPROTECT;

which makes sense if NRF_UICR->APPROTECT was set during the firmware load step.

The steps I did to complete this are:

Step #1:use nrfjprog.exe (and older version I think) as follows:

nrfjprog --recover
nrfjprog --memwr 0x10001208 --val 0x5A
nrfjprog --memwr 0x40000558 --val 0x5A

Then I use J-Flash Lite to program my FW image (NOT erasing the image beforehand, as nrfjprog --recover should have taken care of that).

The firmware is written to do the line "NRF_APPROTECT->DISABLE = NRF_UICR->APPROTECT;" every boot, and early-on: before the SoftDevice (7.2.0) is enabled.

This works across soft-resets (and maybe even quick power-cycles?), but doesn't work if I unplug power manually, then plug it back in.

If you have any debug tips, they'd be appreciated.

Thanks,

Kyle

  • Hi, 

    Check out this post on how to update the MDK with nRF5 SDK v17.0.2 for handling APPROTECT.

    Regards,
    Amanda H.

  • Thanks for the reference.

    I tried replacing my MDK as the post suggests, but was unable to make any progress.

    To be clear, I had updated my firmware to write the APProtect register (I defined it the same way the updated MDK did) on boot similar to how the updated MDK does it. It helped, i.e. the setting seemed to persist across processor resets, but it didn't persist across full power cycles. The behavior has not changed after updating the MDK.

    My larger question is: Is there any way to keep the SWD port protection disabled across full power loss? Is this the correct method to do it?

  • Hi again,
    Apologies, the issue is on my end.
    I am using the J-Flash Lite toolchain to flash the firmware image, and I am doing it in separate components (SoftDevice and the FW App). I believe it's issuing a reset between each component, which wipes the register before the FW App was able to load and propogate the UICR->APPROTECT value to APPROTECT.DISABLE.

    Moving to a batch file and programming a single FW image via nrfjprog fixed the issue.

    Thank you for your help!

Related