Skip to content

Commit 9573717

Browse files
committed
[nrf fromtree] platform: nordic_nrf: APPROTECT to lock debugging
NRF_APPROTECT and NRF_SECURE_APPROTECT to take precedence over other mechanisms when configuring debugging for TF-M. For nRF53 and nRF91x1 the actual locking of firmware is done elsewhere. This further locks the UICR. nRF9160 supports only hardware APPROTECT. This will lock the APPROTECT / SECUREAPPROTECT in the next boot, when the above settings are configured. Change-Id: I5e304be0f8a34c0016488d9ec09929bbcb38481f Signed-off-by: Markus Lassila <[email protected]> Signed-off-by: Frank Audun Kvamtrø <[email protected]>
1 parent a2fe2e6 commit 9573717

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

platform/ext/target/nordic_nrf/common/core/target_cfg.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,33 @@ enum tfm_plat_err_t system_reset_cfg(void)
807807

808808
enum tfm_plat_err_t init_debug(void)
809809
{
810-
#if defined(NRF91_SERIES) || defined(NRF54L15_ENGA_XXAA)
810+
#if defined(NRF_APPROTECT) || defined(NRF_SECURE_APPROTECT)
811+
812+
#if !defined(DAUTH_CHIP_DEFAULT)
813+
#error "Debug access controlled by NRF_APPROTECT and NRF_SECURE_APPROTECT."
814+
#endif
815+
816+
#if defined(NRF_APPROTECT)
817+
/* For nRF53 and nRF91x1 already active. For nRF9160, active in the next boot.*/
818+
if (nrfx_nvmc_word_writable_check((uint32_t)&NRF_UICR_S->APPROTECT,
819+
UICR_APPROTECT_PALL_Protected)) {
820+
nrfx_nvmc_word_write((uint32_t)&NRF_UICR_S->APPROTECT, UICR_APPROTECT_PALL_Protected);
821+
} else {
822+
return TFM_PLAT_ERR_SYSTEM_ERR;
823+
}
824+
#endif
825+
#if defined(NRF_SECURE_APPROTECT)
826+
/* For nRF53 and nRF91x1 already active. For nRF9160, active in the next boot. */
827+
if (nrfx_nvmc_word_writable_check((uint32_t)&NRF_UICR_S->SECUREAPPROTECT,
828+
UICR_SECUREAPPROTECT_PALL_Protected)) {
829+
nrfx_nvmc_word_write((uint32_t)&NRF_UICR_S->SECUREAPPROTECT,
830+
UICR_SECUREAPPROTECT_PALL_Protected);
831+
} else {
832+
return TFM_PLAT_ERR_SYSTEM_ERR;
833+
}
834+
#endif
835+
836+
#elif defined(NRF91_SERIES) || defined(NRF54L15_ENGA_XXAA)
811837

812838
#if !defined(DAUTH_CHIP_DEFAULT)
813839
#error "Debug access on this platform can only be configured by programming the corresponding registers in UICR."

0 commit comments

Comments
 (0)