Skip to content

Commit 57486a5

Browse files
SebastianBoehakonfam
authored andcommitted
soc: nordic: uicr: Add support for uicr.PROTECTEDMEM
Add support for PROTECTEDMEM. Signed-off-by: Sebastian Bøe <[email protected]>
1 parent 18fae83 commit 57486a5

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

scripts/ci/check_compliance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,8 @@ def check_no_undef_outside_kconfig(self, kconf):
12661266
"FOO_SETTING_1",
12671267
"FOO_SETTING_2",
12681268
"GEN_UICR_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
1269+
"GEN_UICR_PROTECTEDMEM", # Used in specialized build tool, not part of main Kconfig
1270+
"GEN_UICR_PROTECTEDMEM_SIZE_BYTES", # Used in specialized build tool, not part of main Kconfig
12691271
"GEN_UICR_SECONDARY", # Used in specialized build tool, not part of main Kconfig
12701272
"GEN_UICR_SECONDARY_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
12711273
"GEN_UICR_SECURESTORAGE", # Used in specialized build tool, not part of main Kconfig

soc/nordic/common/uicr/gen_uicr.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
ENABLED_VALUE = 0xFFFF_FFFF
2727
DISABLED_VALUE = 0xBD23_28A8
2828

29+
KB_4 = 4096
30+
2931

3032
class ScriptError(RuntimeError): ...
3133

@@ -363,6 +365,16 @@ def main() -> None:
363365
type=lambda s: int(s, 0),
364366
help="Absolute flash address of the UICR region (decimal or 0x-prefixed hex)",
365367
)
368+
parser.add_argument(
369+
"--protectedmem",
370+
action="store_true",
371+
help="Enable protected memory region in UICR",
372+
)
373+
parser.add_argument(
374+
"--protectedmem-size-bytes",
375+
type=int,
376+
help="Protected memory size in bytes (must be divisible by 4096)",
377+
)
366378
parser.add_argument(
367379
"--securestorage",
368380
action="store_true",
@@ -535,6 +547,16 @@ def main() -> None:
535547
uicr.SECURESTORAGE.ITS.APPLICATIONSIZE1KB = args.cpuapp_its_size // 1024
536548
uicr.SECURESTORAGE.ITS.RADIOCORESIZE1KB = args.cpurad_its_size // 1024
537549

550+
# Handle protected memory configuration
551+
if args.protectedmem:
552+
if args.protectedmem_size_bytes % KB_4 != 0:
553+
raise ScriptError(
554+
f"Protected memory size ({args.protectedmem_size_bytes} bytes) "
555+
f"must be divisible by {KB_4}"
556+
)
557+
uicr.PROTECTEDMEM.ENABLE = ENABLED_VALUE
558+
uicr.PROTECTEDMEM.SIZE4KB = args.protectedmem_size_bytes // KB_4
559+
538560
# Process periphconf data first and configure UICR completely before creating hex objects
539561
periphconf_hex = IntelHex()
540562
secondary_periphconf_hex = IntelHex()

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ endfunction()
6767
if(CMAKE_VERBOSE_MAKEFILE)
6868
endif()
6969

70+
set(protectedmem_args)
7071
set(periphconf_args)
7172
set(periphconf_elfs)
7273
set(merged_hex_file ${APPLICATION_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.hex)
@@ -79,6 +80,12 @@ set(secondary_periphconf_hex_file ${APPLICATION_BINARY_DIR}/zephyr/secondary_per
7980
dt_nodelabel(uicr_path NODELABEL "uicr" REQUIRED)
8081
dt_reg_addr(UICR_ADDRESS PATH ${uicr_path} REQUIRED)
8182

83+
# Handle protected memory configuration
84+
if(CONFIG_GEN_UICR_PROTECTEDMEM)
85+
list(APPEND protectedmem_args --protectedmem)
86+
list(APPEND protectedmem_args --protectedmem-size-bytes ${CONFIG_GEN_UICR_PROTECTEDMEM_SIZE_BYTES})
87+
endif()
88+
8289
# Handle secure storage configuration
8390
set(securestorage_args)
8491
if(CONFIG_GEN_UICR_SECURESTORAGE)
@@ -181,6 +188,7 @@ add_custom_command(
181188
--out-uicr-hex ${uicr_hex_file}
182189
${periphconf_args}
183190
${securestorage_args}
191+
${protectedmem_args}
184192
${secondary_args}
185193
DEPENDS ${periphconf_elfs} ${secondary_periphconf_elfs}
186194
WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}

soc/nordic/common/uicr/gen_uicr/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ config GEN_UICR_GENERATE_PERIPHCONF
1010
When enabled, the UICR generator will populate the
1111
periphconf_partition partition.
1212

13+
config GEN_UICR_PROTECTEDMEM
14+
bool "Enable UICR.PROTECTEDMEM"
15+
help
16+
When enabled, the UICR generator will configure the
17+
protected memory region.
18+
19+
config GEN_UICR_PROTECTEDMEM_SIZE_BYTES
20+
int "Protected memory size in bytes"
21+
default 4096
22+
depends on GEN_UICR_PROTECTEDMEM
23+
help
24+
Size of the protected memory region in bytes.
25+
This value must be divisible by 4096 (4 kiB).
26+
1327
config GEN_UICR_SECONDARY
1428
bool "Enable UICR.SECONDARY.ENABLE"
1529

0 commit comments

Comments
 (0)