nRF5340 devices have access port protection enabled by default, but they can also have secure access port protection and erase protection.
For more information on access port protection, see Enabling device protection.
To check if your device is protected, read the following registers in the AHB-AP:
- AHP-AP Control/Status Word (CSW) register – use this register to read the Access Port Protection (APPROTECT) status. This register is defined in the Arm® CoreSight SoC-400 Technical Reference Manual. Use the following fields to check the access port protection status:
- DgbStatus field (bit 6 in AHB-AP.CSW) – indicates if AHB transfers are permitted. If the
value of AHB-AP.CSW->DbgStatus is 1, then AHB transfers are allowed and
the device does not have APPROTECT.
- SPIStatus field (bit 23 in AHB-AP.CSW) - indicates if secure protection is enabled. If the value of AHB-AP.CSW->SPIStatus is 1, Secure Access Port Protection (SECUREAPPROTECT) is not set and both secure and non-secure transfers are allowed.
- CTRL-AP.ERASEPROTECT.STATUS – If access port protection is not enabled, use this register to
check if Erase Protection (ERASEPROTECT) is set. If both APPROTECT and
ERASEPROTECT are set, the device cannot be unlocked unless programmed software changes the
settings.