Skip to content

Commit 1a7614d

Browse files
committed
[nrf fromlist] soc: nordic: uicr: Add support for UICR.APPROTECT
Add support for UICR.APPROTECT configuration, which controls debugger and access-port permissions through the TAMPC peripheral. This introduces three Kconfig options that allow independent control over access port protection for different processor domains: - GEN_UICR_APPROTECT_APPLICATION_PROTECTED: Controls debug access to the application domain processor - GEN_UICR_APPROTECT_RADIOCORE_PROTECTED: Controls debug access to the radio core processor - GEN_UICR_APPROTECT_CORESIGHT_PROTECTED: Controls access to the CoreSight debug infrastructure When enabled, each option sets the corresponding UICR.APPROTECT register to PROTECTED (0xFFFFFFFF), which disables debug access for that domain. When disabled, the registers remain at their erased value (UNPROTECTED), allowing full debug access. This feature is critical for production devices where debug access must be restricted to prevent unauthorized access to sensitive code and data. Upstream PR #: 97337 Signed-off-by: Sebastian Bøe <[email protected]>
1 parent b22345c commit 1a7614d

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

scripts/ci/check_compliance.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,9 @@ def check_no_undef_outside_kconfig(self, kconf):
13001300
"FOO_LOG_LEVEL",
13011301
"FOO_SETTING_1",
13021302
"FOO_SETTING_2",
1303+
"GEN_UICR_APPROTECT_APPLICATION_PROTECTED",
1304+
"GEN_UICR_APPROTECT_CORESIGHT_PROTECTED",
1305+
"GEN_UICR_APPROTECT_RADIOCORE_PROTECTED",
13031306
"GEN_UICR_ERASEPROTECT",
13041307
"GEN_UICR_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
13051308
"GEN_UICR_LOCK",

soc/nordic/common/uicr/gen_uicr.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
# Common values for representing enabled/disabled in the UICR format.
2626
ENABLED_VALUE = 0xFFFF_FFFF
2727
DISABLED_VALUE = 0xBD23_28A8
28+
PROTECTED_VALUE = ENABLED_VALUE # UICR_PROTECTED = UICR_ENABLED per uicr_defs.h
29+
UNPROTECTED_VALUE = DISABLED_VALUE # Unprotected uses the default erased value
2830

2931
KB_4 = 4096
3032

@@ -440,6 +442,21 @@ def main() -> None:
440442
action="store_true",
441443
help="Enable UICR.ERASEPROTECT to block ERASEALL operations",
442444
)
445+
parser.add_argument(
446+
"--approtect-application-protected",
447+
action="store_true",
448+
help="Protect application domain access port (disable debug access)",
449+
)
450+
parser.add_argument(
451+
"--approtect-radiocore-protected",
452+
action="store_true",
453+
help="Protect radio core access port (disable debug access)",
454+
)
455+
parser.add_argument(
456+
"--approtect-coresight-protected",
457+
action="store_true",
458+
help="Protect CoreSight access port (disable debug access)",
459+
)
443460
parser.add_argument(
444461
"--protectedmem",
445462
action="store_true",
@@ -613,6 +630,15 @@ def main() -> None:
613630
# Handle ERASEPROTECT configuration
614631
if args.eraseprotect:
615632
uicr.ERASEPROTECT = ENABLED_VALUE
633+
# Handle APPROTECT configuration
634+
if args.approtect_application_protected:
635+
uicr.APPROTECT.APPLICATION = PROTECTED_VALUE
636+
637+
if args.approtect_radiocore_protected:
638+
uicr.APPROTECT.RADIOCORE = PROTECTED_VALUE
639+
640+
if args.approtect_coresight_protected:
641+
uicr.APPROTECT.CORESIGHT = PROTECTED_VALUE
616642
# Handle protected memory configuration
617643
if args.protectedmem:
618644
if args.protectedmem_size_bytes % KB_4 != 0:

soc/nordic/common/uicr/gen_uicr/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ endif()
7777

7878
set(lock_args)
7979
set(eraseprotect_args)
80+
set(approtect_args)
8081
set(protectedmem_args)
8182
set(periphconf_args)
8283
set(wdtstart_args)
@@ -127,6 +128,19 @@ if(CONFIG_GEN_UICR_ERASEPROTECT)
127128
list(APPEND eraseprotect_args --eraseprotect)
128129
endif()
129130

131+
# Handle APPROTECT configuration
132+
if(CONFIG_GEN_UICR_APPROTECT_APPLICATION_PROTECTED)
133+
list(APPEND approtect_args --approtect-application-protected)
134+
endif()
135+
136+
if(CONFIG_GEN_UICR_APPROTECT_RADIOCORE_PROTECTED)
137+
list(APPEND approtect_args --approtect-radiocore-protected)
138+
endif()
139+
140+
if(CONFIG_GEN_UICR_APPROTECT_CORESIGHT_PROTECTED)
141+
list(APPEND approtect_args --approtect-coresight-protected)
142+
endif()
143+
130144
# Handle protected memory configuration
131145
if(CONFIG_GEN_UICR_PROTECTEDMEM)
132146
list(APPEND protectedmem_args --protectedmem)
@@ -257,6 +271,7 @@ add_custom_command(
257271
--out-uicr-hex ${uicr_hex_file}
258272
${lock_args}
259273
${eraseprotect_args}
274+
${approtect_args}
260275
${wdtstart_args}
261276
${periphconf_args}
262277
${securestorage_args}

soc/nordic/common/uicr/gen_uicr/Kconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,31 @@ config GEN_UICR_ERASEPROTECT
4949
with UICR.LOCK, it becomes impossible to modify the UICR in any way.
5050
This should only be enabled during final stages of production.
5151

52+
menu "UICR.APPROTECT - Access Port Protection"
53+
54+
config GEN_UICR_APPROTECT_APPLICATION_PROTECTED
55+
bool "Protect application domain access port"
56+
help
57+
When enabled, disables debug access to the application domain processor,
58+
preventing debugger connection to application memory, registers, and debug
59+
features. When disabled, full debug access is enabled.
60+
61+
config GEN_UICR_APPROTECT_RADIOCORE_PROTECTED
62+
bool "Protect radio core access port"
63+
help
64+
When enabled, disables debug access to the radio core processor,
65+
preventing debugger connection to radio core memory, registers, and debug
66+
features. When disabled, full debug access is enabled.
67+
68+
config GEN_UICR_APPROTECT_CORESIGHT_PROTECTED
69+
bool "Protect CoreSight access port"
70+
help
71+
When enabled, disables access to the CoreSight debug infrastructure,
72+
blocking system-level debug features. When disabled, full debug access
73+
is enabled.
74+
75+
endmenu
76+
5277
config GEN_UICR_PROTECTEDMEM
5378
bool "Enable UICR.PROTECTEDMEM"
5479
help

0 commit comments

Comments
 (0)