Skip to content

Commit 9f2450f

Browse files
SebastianBoerlubos
authored andcommitted
[nrf fromtree] soc: nordic: uicr: Add support for UICR.SECONDARY.PROTECTEDMEM
Add support for UICR.SECONDARY.PROTECTEDMEM configuration, which enables configuration of the protected memory region for secondary firmware. This introduces Kconfig options for configuring: - GEN_UICR_SECONDARY_PROTECTEDMEM - Enable/disable protected memory for secondary firmware - GEN_UICR_SECONDARY_PROTECTEDMEM_SIZE_BYTES - Size of the protected memory region in bytes The implementation validates that the configured size is divisible by 4096 bytes (4 KiB) as required by the hardware, and converts it to 4 KiB units when writing to UICR.SECONDARY.PROTECTEDMEM.SIZE4KB. Signed-off-by: Sebastian Bøe <[email protected]> (cherry picked from commit c3f6b8c)
1 parent 6c9b26c commit 9f2450f

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

scripts/ci/check_compliance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,8 @@ def check_no_undef_outside_kconfig(self, kconf):
13061306
"GEN_UICR_SECONDARY",
13071307
"GEN_UICR_SECONDARY_GENERATE_PERIPHCONF",
13081308
"GEN_UICR_SECONDARY_PROCESSOR_VALUE",
1309+
"GEN_UICR_SECONDARY_PROTECTEDMEM",
1310+
"GEN_UICR_SECONDARY_PROTECTEDMEM_SIZE_BYTES",
13091311
"GEN_UICR_SECONDARY_TRIGGER",
13101312
"GEN_UICR_SECONDARY_TRIGGER_APPLICATIONLOCKUP",
13111313
"GEN_UICR_SECONDARY_TRIGGER_APPLICATIONWDT0",

soc/nordic/common/uicr/gen_uicr.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,12 @@ def main() -> None:
501501
"(decimal or 0x-prefixed hex)"
502502
),
503503
)
504+
parser.add_argument(
505+
"--secondary-protectedmem-size",
506+
default=None,
507+
type=lambda s: int(s, 0),
508+
help="Size in bytes of the secondary protected memory region (decimal or 0x-prefixed hex)",
509+
)
504510
parser.add_argument(
505511
"--secondary-periphconf-address",
506512
default=None,
@@ -647,6 +653,15 @@ def main() -> None:
647653
uicr.SECONDARY.TRIGGER.ENABLE = ENABLED_VALUE
648654
uicr.SECONDARY.TRIGGER.RESETREAS = args.secondary_trigger_resetreas
649655

656+
# Handle secondary PROTECTEDMEM configuration
657+
if args.secondary_protectedmem_size:
658+
uicr.SECONDARY.PROTECTEDMEM.ENABLE = ENABLED_VALUE
659+
if args.secondary_protectedmem_size % 4096 != 0:
660+
raise ScriptError(
661+
f"args.secondary_protectedmem_size was {args.secondary_protectedmem_size}, "
662+
f"but must be divisible by 4096"
663+
)
664+
uicr.SECONDARY.PROTECTEDMEM.SIZE4KB = args.secondary_protectedmem_size // 4096
650665
# Handle secondary periphconf if provided
651666
if args.out_secondary_periphconf_hex:
652667
secondary_periphconf_combined = extract_and_combine_periphconfs(

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ if(CONFIG_GEN_UICR_SECONDARY)
216216
list(APPEND secondary_args --secondary-trigger-resetreas ${resetreas_value})
217217
endif()
218218

219+
# Handle secondary PROTECTEDMEM configuration
220+
if(CONFIG_GEN_UICR_SECONDARY_PROTECTEDMEM)
221+
list(APPEND secondary_args --secondary-protectedmem-size ${CONFIG_GEN_UICR_SECONDARY_PROTECTEDMEM_SIZE_BYTES})
222+
endif()
223+
219224
if(CONFIG_GEN_UICR_SECONDARY_GENERATE_PERIPHCONF)
220225
# Compute SECONDARY_PERIPHCONF absolute address and size from this image's devicetree
221226
compute_partition_address_and_size("secondary_periphconf_partition" SECONDARY_PERIPHCONF_ADDRESS SECONDARY_PERIPHCONF_SIZE)

soc/nordic/common/uicr/gen_uicr/Kconfig

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,23 @@ config GEN_UICR_SECONDARY_TRIGGER_RADIOCORELOCKUP
205205
help
206206
Boot secondary firmware when Radio core CPU lockup causes a reset.
207207

208-
209208
endif # GEN_UICR_SECONDARY_TRIGGER
210209

210+
config GEN_UICR_SECONDARY_PROTECTEDMEM
211+
bool "Enable UICR.SECONDARY.PROTECTEDMEM"
212+
depends on GEN_UICR_SECONDARY
213+
help
214+
When enabled, the UICR generator will configure the
215+
protected memory region for the secondary firmware.
216+
217+
config GEN_UICR_SECONDARY_PROTECTEDMEM_SIZE_BYTES
218+
int "Secondary protected memory size in bytes"
219+
default 4096
220+
depends on GEN_UICR_SECONDARY_PROTECTEDMEM
221+
help
222+
Size of the secondary protected memory region in bytes.
223+
This value must be divisible by 4096 (4 kiB).
224+
211225
endif # GEN_UICR_SECONDARY
212226

213227
endmenu

0 commit comments

Comments
 (0)