Disable APPROTECT for nRF5340

Hi,

Our team is trying to disable the Access Port Protection (APPROTECT) for the nRF5340. The main goal for this is to be able to start breakpoint debugging without needing to recover the MCU. The need to frequently recover the MCU has been slowing down our development. We are using the nRF Connect Extension inside VSCode.
I have read through the documentation to get familiar with this feature, but I seem to be misinterpreting the instructions. The relevant DevZone issues I have found provide incomplete solutions or simply refer me back to the documentation. It seems there are multiple items that need to be satisfied:
1. Disable APPROTECT in hardware (UICR)
2. Disable APPROTECT in firmware (CTRL-AP)
3. Ensure CTRL-AP.APPROTECT.DISABLE registers match for CPU and debugger
Is it possible for someone to provide a complete code example to explicitly show how to configure this?
Best regards,
Parker
Parents Reply Children
  • Hi Johnny,

    Thanks for your help. I cloned that repo and tested it out. The line for disabling the APPROTECT just prevents the rest of the code from running:

    NRF_CTRLAP_S->APPROTECT.DISABLE = 0x00000055; // our key
     
    If this line is included, breakpoint debugging fails to start from main and no logs are able to be printed. If I remove this line, debugging successfully starts from main and I can see logs.
    I am interested in what you said here:

    "Alternatively, you can for development keep APPROTECT disabled and ERASEPROTECT disabled to make things easier."

    I assume this will have the same effect we're hoping for. We simply want to disable all APPROTECT functionality for the time being to make development as easy as possible. Are there examples or guides that step through how to do this properly for the nRF5340? I notice many examples I found are for the nRF52 and I'm wondering if it's entirely accurate for the nRF53 - since I haven't had much luck.

    Parker

  • I should note that APPROTECT is enabled by default for our nRF5340 devkits. Is it not disabled by default.

  • Hello,

    I tested with the latest sdk and it unlocks the debugger when the key is provided.

    Regardless, for debugging, here is a branch that just disables it: droidecahedron/nrf_ctrl-ap_approtect at disable

    after flashing, I was able to debug and get output without recovering. (You can choose the "debug without flashing" option if you use the GUI)

  • Thanks so much Johnny. I totally forgot I could disable debug flashing in the launch.json.