Skip to content

Commit 1be37ce

Browse files
SebastianBoerlubos
authored andcommitted
[nrf fromtree] soc: nordic: uicr: Add support for UICR.LOCK
Add support for UICR.LOCK configuration, which locks the entire UICR configuration in NVR0 to prevent unauthorized modifications. This introduces a Kconfig option GEN_UICR_LOCK that enables locking of the UICR. Once locked, the UICR can only be modified by performing an ERASEALL operation. This is a critical security feature for production devices, typically enabled alongside UICR.APPROTECT, UICR.PROTECTEDMEM, and UICR.ERASEPROTECT to establish a complete device protection scheme. When enabled, the gen_uicr.py script sets UICR.LOCK to 0xFFFFFFFF, which configures the NVR0 page as read-only and enforces integrity checks on the UICR content. Signed-off-by: Sebastian Bøe <[email protected]> (cherry picked from commit 1ffdf09)
1 parent 245fde6 commit 1be37ce

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

scripts/ci/check_compliance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,7 @@ def check_no_undef_outside_kconfig(self, kconf):
13511351
"FOO_SETTING_1",
13521352
"FOO_SETTING_2",
13531353
"GEN_UICR_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
1354+
"GEN_UICR_LOCK",
13541355
"GEN_UICR_PROTECTEDMEM",
13551356
"GEN_UICR_PROTECTEDMEM_SIZE_BYTES",
13561357
"GEN_UICR_SECONDARY",

soc/nordic/common/uicr/gen_uicr.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ def main() -> None:
430430
type=lambda s: int(s, 0),
431431
help="Size in bytes of cpurad_its_partition (decimal or 0x-prefixed hex)",
432432
)
433+
parser.add_argument(
434+
"--lock",
435+
action="store_true",
436+
help="Enable UICR.LOCK to prevent modifications without ERASEALL",
437+
)
433438
parser.add_argument(
434439
"--protectedmem",
435440
action="store_true",
@@ -597,6 +602,9 @@ def main() -> None:
597602
uicr.SECURESTORAGE.ITS.APPLICATIONSIZE1KB = args.cpuapp_its_size // 1024
598603
uicr.SECURESTORAGE.ITS.RADIOCORESIZE1KB = args.cpurad_its_size // 1024
599604

605+
# Handle LOCK configuration
606+
if args.lock:
607+
uicr.LOCK = ENABLED_VALUE
600608
# Handle protected memory configuration
601609
if args.protectedmem:
602610
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
@@ -75,6 +75,7 @@ endfunction()
7575
if(CMAKE_VERBOSE_MAKEFILE)
7676
endif()
7777

78+
set(lock_args)
7879
set(protectedmem_args)
7980
set(periphconf_args)
8081
set(wdtstart_args)
@@ -115,6 +116,11 @@ if(CONFIG_GEN_UICR_SECURESTORAGE)
115116
list(APPEND securestorage_args --cpurad-its-size ${CPURAD_ITS_SIZE})
116117
endif(CONFIG_GEN_UICR_SECURESTORAGE)
117118

119+
# Handle LOCK configuration
120+
if(CONFIG_GEN_UICR_LOCK)
121+
list(APPEND lock_args --lock)
122+
endif()
123+
118124
# Handle protected memory configuration
119125
if(CONFIG_GEN_UICR_PROTECTEDMEM)
120126
list(APPEND protectedmem_args --protectedmem)
@@ -243,6 +249,7 @@ add_custom_command(
243249
--uicr-address ${UICR_ADDRESS}
244250
--out-merged-hex ${merged_hex_file}
245251
--out-uicr-hex ${uicr_hex_file}
252+
${lock_args}
246253
${wdtstart_args}
247254
${periphconf_args}
248255
${securestorage_args}

soc/nordic/common/uicr/gen_uicr/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ config GEN_UICR_SECURESTORAGE
3232
- At least one subpartition must be defined
3333
- Combined subpartition sizes must equal secure_storage_partition size
3434

35+
config GEN_UICR_LOCK
36+
bool "Enable UICR.LOCK"
37+
help
38+
When enabled, locks the entire contents of the NVR0 page located in
39+
MRAM10. This includes all values in both the UICR and the BICR (Board
40+
Information Configuration Registers). Once locked, the UICR can only
41+
be modified by performing an ERASEALL operation.
42+
43+
This should be enabled only in production devices to prevent
44+
unauthorized modification.
45+
3546
config GEN_UICR_PROTECTEDMEM
3647
bool "Enable UICR.PROTECTEDMEM"
3748
help

0 commit comments

Comments
 (0)