Skip to content

Commit cd1a0c5

Browse files
SebastianBoerlubos
authored andcommitted
[nrf fromtree] soc: nordic: uicr: Add safety flag for permanent device transition
Add --permit-permanently-transitioning-device-to-deployed safety flag to gen_uicr.py, required when enabling both UICR.LOCK and UICR.ERASEPROTECT together. This prevents accidental permanent locking of devices since this combination makes the configuration irreversible. Signed-off-by: Sebastian Bøe <[email protected]> (cherry picked from commit 35b89ab)
1 parent 4cc690e commit cd1a0c5

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

scripts/ci/check_compliance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ def check_no_undef_outside_kconfig(self, kconf):
13541354
"GEN_UICR_APPROTECT_CORESIGHT_PROTECTED",
13551355
"GEN_UICR_APPROTECT_RADIOCORE_PROTECTED",
13561356
"GEN_UICR_ERASEPROTECT",
1357-
"GEN_UICR_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
1357+
"GEN_UICR_GENERATE_PERIPHCONF",
13581358
"GEN_UICR_LOCK",
13591359
"GEN_UICR_PROTECTEDMEM",
13601360
"GEN_UICR_PROTECTEDMEM_SIZE_BYTES",

soc/nordic/common/uicr/gen_uicr.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,14 @@ def main() -> None:
432432
type=lambda s: int(s, 0),
433433
help="Size in bytes of cpurad_its_partition (decimal or 0x-prefixed hex)",
434434
)
435+
parser.add_argument(
436+
"--permit-permanently-transitioning-device-to-deployed",
437+
action="store_true",
438+
help=(
439+
"Safety flag required to enable both UICR.LOCK and UICR.ERASEPROTECT together. "
440+
"Must be explicitly provided to acknowledge permanent device state changes."
441+
),
442+
)
435443
parser.add_argument(
436444
"--lock",
437445
action="store_true",
@@ -624,10 +632,22 @@ def main() -> None:
624632
uicr.SECURESTORAGE.ITS.APPLICATIONSIZE1KB = args.cpuapp_its_size // 1024
625633
uicr.SECURESTORAGE.ITS.RADIOCORESIZE1KB = args.cpurad_its_size // 1024
626634

627-
# Handle LOCK configuration
635+
# Handle LOCK and ERASEPROTECT configuration
636+
# Check if both are enabled together - this requires explicit acknowledgment
637+
if (
638+
args.lock
639+
and args.eraseprotect
640+
and not args.permit_permanently_transitioning_device_to_deployed
641+
):
642+
raise ScriptError(
643+
"Enabling both --lock and --eraseprotect requires "
644+
"--permit-permanently-transitioning-device-to-deployed to be specified. "
645+
"This combination permanently locks the device configuration and prevents "
646+
"ERASEALL."
647+
)
648+
628649
if args.lock:
629650
uicr.LOCK = ENABLED_VALUE
630-
# Handle ERASEPROTECT configuration
631651
if args.eraseprotect:
632652
uicr.ERASEPROTECT = ENABLED_VALUE
633653
# Handle APPROTECT configuration

0 commit comments

Comments
 (0)