Skip to content

Commit b22345c

Browse files
committed
[nrf fromlist] soc: nordic: uicr: Add support for UICR.ERASEPROTECT
Add support for UICR.ERASEPROTECT configuration, which blocks ERASEALL operations to prevent bulk erasure of protected memory. This introduces a Kconfig option GEN_UICR_ERASEPROTECT that enables blocking of ERASEALL operations on NVR0, preserving UICR settings even if an attacker attempts a full-chip erase. This is a critical security feature for production devices. When enabled together with UICR.LOCK, it becomes impossible to modify the UICR in any way, establishing a permanent device protection scheme. Due to this irreversibility, it should only be enabled during the final stages of production. When enabled, the gen_uicr.py script sets UICR.ERASEPROTECT to 0xFFFFFFFF, which prevents the ERASEALL command from affecting the NVR0 page. Upstream PR #: 97337 Signed-off-by: Sebastian Bøe <[email protected]>
1 parent 8ac1716 commit b22345c

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

scripts/ci/check_compliance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,7 @@ def check_no_undef_outside_kconfig(self, kconf):
13001300
"FOO_LOG_LEVEL",
13011301
"FOO_SETTING_1",
13021302
"FOO_SETTING_2",
1303+
"GEN_UICR_ERASEPROTECT",
13031304
"GEN_UICR_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
13041305
"GEN_UICR_LOCK",
13051306
"GEN_UICR_PROTECTEDMEM",

soc/nordic/common/uicr/gen_uicr.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,11 @@ def main() -> None:
435435
action="store_true",
436436
help="Enable UICR.LOCK to prevent modifications without ERASEALL",
437437
)
438+
parser.add_argument(
439+
"--eraseprotect",
440+
action="store_true",
441+
help="Enable UICR.ERASEPROTECT to block ERASEALL operations",
442+
)
438443
parser.add_argument(
439444
"--protectedmem",
440445
action="store_true",
@@ -605,6 +610,9 @@ def main() -> None:
605610
# Handle LOCK configuration
606611
if args.lock:
607612
uicr.LOCK = ENABLED_VALUE
613+
# Handle ERASEPROTECT configuration
614+
if args.eraseprotect:
615+
uicr.ERASEPROTECT = ENABLED_VALUE
608616
# Handle protected memory configuration
609617
if args.protectedmem:
610618
if args.protectedmem_size_bytes % KB_4 != 0:

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ if(CMAKE_VERBOSE_MAKEFILE)
7676
endif()
7777

7878
set(lock_args)
79+
set(eraseprotect_args)
7980
set(protectedmem_args)
8081
set(periphconf_args)
8182
set(wdtstart_args)
@@ -121,6 +122,11 @@ if(CONFIG_GEN_UICR_LOCK)
121122
list(APPEND lock_args --lock)
122123
endif()
123124

125+
# Handle ERASEPROTECT configuration
126+
if(CONFIG_GEN_UICR_ERASEPROTECT)
127+
list(APPEND eraseprotect_args --eraseprotect)
128+
endif()
129+
124130
# Handle protected memory configuration
125131
if(CONFIG_GEN_UICR_PROTECTEDMEM)
126132
list(APPEND protectedmem_args --protectedmem)
@@ -250,6 +256,7 @@ add_custom_command(
250256
--out-merged-hex ${merged_hex_file}
251257
--out-uicr-hex ${uicr_hex_file}
252258
${lock_args}
259+
${eraseprotect_args}
253260
${wdtstart_args}
254261
${periphconf_args}
255262
${securestorage_args}

soc/nordic/common/uicr/gen_uicr/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ config GEN_UICR_LOCK
4141
in production devices to prevent unauthorized modification of the
4242
UICR configuration.
4343

44+
config GEN_UICR_ERASEPROTECT
45+
bool "Enable UICR.ERASEPROTECT"
46+
help
47+
When enabled, the UICR generator will block ERASEALL operations.
48+
This prevents bulk erasure of protected memory. If enabled along
49+
with UICR.LOCK, it becomes impossible to modify the UICR in any way.
50+
This should only be enabled during final stages of production.
51+
4452
config GEN_UICR_PROTECTEDMEM
4553
bool "Enable UICR.PROTECTEDMEM"
4654
help

0 commit comments

Comments
 (0)