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
  • Hello Parker,

    I haven't tested this unofficial sample post sysbuild, but if the key in the application and the key in the script match, you should be able to attach debugger without triggering a full erase for the app core. 

    droidecahedron/nrf_ctrl-ap_approtect: Modified from https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/ctrl-ap/eraseprotect to only modify approtect

    There are also instructions for using jlink.exe directly to write to the relevant DAP registers.

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

    Best regards,

  • 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

Reply
  • 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

Children
Related