Skip to content

Commit 4a1709f

Browse files
committed
[nrf fromtree] soc: nordic: uicr: Add support for UICR.ERASEPROTECT
Add support for UICR.ERASEPROTECT configuration, which controls erase protection for the device. When enabled, this prevents mass erase operations that would normally clear all flash memory and reset the device to factory defaults. This register is controlled through the TAMPC peripheral and provides an additional layer of security for production devices. When combined with UICR.LOCK, it creates a permanent protection that cannot be reversed without destroying the device. The Kconfig option GEN_UICR_ERASEPROTECT_PROTECTED controls whether erase protection is enabled (PROTECTED) or disabled (UNPROTECTED). Signed-off-by: Sebastian Bøe <[email protected]> (cherry picked from commit e20352d80a083fbf6bc0e23e2cb22e95c4b7dd8d)
1 parent b6338af commit 4a1709f

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ config GEN_UICR_LOCK
4343
This should be enabled only in production devices to prevent
4444
unauthorized modification.
4545

46+
config GEN_UICR_ERASEPROTECT
47+
bool "Enable UICR.ERASEPROTECT"
48+
depends on ! GEN_UICR_LOCK
49+
help
50+
When enabled, ERASEALL operations are blocked.
51+
52+
This option is mutually exclusive with UICR.LOCK in Kconfig to prevent
53+
accidental configuration where both are enabled simultaneously. If both
54+
were enabled, the UICR would become impossible to modify in any way.
55+
Note that gen_uicr.py can be used directly to create a configuration
56+
with both enabled if needed.
57+
4658
config GEN_UICR_PROTECTEDMEM
4759
bool "Enable UICR.PROTECTEDMEM"
4860
help

0 commit comments

Comments
 (0)