Skip to content

Commit 4986d37

Browse files
committed
[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. The safety flag must be explicitly provided through the Kconfig option GEN_UICR_PERMIT_PERMANENTLY_TRANSITIONING_DEVICE_TO_DEPLOYED to enable this dangerous combination. This ensures developers are aware of the permanent consequences before locking their devices. Without this safety mechanism, developers might accidentally create devices that cannot be updated or debugged, requiring hardware replacement. Signed-off-by: Sebastian Bøe <[email protected]> (cherry picked from commit 35b89ab)
1 parent 18c8780 commit 4986d37

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
@@ -1304,7 +1304,7 @@ def check_no_undef_outside_kconfig(self, kconf):
13041304
"GEN_UICR_APPROTECT_CORESIGHT_PROTECTED",
13051305
"GEN_UICR_APPROTECT_RADIOCORE_PROTECTED",
13061306
"GEN_UICR_ERASEPROTECT",
1307-
"GEN_UICR_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
1307+
"GEN_UICR_GENERATE_PERIPHCONF",
13081308
"GEN_UICR_LOCK",
13091309
"GEN_UICR_PROTECTEDMEM",
13101310
"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)