Skip to content

Commit 4cc690e

Browse files
SebastianBoerlubos
authored andcommitted
[nrf fromtree] 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. Signed-off-by: Sebastian Bøe <[email protected]> (cherry picked from commit 1438f8a)
1 parent f85acf7 commit 4cc690e

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

scripts/ci/check_compliance.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,9 @@ def check_no_undef_outside_kconfig(self, kconf):
13501350
"FOO_LOG_LEVEL",
13511351
"FOO_SETTING_1",
13521352
"FOO_SETTING_2",
1353+
"GEN_UICR_APPROTECT_APPLICATION_PROTECTED",
1354+
"GEN_UICR_APPROTECT_CORESIGHT_PROTECTED",
1355+
"GEN_UICR_APPROTECT_RADIOCORE_PROTECTED",
13531356
"GEN_UICR_ERASEPROTECT",
13541357
"GEN_UICR_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
13551358
"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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ config GEN_UICR_ERASEPROTECT
5555
Note that gen_uicr.py can be used directly to create a configuration
5656
with both enabled if needed.
5757

58+
menu "UICR.APPROTECT - Access Port Protection"
59+
60+
config GEN_UICR_APPROTECT_APPLICATION_PROTECTED
61+
bool "Protect application domain access port"
62+
help
63+
When enabled, disables debug access to the application domain processor,
64+
preventing debugger connection to application memory, registers, and debug
65+
features. When disabled, full debug access is enabled.
66+
67+
config GEN_UICR_APPROTECT_RADIOCORE_PROTECTED
68+
bool "Protect radio core access port"
69+
help
70+
When enabled, disables debug access to the radio core processor,
71+
preventing debugger connection to radio core memory, registers, and debug
72+
features. When disabled, full debug access is enabled.
73+
74+
config GEN_UICR_APPROTECT_CORESIGHT_PROTECTED
75+
bool "Disable CoreSight subsystem"
76+
help
77+
When enabled will disable the coresight subsystem, preventing
78+
system level trace features.
79+
80+
endmenu
81+
5882
config GEN_UICR_PROTECTEDMEM
5983
bool "Enable UICR.PROTECTEDMEM"
6084
help

0 commit comments

Comments
 (0)